class FortePayments::Client

Attributes

account_id[R]
api_key[R]
location_id[R]
secure_key[R]

Public Class Methods

new(api_key: api_key, secure_key: secure_key, account_id: account_id, location_id: location_id) click to toggle source
# File lib/forte_payments/client.rb, line 16
def initialize(api_key: api_key, secure_key: secure_key, account_id: account_id, location_id: location_id)
  @api_key     = api_key
  @secure_key  = secure_key
  @account_id  = account_id
  @location_id = location_id
end

Public Instance Methods

delete(path, options = {}) click to toggle source
# File lib/forte_payments/client.rb, line 38
def delete(path, options = {})
  connection.delete(path, options).body
end
get(path, options={}) click to toggle source
# File lib/forte_payments/client.rb, line 23
def get(path, options={})
  connection.get(path, options).body
end
post(path, req_body) click to toggle source
# File lib/forte_payments/client.rb, line 27
def post(path, req_body)
  connection.post do |req|
    req.url(path)
    req.body = req_body
  end.body
end
put(path, options={}) click to toggle source
# File lib/forte_payments/client.rb, line 34
def put(path, options={})
  connection.put(path, options).body
end

Private Instance Methods

base_path() click to toggle source
# File lib/forte_payments/client.rb, line 48
def base_path
  "/accounts/#{account_id}/locations/#{location_id}"
end
base_url() click to toggle source
# File lib/forte_payments/client.rb, line 44
def base_url
  "https://sandbox.forte.net/api/v2"
end
connection() click to toggle source
# File lib/forte_payments/client.rb, line 52
def connection
  Faraday.new(url: base_url, headers: { accept: 'application/json' }) do |connection|
    connection.basic_auth api_key, secure_key
    connection.request    :json
    connection.response   :logger
    connection.use        FaradayMiddleware::Mashify
    connection.response   :json
    connection.adapter    Faraday.default_adapter
  end
end