Class: Cin7API::Client
- Inherits:
-
Object
- Object
- Cin7API::Client
- Defined in:
- lib/cin7_api/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.cin7.com/api/v1/"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #branch ⇒ Object
- #connection ⇒ Object
- #credit_note ⇒ Object
-
#initialize(username:, api_key:, adapter: Faraday.default_adapter) ⇒ Client
constructor
A new instance of Client.
- #payment ⇒ Object
- #sales_order ⇒ Object
Constructor Details
#initialize(username:, api_key:, adapter: Faraday.default_adapter) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 |
# File 'lib/cin7_api/client.rb', line 11 def initialize(username:, api_key:, adapter: Faraday.default_adapter) @username = username @api_key = api_key @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/cin7_api/client.rb', line 9 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/cin7_api/client.rb', line 9 def api_key @api_key end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
9 10 11 |
# File 'lib/cin7_api/client.rb', line 9 def username @username end |
Instance Method Details
#branch ⇒ Object
29 30 31 |
# File 'lib/cin7_api/client.rb', line 29 def branch BranchResource.new(self) end |
#connection ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/cin7_api/client.rb', line 33 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 conn.request :authorization, :basic, username, api_key end end |
#credit_note ⇒ Object
21 22 23 |
# File 'lib/cin7_api/client.rb', line 21 def credit_note CreditNoteResource.new(self) end |
#payment ⇒ Object
25 26 27 |
# File 'lib/cin7_api/client.rb', line 25 def payment PaymentResource.new(self) end |
#sales_order ⇒ Object
17 18 19 |
# File 'lib/cin7_api/client.rb', line 17 def sales_order SalesOrderResource.new(self) end |