Class: Bigcommerce::Customer

Inherits:
Resource
  • Object
show all
Defined in:
lib/bigcommerce/resources/customers/customer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.count(params = {}) ⇒ Object


30
31
32
# File 'lib/bigcommerce/resources/customers/customer.rb', line 30

def self.count(params = {})
  get 'customers/count', params
end

Instance Method Details

#login_token(config: Bigcommerce.config) ⇒ Object

Generate a token that can be used to log the customer into the storefront. This requires your app to have the store_v2_customers_login scope and to be installed in the store.


37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bigcommerce/resources/customers/customer.rb', line 37

def (config: Bigcommerce.config)
  payload = {
    'iss' => config.client_id,
    'iat' => Time.now.to_i,
    'jti' => SecureRandom.uuid,
    'operation' => 'customer_login',
    'store_hash' => config.store_hash,
    'customer_id' => id
  }

  JWT.encode(payload, config.client_secret, 'HS256')
end