Class: Lightspeed::Client
- Inherits:
-
Object
- Object
- Lightspeed::Client
- Defined in:
- lib/lightspeed/client.rb
Constant Summary collapse
- API_BASE =
"https://api.merchantos.com/API/"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
Class Method Summary collapse
Instance Method Summary collapse
- #accounts ⇒ Object
- #categories ⇒ Object
- #customers ⇒ Object
- #delete(url) ⇒ Object
- #get(url, params: {}, relations: []) ⇒ Object
-
#initialize(access_token:, account_id:) ⇒ Client
constructor
A new instance of Client.
- #items ⇒ Object
- #post(url, body: {}) ⇒ Object
- #sales ⇒ Object
Constructor Details
#initialize(access_token:, account_id:) ⇒ Client
Returns a new instance of Client.
18 19 20 21 |
# File 'lib/lightspeed/client.rb', line 18 def initialize(access_token:, account_id:) @access_token = access_token @account_id = account_id end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
12 13 14 |
# File 'lib/lightspeed/client.rb', line 12 def access_token @access_token end |
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
12 13 14 |
# File 'lib/lightspeed/client.rb', line 12 def account_id @account_id end |
Class Method Details
.tokens(client_id:, client_secret:, refresh_token:) ⇒ Object
14 15 16 |
# File 'lib/lightspeed/client.rb', line 14 def self.tokens(client_id:, client_secret:, refresh_token:) API::Tokens.new(client_id, client_secret, refresh_token) end |
Instance Method Details
#accounts ⇒ Object
35 |
# File 'lib/lightspeed/client.rb', line 35 def accounts; API::Accounts.new(self); end |
#categories ⇒ Object
39 |
# File 'lib/lightspeed/client.rb', line 39 def categories; API::Categories.new(self); end |
#customers ⇒ Object
37 |
# File 'lib/lightspeed/client.rb', line 37 def customers; API::Customers.new(self); end |
#delete(url) ⇒ Object
31 32 33 |
# File 'lib/lightspeed/client.rb', line 31 def delete(url) conn.delete(url) end |
#get(url, params: {}, relations: []) ⇒ Object
23 24 25 |
# File 'lib/lightspeed/client.rb', line 23 def get(url, params: {}, relations: []) conn.get(url, params.merge(load_relations: "[#{relation_names(relations)}]")) end |
#items ⇒ Object
38 |
# File 'lib/lightspeed/client.rb', line 38 def items; API::Items.new(self); end |
#post(url, body: {}) ⇒ Object
27 28 29 |
# File 'lib/lightspeed/client.rb', line 27 def post(url, body: {}) conn.post(url, body) end |
#sales ⇒ Object
36 |
# File 'lib/lightspeed/client.rb', line 36 def sales; API::Sales.new(self); end |