Class: PayPal::Client
- Inherits:
-
Object
- Object
- PayPal::Client
- Defined in:
- lib/pay_pal/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#sandbox ⇒ Object
readonly
Returns the value of attribute sandbox.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(access_token:, sandbox: true, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #orders ⇒ Object
- #products ⇒ Object
Constructor Details
#initialize(access_token:, sandbox: true, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 |
# File 'lib/pay_pal/client.rb', line 5 def initialize(access_token:, sandbox: true, adapter: Faraday.default_adapter, stubs: nil) @access_token = access_token @sandbox = sandbox @adapter = adapter # Test stubs for requests @stubs = stubs end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
3 4 5 |
# File 'lib/pay_pal/client.rb', line 3 def access_token @access_token end |
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
3 4 5 |
# File 'lib/pay_pal/client.rb', line 3 def adapter @adapter end |
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
3 4 5 |
# File 'lib/pay_pal/client.rb', line 3 def sandbox @sandbox end |
Instance Method Details
#connection ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pay_pal/client.rb', line 22 def connection url = @sandbox ? "https://api-m.sandbox.paypal.com" : "https://api-m.paypal.com" @connection ||= Faraday.new(url) do |conn| conn.request :authorization, :Bearer, access_token conn.request :json conn.response :json conn.adapter adapter, @stubs end end |
#orders ⇒ Object
18 19 20 |
# File 'lib/pay_pal/client.rb', line 18 def orders OrdersResource.new(self) end |
#products ⇒ Object
14 15 16 |
# File 'lib/pay_pal/client.rb', line 14 def products ProductsResource.new(self) end |