Class: Lightspeed::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/lightspeed/client.rb

Constant Summary collapse

API_BASE =
"https://api.merchantos.com/API/"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, account_id:, configuration:) ⇒ Client

Returns a new instance of Client.



27
28
29
30
31
# File 'lib/lightspeed/client.rb', line 27

def initialize(access_token:, account_id:, configuration:)
  @access_token = access_token
  @account_id = 
  @configuration = configuration
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



21
22
23
# File 'lib/lightspeed/client.rb', line 21

def access_token
  @access_token
end

#account_idObject (readonly)

Returns the value of attribute account_id.



21
22
23
# File 'lib/lightspeed/client.rb', line 21

def 
  @account_id
end

Class Method Details

.tokens(client_id:, client_secret:, refresh_token:) ⇒ Object



23
24
25
# File 'lib/lightspeed/client.rb', line 23

def self.tokens(client_id:, client_secret:, refresh_token:)
  API::Tokens.new(client_id, client_secret, refresh_token)
end

Instance Method Details

#accountsObject



57
# File 'lib/lightspeed/client.rb', line 57

def accounts; API::Accounts.new(self); end

#categoriesObject



61
# File 'lib/lightspeed/client.rb', line 61

def categories; API::Categories.new(self); end

#customersObject



59
# File 'lib/lightspeed/client.rb', line 59

def customers; API::Customers.new(self); end

#delete(url) ⇒ Object



45
46
47
48
49
# File 'lib/lightspeed/client.rb', line 45

def delete(url)
  response = conn.delete(url)
  rate_limit_wait(response)
  response
end

#get(url, params: {}, relations: []) ⇒ Object



33
34
35
36
37
# File 'lib/lightspeed/client.rb', line 33

def get(url, params: {}, relations: [])
  response = conn.get(url, params.merge(load_relations: "[#{relation_names(relations)}]"))
  rate_limit_wait(response)
  response
end

#itemsObject



60
# File 'lib/lightspeed/client.rb', line 60

def items; API::Items.new(self); end

#post(url, body: {}) ⇒ Object



39
40
41
42
43
# File 'lib/lightspeed/client.rb', line 39

def post(url, body: {})
  response = conn.post(url, body)
  rate_limit_wait(response)
  response
end

#put(url, body: {}) ⇒ Object



51
52
53
54
55
# File 'lib/lightspeed/client.rb', line 51

def put(url, body: {})
  response = conn.put(url, body)
  rate_limit_wait(response)
  response
end

#salesObject



58
# File 'lib/lightspeed/client.rb', line 58

def sales; API::Sales.new(self); end