class SuperLanding::API::Base

Attributes

access_key[RW]
base_url[RW]
merchant_no[RW]

Public Class Methods

new(merchant_no, access_key, base_url=nil) click to toggle source
# File lib/super_landing/api/base.rb, line 7
def initialize(merchant_no, access_key, base_url=nil)
  @merchant_no = merchant_no
  @access_key = access_key
  @base_url = base_url.nil? ? SuperLanding::BASE_URL : base_url
end

Protected Instance Methods

get(path) click to toggle source
# File lib/super_landing/api/base.rb, line 21
def get(path)
  RestClient.get(uri(path).to_s)
rescue RestClient::ExceptionWithResponse => e
  e.response
end
params() click to toggle source
GET

query string params

# File lib/super_landing/api/base.rb, line 28
def params
  {}
end
post(path) click to toggle source
# File lib/super_landing/api/base.rb, line 15
def post(path)
  RestClient.post(uri(path).to_s, post_data)
rescue RestClient::ExceptionWithResponse => e
  e.response
end
post_data() click to toggle source
POST
# File lib/super_landing/api/base.rb, line 33
def post_data
  {}
end

Private Instance Methods

auth_params() click to toggle source
# File lib/super_landing/api/base.rb, line 47
def auth_params
  { merchant_no: merchant_no, access_key: access_key }
end
query_auth_params() click to toggle source
# File lib/super_landing/api/base.rb, line 43
def query_auth_params
  URI.encode_www_form(auth_params.merge(params))
end
uri(path) click to toggle source
# File lib/super_landing/api/base.rb, line 39
def uri(path)
  uri = URI.parse("#{base_url}#{path}").tap { |u| u.query = query_auth_params }
end