Class: Multisafepay::Client
- Inherits:
-
Object
- Object
- Multisafepay::Client
- Defined in:
- lib/multisafepay/client.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #accounts ⇒ Object
- #capture ⇒ Object
- #connection ⇒ Object
- #gateways ⇒ Object
-
#initialize(api_key: nil, env: :live, adapter: Faraday.default_adapter) ⇒ Client
constructor
A new instance of Client.
- #orders ⇒ Object
- #tokens ⇒ Object
- #transactions ⇒ Object
Constructor Details
#initialize(api_key: nil, env: :live, adapter: Faraday.default_adapter) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 |
# File 'lib/multisafepay/client.rb', line 5 def initialize(api_key: nil, env: :live, adapter: Faraday.default_adapter) @api_key = api_key @env = env @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
3 4 5 |
# File 'lib/multisafepay/client.rb', line 3 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/multisafepay/client.rb', line 3 def api_key @api_key end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
3 4 5 |
# File 'lib/multisafepay/client.rb', line 3 def env @env end |
Instance Method Details
#accounts ⇒ Object
11 12 13 |
# File 'lib/multisafepay/client.rb', line 11 def accounts AccountsResource.new(self) end |
#capture ⇒ Object
15 16 17 |
# File 'lib/multisafepay/client.rb', line 15 def capture CaptureResource.new(self) end |
#connection ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/multisafepay/client.rb', line 35 def connection @connection ||= Faraday.new(base_url) do |conn| conn.headers["api_key"] = api_key conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter end end |
#gateways ⇒ Object
19 20 21 |
# File 'lib/multisafepay/client.rb', line 19 def gateways GatewaysResource.new(self) end |
#orders ⇒ Object
23 24 25 |
# File 'lib/multisafepay/client.rb', line 23 def orders OrdersResource.new(self) end |
#tokens ⇒ Object
27 28 29 |
# File 'lib/multisafepay/client.rb', line 27 def tokens TokensResource.new(self) end |
#transactions ⇒ Object
31 32 33 |
# File 'lib/multisafepay/client.rb', line 31 def transactions TransactionsResource.new(self) end |