Class: NMIGateway::Api
- Inherits:
-
Object
- Object
- NMIGateway::Api
- Includes:
- HTTParty
- Defined in:
- lib/nmi_gateway/api.rb
Direct Known Subclasses
Constant Summary collapse
- TRANSACTION_URL =
ENV.fetch("NMI_TRANSACTION_URL", "https://figpay.transactiongateway.com/api/transact.php")
- QUERY_URL =
ENV.fetch("NMI_QUERY_URL", "https://figpay.transactiongateway.com/api/query.php")
Instance Attribute Summary collapse
-
#query ⇒ Object
Returns the value of attribute query.
-
#security_key ⇒ Object
Returns the value of attribute security_key.
Instance Method Summary collapse
- #get(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Api
constructor
A new instance of Api.
- #post(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Api
Returns a new instance of Api.
9 10 11 |
# File 'lib/nmi_gateway/api.rb', line 9 def initialize( = {}) @security_key = [:security_key] || ENV["NMI_SECURITY_KEY"] end |
Instance Attribute Details
#query ⇒ Object
Returns the value of attribute query.
7 8 9 |
# File 'lib/nmi_gateway/api.rb', line 7 def query @query end |
#security_key ⇒ Object
Returns the value of attribute security_key.
7 8 9 |
# File 'lib/nmi_gateway/api.rb', line 7 def security_key @security_key end |
Instance Method Details
#get(options = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/nmi_gateway/api.rb', line 13 def get(={}) response = self.class.get(QUERY_URL, query: .merge(credentials), timeout: 30, headers: headers) api_type = [:type] || [:report_type] handle_response(response, api_type) end |
#post(options = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/nmi_gateway/api.rb', line 19 def post(={}) response = self.class.get(TRANSACTION_URL, query: .merge(credentials), timeout: 30, headers: headers) api_type = [:type] || [:customer_vault] handle_response(response, api_type) end |