Class: Prodigi::Client
- Inherits:
-
Object
- Object
- Prodigi::Client
- Defined in:
- lib/prodigi/client.rb
Constant Summary collapse
- BASE_URL =
ENV.fetch('PRODIGI_API_URL',"https://api.sandbox.prodigi.com/v4.0")
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #orders ⇒ Object
- #products ⇒ Object
- #quotes ⇒ Object
Constructor Details
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 |
# File 'lib/prodigi/client.rb', line 7 def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) @api_key = api_key @adapter = adapter # Tests stubs for requests @stubs = stubs end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/prodigi/client.rb', line 5 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/prodigi/client.rb', line 5 def api_key @api_key end |
Instance Method Details
#connection ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/prodigi/client.rb', line 27 def connection @connection ||= Faraday.new do |conn| conn.url_prefix = BASE_URL conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |
#orders ⇒ Object
15 16 17 |
# File 'lib/prodigi/client.rb', line 15 def orders OrderResource.new(self) end |
#products ⇒ Object
23 24 25 |
# File 'lib/prodigi/client.rb', line 23 def products ProductResource.new(self) end |
#quotes ⇒ Object
19 20 21 |
# File 'lib/prodigi/client.rb', line 19 def quotes QuoteResource.new(self) end |