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.



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

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.



9
10
11
# File 'lib/lightspeed/client.rb', line 9

def throttler
  @throttler
end

Instance Method Details

#accountsObject

Returns a list of accounts that you have access to.



19
20
21
# File 'lib/lightspeed/client.rb', line 19

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

#delete(**args) ⇒ Object



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

def delete(**args)
  perform_request(args.merge(method: :delete))
end

#get(**args) ⇒ Object



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

def get(**args)
  perform_request(args.merge(method: :get))
end

#oauth_tokenObject



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

def oauth_token
  @oauth_token_holder.oauth_token
end

#post(**args) ⇒ Object



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

def post(**args)
  perform_request(args.merge(method: :post))
end

#put(**args) ⇒ Object



31
32
33
# File 'lib/lightspeed/client.rb', line 31

def put(**args)
  perform_request(args.merge(method: :put))
end

#refresh_oauth_tokenObject



43
44
45
# File 'lib/lightspeed/client.rb', line 43

def refresh_oauth_token
  @oauth_token_holder.refresh_oauth_token
end