class ForteRuby::API::RequestData
Attributes
config[RW]
Public Class Methods
new()
click to toggle source
# File lib/forte_ruby/api/request_data.rb, line 6 def initialize self.config = parse_config_file end
Public Instance Methods
base_url()
click to toggle source
# File lib/forte_ruby/api/request_data.rb, line 10 def base_url "#{config.endpoint}/accounts/#{account_id}/locations/#{location_id}" end
headers()
click to toggle source
# File lib/forte_ruby/api/request_data.rb, line 14 def headers { 'X-Forte-Auth-Account-Id' => account_id, 'Authorization' => "Basic #{signature}", 'Accept' => 'application/json', 'Content-Type' => 'json' } end
Private Instance Methods
account_id()
click to toggle source
# File lib/forte_ruby/api/request_data.rb, line 25 def account_id "act_#{config.account_id}" end
location_id()
click to toggle source
# File lib/forte_ruby/api/request_data.rb, line 29 def location_id "loc_#{config.location_id}" end
parse_config_file()
click to toggle source
# File lib/forte_ruby/api/request_data.rb, line 33 def parse_config_file file = Rails.root.join("config").join("forte_ruby.yml") data = YAML.load(ERB.new(IO.read(file)).result)[Rails.env] rescue nil data ? OpenStruct.new(data) : data end
signature()
click to toggle source
# File lib/forte_ruby/api/request_data.rb, line 39 def signature credentials = "#{config.api_login_id}:#{config.secure_transaction_key}" Base64.encode64(credentials).gsub("\n", "") end