Module: ShopifyApp::SessionStorage::ShopStorageStrategy

Defined in:
lib/shopify_app/session/storage_strategies/shop_storage_strategy.rb

Instance Method Summary collapse

Instance Method Details

#retrieve(id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/shopify_app/session/storage_strategies/shop_storage_strategy.rb', line 11

def retrieve(id)
  return unless id
  if shop = self.find_by(id: id)
    ShopifyAPI::Session.new(
      domain: shop.shopify_domain,
      token: shop.shopify_token,
      api_version: shop.api_version
    )
  end
end

#store(auth_session, *args) ⇒ Object



4
5
6
7
8
9
# File 'lib/shopify_app/session/storage_strategies/shop_storage_strategy.rb', line 4

def store(auth_session, *args)
  shop = find_or_initialize_by(shopify_domain: auth_session.domain)
  shop.shopify_token = auth_session.token
  shop.save!
  shop.id
end