Class: ShopExpress::Client

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

Overview

Base class used to store data about authentication

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, login:, password:) ⇒ Client

Returns a new instance of Client.

Parameters:

  • url (URI)
  • login (String)
  • password (String)


17
18
19
20
21
22
23
# File 'lib/shop_express.rb', line 17

def initialize(url:, login:, password:)
  @url = url
  @login = 
  @password = password
  @token = nil
  @expiration_timestamp = nil
end

Instance Attribute Details

#expiration_timestampObject

Returns the value of attribute expiration_timestamp.



12
13
14
# File 'lib/shop_express.rb', line 12

def expiration_timestamp
  @expiration_timestamp
end

#loginObject

Returns the value of attribute login.



12
13
14
# File 'lib/shop_express.rb', line 12

def 
  @login
end

#passwordObject

Returns the value of attribute password.



12
13
14
# File 'lib/shop_express.rb', line 12

def password
  @password
end

#tokenObject

Returns the value of attribute token.



12
13
14
# File 'lib/shop_express.rb', line 12

def token
  @token
end

#urlObject

Returns the value of attribute url.



12
13
14
# File 'lib/shop_express.rb', line 12

def url
  @url
end

Instance Method Details

#refresh_token!Object



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

def refresh_token!
  ShopExpress::Authorization.new(self).authorize
end

#token_valid?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/shop_express.rb', line 25

def token_valid?
  return false if token.nil?

  expiration_timestamp > Time.now
end