Class: PriorityPayoutGateway::Api

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/priority_payout_gateway/api.rb

Direct Known Subclasses

CustomerVault, Recurring, Transaction

Constant Summary collapse

TRANSACTION_URL =
ENV.fetch("TRANSACTION_URL", "https://secure.prioritypayoutgateway.com/api/transact.php")
QUERY_URL =
ENV.fetch( "QUERY_URL", "https://secure.prioritypayoutgateway.com/api/query.php")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Api

Returns a new instance of Api.



9
10
11
12
# File 'lib/priority_payout_gateway/api.rb', line 9

def initialize(options = {})
  @username = options[:username] || ENV["PPG_USERNAME"]
  @password = options[:password] || ENV["PPG_PASSWORD"]
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/priority_payout_gateway/api.rb', line 7

def password
  @password
end

#queryObject

Returns the value of attribute query.



7
8
9
# File 'lib/priority_payout_gateway/api.rb', line 7

def query
  @query
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/priority_payout_gateway/api.rb', line 7

def username
  @username
end

Instance Method Details

#get(options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/priority_payout_gateway/api.rb', line 14

def get(options={})
  response = self.class.get(QUERY_URL, query: options.merge(credentials), timeout: 30, headers: headers)
  api_type = options[:type] || options[:report_type]
  handle_response(response, api_type)
end

#post(options = {}) ⇒ Object



20
21
22
23
24
# File 'lib/priority_payout_gateway/api.rb', line 20

def post(options={})
  response = self.class.get(TRANSACTION_URL, query: options.merge(credentials), timeout: 30, headers: headers)
  api_type = options[:type] || options[:customer_vault]
  handle_response(response, api_type)
end