Class: Bigcommerce::Customer
- Defined in:
- lib/bigcommerce/resources/customers/customer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#login_token(config: Bigcommerce.config, redirect_to: '/') ⇒ Object
Generate a token that can be used to log the customer into the storefront.
Class Method Details
.count(params = {}) ⇒ Object
32 33 34 |
# File 'lib/bigcommerce/resources/customers/customer.rb', line 32 def self.count(params = {}) get 'customers/count', params end |
Instance Method Details
#login_token(config: Bigcommerce.config, redirect_to: '/') ⇒ 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.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bigcommerce/resources/customers/customer.rb', line 39 def login_token(config: Bigcommerce.config, redirect_to: '/') payload = { 'iss' => config.client_id, 'iat' => Time.now.to_i, 'jti' => SecureRandom.uuid, 'operation' => 'customer_login', 'store_hash' => config.store_hash, 'customer_id' => id, 'redirect_to' => redirect_to } JWT.encode(payload, config.client_secret, 'HS256', { typ: 'JWT' }) end |