Class: EcwidApi::Client
- Inherits:
-
Object
- Object
- EcwidApi::Client
- Extended by:
- Forwardable
- Defined in:
- lib/ecwid_api/client.rb
Overview
Constant Summary collapse
- DEFAULT_URL =
The default base URL for the Ecwid API
"https://app.ecwid.com/api/v3"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#store_id ⇒ Object
readonly
Public: Returns the Ecwid Store ID.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#categories ⇒ Object
Public: Returns the Category API.
-
#connection ⇒ Object
Private: Returns a Faraday connection to interface with the Ecwid API.
-
#initialize(store_id, token, adapter = Faraday.default_adapter) ⇒ Client
constructor
Public: Initializes a new Client to interact with the API.
-
#orders ⇒ Object
Public: Returns the Order API.
-
#products ⇒ Object
Public: Returns the Products API.
-
#store_url ⇒ Object
Public: The URL of the API for the Ecwid Store.
Constructor Details
#initialize(store_id, token, adapter = Faraday.default_adapter) ⇒ Client
Public: Initializes a new Client to interact with the API
store_id - the Ecwid store_id to interact with token - the authorization token provided by oAuth. See the
Authentication class
27 28 29 |
# File 'lib/ecwid_api/client.rb', line 27 def initialize(store_id, token, adapter = Faraday.default_adapter) @store_id, @token, @adapter = store_id, token, adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
19 20 21 |
# File 'lib/ecwid_api/client.rb', line 19 def adapter @adapter end |
#store_id ⇒ Object (readonly)
Public: Returns the Ecwid Store ID
17 18 19 |
# File 'lib/ecwid_api/client.rb', line 17 def store_id @store_id end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
18 19 20 |
# File 'lib/ecwid_api/client.rb', line 18 def token @token end |
Instance Method Details
#categories ⇒ Object
Public: Returns the Category API
39 40 41 |
# File 'lib/ecwid_api/client.rb', line 39 def categories @categories ||= Api::Categories.new(self) end |
#connection ⇒ Object
Private: Returns a Faraday connection to interface with the Ecwid API
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ecwid_api/client.rb', line 54 def connection @connection ||= Faraday.new store_url do |conn| conn.request :oauth2, token, param_name: :token conn.request :json conn.response :json, content_type: /\bjson$/ conn.response :logger conn.adapter adapter end end |
#orders ⇒ Object
Public: Returns the Order API
44 45 46 |
# File 'lib/ecwid_api/client.rb', line 44 def orders @orders ||= Api::Orders.new(self) end |
#products ⇒ Object
Public: Returns the Products API
49 50 51 |
# File 'lib/ecwid_api/client.rb', line 49 def products @products ||= Api::Products.new(self) end |
#store_url ⇒ Object
Public: The URL of the API for the Ecwid Store
32 33 34 |
# File 'lib/ecwid_api/client.rb', line 32 def store_url "#{DEFAULT_URL}/#{store_id}" end |