Sha256: db96dfa0cc828b8de5f4449e0eb8694665a28096bc1c5c5fec3e8f0e177a37f0
Contents?: true
Size: 988 Bytes
Versions: 47
Compression:
Stored size: 988 Bytes
Contents
# frozen_string_literal: true module ShopifyApp module ShopSessionStorage extend ActiveSupport::Concern include ::ShopifyApp::SessionStorage included do validates :shopify_domain, presence: true, uniqueness: { case_sensitive: false } end class_methods do 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 def retrieve(id) shop = find_by(id: id) construct_session(shop) end def retrieve_by_shopify_domain(domain) shop = find_by(shopify_domain: domain) construct_session(shop) end private def construct_session(shop) return unless shop ShopifyAPI::Session.new( domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version, ) end end end end
Version data entries
47 entries across 47 versions & 2 rubygems