class Api::Billing

Constants

KEY_PATH

Public Instance Methods

api_call_result() click to toggle source
# File lib/api/billing.rb, line 31
def api_call_result
  @api_result ||= Net::HTTP.post_form(uri, signed_data)
end
auth_key() click to toggle source
# File lib/api/billing.rb, line 15
def auth_key
  File.read(KEY_PATH)
end
host_with_port() click to toggle source
# File lib/api/billing.rb, line 10
def host_with_port
  host = ENV['API_HOST']
  "http://#{host.strip}"
end
hostname() click to toggle source
# File lib/api/billing.rb, line 19
def hostname
  ENV['HOSTNAME']
end
response() click to toggle source
# File lib/api/billing.rb, line 27
def response
  JSON.parse(api_call_result.body)
end
signed_data() click to toggle source
# File lib/api/billing.rb, line 39
def signed_data
  data.merge!({ signature: Signer.sign_hash(data, auth_key) })
end
success_api_call?() click to toggle source
# File lib/api/billing.rb, line 23
def success_api_call?
  api_call_result.code == '200'
end
uri() click to toggle source
# File lib/api/billing.rb, line 35
def uri
  URI("#{host_with_port}/api/#{action}")
end