Class: PayCertify::Gateway::Client
- Inherits:
-
Object
- Object
- PayCertify::Gateway::Client
- Defined in:
- lib/paycertify/gateway/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #api_endpoint ⇒ Object
- #error? ⇒ Boolean
- #get(path:, data: {}) ⇒ Object
-
#initialize(api_key:, mode:) ⇒ Client
constructor
A new instance of Client.
- #live? ⇒ Boolean
- #post(path:, data:) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(api_key:, mode:) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/paycertify/gateway/client.rb', line 9 def initialize(api_key:, mode:) self.api_key = api_key self.mode = mode.to_s.to_sym end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/paycertify/gateway/client.rb', line 7 def api_key @api_key end |
#mode ⇒ Object
Returns the value of attribute mode.
7 8 9 |
# File 'lib/paycertify/gateway/client.rb', line 7 def mode @mode end |
#response ⇒ Object
Returns the value of attribute response.
7 8 9 |
# File 'lib/paycertify/gateway/client.rb', line 7 def response @response end |
Instance Method Details
#api_endpoint ⇒ Object
18 19 20 |
# File 'lib/paycertify/gateway/client.rb', line 18 def api_endpoint @api_endpoint ||= 'https://'+ (live?? 'gateway' : 'demo') +'.paycertify.net' end |
#error? ⇒ Boolean
43 44 45 |
# File 'lib/paycertify/gateway/client.rb', line 43 def error? !success? end |
#get(path:, data: {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/paycertify/gateway/client.rb', line 22 def get(path:, data: {}) data.merge!(token_payload) response = connection.get(path, data) respond_with response end |
#live? ⇒ Boolean
14 15 16 |
# File 'lib/paycertify/gateway/client.rb', line 14 def live? mode.to_sym == :live end |
#post(path:, data:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/paycertify/gateway/client.rb', line 28 def post(path:, data:) body = data.merge(token_payload) response = connection.post do |request| request.url path request.body = body end respond_with response end |
#success? ⇒ Boolean
39 40 41 |
# File 'lib/paycertify/gateway/client.rb', line 39 def success? response.status < 400 end |