class PQSDK::Token
The Token
holds the random access token generated on every crawler run, and it is used to authenticate all following requests.
Public Class Methods
access_token()
click to toggle source
# File lib/pqsdk/token.rb, line 21 def self.access_token if @access_token.nil? || @expiration <= Time.now get else @access_token end end
get()
click to toggle source
# File lib/pqsdk/token.rb, line 9 def self.get res = RestLayer.get('v1/token', {}, 'Authentication' => "Key #{Settings.app_secret}") if res[0] == 200 @access_token = res[1]['token'] @expiration = Time.parse(res[1]['expired_at']) @retailer_id = res[1]['retailer_id'] end @access_token end
reset!()
click to toggle source
# File lib/pqsdk/token.rb, line 35 def self.reset! @access_token = nil @expiration = nil @retailer_id = nil end
retailer_id()
click to toggle source
# File lib/pqsdk/token.rb, line 29 def self.retailer_id get unless @retailer_id @retailer_id end