Class: ShopifyApp::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_app/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



47
48
49
50
51
52
53
# File 'lib/shopify_app/configuration.rb', line 47

def initialize
  @root_url = "/"
  @myshopify_domain = "myshopify.com"
  @scripttags_manager_queue_name = Rails.application.config.active_job.queue_name
  @webhooks_manager_queue_name = Rails.application.config.active_job.queue_name
  @disable_webpacker = ENV["SHOPIFY_APP_DISABLE_WEBPACKER"].present?
end

Instance Attribute Details

#after_authenticate_jobObject

Returns the value of attribute after_authenticate_job.



19
20
21
# File 'lib/shopify_app/configuration.rb', line 19

def after_authenticate_job
  @after_authenticate_job
end

#api_keyObject

Returns the value of attribute api_key.



9
10
11
# File 'lib/shopify_app/configuration.rb', line 9

def api_key
  @api_key
end

#api_versionObject

Returns the value of attribute api_version.



20
21
22
# File 'lib/shopify_app/configuration.rb', line 20

def api_version
  @api_version
end

#application_nameObject

Shopify App settings. These values should match the configuration for the app in your Shopify Partners page. Change your settings in ‘config/initializers/shopify_app.rb`



8
9
10
# File 'lib/shopify_app/configuration.rb', line 8

def application_name
  @application_name
end

#billingObject

takes a ShopifyApp::BillingConfiguration object



45
46
47
# File 'lib/shopify_app/configuration.rb', line 45

def billing
  @billing
end

#disable_webpackerObject

ability to have webpacker installed but not used in this gem and the generators



39
40
41
# File 'lib/shopify_app/configuration.rb', line 39

def disable_webpacker
  @disable_webpacker
end

#embedded_appObject Also known as: embedded_app?

Returns the value of attribute embedded_app.



15
16
17
# File 'lib/shopify_app/configuration.rb', line 15

def embedded_app
  @embedded_app
end

#embedded_redirect_urlObject

Returns the value of attribute embedded_redirect_url.



29
30
31
# File 'lib/shopify_app/configuration.rb', line 29

def embedded_redirect_url
  @embedded_redirect_url
end

#log_levelObject

Returns the value of attribute log_level.



23
24
25
# File 'lib/shopify_app/configuration.rb', line 23

def log_level
  @log_level
end

#login_callback_urlObject



59
60
61
62
# File 'lib/shopify_app/configuration.rb', line 59

def 
  # Not including @root_url to keep historic behaviour
  @login_callback_url || File.join("auth/shopify/callback")
end

#login_urlObject



55
56
57
# File 'lib/shopify_app/configuration.rb', line 55

def 
  @login_url || File.join(@root_url, "login")
end

#myshopify_domainObject

configure myshopify domain for local shopify development



36
37
38
# File 'lib/shopify_app/configuration.rb', line 36

def myshopify_domain
  @myshopify_domain
end

#old_secretObject

Returns the value of attribute old_secret.



11
12
13
# File 'lib/shopify_app/configuration.rb', line 11

def old_secret
  @old_secret
end

#reauth_on_access_scope_changesObject

Returns the value of attribute reauth_on_access_scope_changes.



22
23
24
# File 'lib/shopify_app/configuration.rb', line 22

def reauth_on_access_scope_changes
  @reauth_on_access_scope_changes
end

#root_urlObject

customise urls



26
27
28
# File 'lib/shopify_app/configuration.rb', line 26

def root_url
  @root_url
end

#scopeObject

Returns the value of attribute scope.



12
13
14
# File 'lib/shopify_app/configuration.rb', line 12

def scope
  @scope
end

#scripttagsObject

Returns the value of attribute scripttags.



18
19
20
# File 'lib/shopify_app/configuration.rb', line 18

def scripttags
  @scripttags
end

#scripttags_manager_queue_nameObject

customise ActiveJob queue names



32
33
34
# File 'lib/shopify_app/configuration.rb', line 32

def scripttags_manager_queue_name
  @scripttags_manager_queue_name
end

#secretObject

Returns the value of attribute secret.



10
11
12
# File 'lib/shopify_app/configuration.rb', line 10

def secret
  @secret
end

#shop_access_scopesObject



114
115
116
# File 'lib/shopify_app/configuration.rb', line 114

def shop_access_scopes
  @shop_access_scopes || scope
end

#user_access_scopesObject



118
119
120
# File 'lib/shopify_app/configuration.rb', line 118

def user_access_scopes
  @user_access_scopes || scope
end

#webhook_jobs_namespaceObject

allow namespacing webhook jobs



42
43
44
# File 'lib/shopify_app/configuration.rb', line 42

def webhook_jobs_namespace
  @webhook_jobs_namespace
end

#webhooksObject

Returns the value of attribute webhooks.



17
18
19
# File 'lib/shopify_app/configuration.rb', line 17

def webhooks
  @webhooks
end

#webhooks_manager_queue_nameObject

Returns the value of attribute webhooks_manager_queue_name.



33
34
35
# File 'lib/shopify_app/configuration.rb', line 33

def webhooks_manager_queue_name
  @webhooks_manager_queue_name
end

Instance Method Details

#has_scripttags?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/shopify_app/configuration.rb', line 106

def has_scripttags?
  scripttags.present?
end

#has_webhooks?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/shopify_app/configuration.rb', line 102

def has_webhooks?
  webhooks.present?
end

#requires_billing?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/shopify_app/configuration.rb', line 110

def requires_billing?
  billing.present?
end

#shop_access_scopes_strategyObject



80
81
82
83
84
# File 'lib/shopify_app/configuration.rb', line 80

def shop_access_scopes_strategy
  return ShopifyApp::AccessScopes::NoopStrategy unless reauth_on_access_scope_changes

  ShopifyApp::AccessScopes::ShopStrategy
end

#shop_session_repositoryObject



76
77
78
# File 'lib/shopify_app/configuration.rb', line 76

def shop_session_repository
  ShopifyApp::SessionRepository.shop_storage
end

#shop_session_repository=(klass) ⇒ Object



72
73
74
# File 'lib/shopify_app/configuration.rb', line 72

def shop_session_repository=(klass)
  ShopifyApp::SessionRepository.shop_storage = klass
end

#user_access_scopes_strategyObject



94
95
96
97
98
99
100
# File 'lib/shopify_app/configuration.rb', line 94

def user_access_scopes_strategy
  return @user_access_scopes_strategy if @user_access_scopes_strategy

  return ShopifyApp::AccessScopes::NoopStrategy unless reauth_on_access_scope_changes

  ShopifyApp::AccessScopes::UserStrategy
end

#user_access_scopes_strategy=(class_name) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/shopify_app/configuration.rb', line 86

def user_access_scopes_strategy=(class_name)
  unless class_name.is_a?(String)
    raise ConfigurationError, "Invalid user access scopes strategy - expected a string"
  end

  @user_access_scopes_strategy = class_name.safe_constantize
end

#user_session_repositoryObject



68
69
70
# File 'lib/shopify_app/configuration.rb', line 68

def user_session_repository
  ShopifyApp::SessionRepository.user_storage
end

#user_session_repository=(klass) ⇒ Object



64
65
66
# File 'lib/shopify_app/configuration.rb', line 64

def user_session_repository=(klass)
  ShopifyApp::SessionRepository.user_storage = klass
end