Class: Lightspeed::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(oauth_token_holder: nil, oauth_token: nil) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
# File 'lib/lightspeed/client.rb', line 13

def initialize(oauth_token_holder: nil, oauth_token: nil)
  @oauth_token_holder = oauth_token_holder
  @throttler = Lightspeed::RequestThrottler.new

  raise "Passing an oauth token is no longer supported. Pass a token holder instead." if oauth_token
end

Instance Attribute Details

#throttlerObject

Returns the value of attribute throttler.



11
12
13
# File 'lib/lightspeed/client.rb', line 11

def throttler
  @throttler
end

Instance Method Details

#accountsObject

Returns a list of accounts that you have access to.



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

def accounts
  @accounts ||= Lightspeed::Accounts.new(context: self)
end

#delete(**args) ⇒ Object



37
38
39
# File 'lib/lightspeed/client.rb', line 37

def delete(**args)
  perform_request(**args, method: :delete)
end

#get(**args) ⇒ Object



25
26
27
# File 'lib/lightspeed/client.rb', line 25

def get(**args)
  perform_request(**args, method: :get)
end

#oauth_tokenObject



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

def oauth_token
  @oauth_token_holder.oauth_token
end

#post(**args) ⇒ Object



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

def post(**args)
  perform_request(**args, method: :post)
end

#put(**args) ⇒ Object



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

def put(**args)
  perform_request(**args, method: :put)
end

#refresh_oauth_tokenObject



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

def refresh_oauth_token
  @oauth_token_holder.refresh_oauth_token
end