Class: ShopifyApp::Configuration
- Inherits:
-
Object
- Object
- ShopifyApp::Configuration
- Defined in:
- lib/shopify_app/configuration.rb
Instance Attribute Summary collapse
-
#after_authenticate_job ⇒ Object
Returns the value of attribute after_authenticate_job.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#application_name ⇒ Object
Shopify App settings.
-
#billing ⇒ Object
takes a ShopifyApp::BillingConfiguration object.
-
#check_session_expiry_date ⇒ Object
Returns the value of attribute check_session_expiry_date.
-
#custom_post_authenticate_tasks ⇒ Object
customize post authenticate tasks.
-
#disable_webpacker ⇒ Object
ability to have webpacker installed but not used in this gem and the generators.
-
#embedded_app ⇒ Object
(also: #embedded_app?)
Returns the value of attribute embedded_app.
-
#embedded_redirect_url ⇒ Object
Returns the value of attribute embedded_redirect_url.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
- #login_callback_url ⇒ Object
- #login_url ⇒ Object
-
#myshopify_domain ⇒ Object
configure myshopify domain for local shopify development.
-
#new_embedded_auth_strategy ⇒ Object
Enables new authorization flow using token exchange.
-
#old_secret ⇒ Object
Returns the value of attribute old_secret.
-
#reauth_on_access_scope_changes ⇒ Object
Returns the value of attribute reauth_on_access_scope_changes.
-
#root_url ⇒ Object
customise urls.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#script_tags ⇒ Object
Returns the value of attribute script_tags.
-
#script_tags_manager_queue_name ⇒ Object
customise ActiveJob queue names.
-
#secret ⇒ Object
Returns the value of attribute secret.
- #shop_access_scopes ⇒ Object
-
#unified_admin_domain ⇒ Object
configure the unified admin domain for local shopify development.
- #user_access_scopes ⇒ Object
-
#webhook_jobs_namespace ⇒ Object
allow namespacing webhook jobs.
-
#webhooks ⇒ Object
Returns the value of attribute webhooks.
-
#webhooks_manager_queue_name ⇒ Object
Returns the value of attribute webhooks_manager_queue_name.
Instance Method Summary collapse
- #has_script_tags? ⇒ Boolean
- #has_webhooks? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #online_token_configured? ⇒ Boolean
- #post_authenticate_tasks ⇒ Object
- #requires_billing? ⇒ Boolean
- #shop_access_scopes_strategy ⇒ Object
- #shop_session_repository ⇒ Object
- #shop_session_repository=(klass) ⇒ Object
- #use_new_embedded_auth_strategy? ⇒ Boolean
- #user_access_scopes_strategy ⇒ Object
- #user_access_scopes_strategy=(class_name) ⇒ Object
- #user_session_repository ⇒ Object
- #user_session_repository=(klass) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
57 58 59 60 61 62 63 64 65 |
# File 'lib/shopify_app/configuration.rb', line 57 def initialize @root_url = "/" @myshopify_domain = "myshopify.com" @unified_admin_domain = "shopify.com" = 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? @scope = [] end |
Instance Attribute Details
#after_authenticate_job ⇒ Object
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_key ⇒ Object
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_version ⇒ Object
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_name ⇒ Object
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 |
#billing ⇒ Object
takes a ShopifyApp::BillingConfiguration object
52 53 54 |
# File 'lib/shopify_app/configuration.rb', line 52 def billing @billing end |
#check_session_expiry_date ⇒ Object
Returns the value of attribute check_session_expiry_date.
23 24 25 |
# File 'lib/shopify_app/configuration.rb', line 23 def check_session_expiry_date @check_session_expiry_date end |
#custom_post_authenticate_tasks ⇒ Object
customize post authenticate tasks
33 34 35 |
# File 'lib/shopify_app/configuration.rb', line 33 def custom_post_authenticate_tasks @custom_post_authenticate_tasks end |
#disable_webpacker ⇒ Object
ability to have webpacker installed but not used in this gem and the generators
46 47 48 |
# File 'lib/shopify_app/configuration.rb', line 46 def disable_webpacker @disable_webpacker end |
#embedded_app ⇒ Object Also known as: embedded_app?
Returns the value of attribute embedded_app.
15 16 17 |
# File 'lib/shopify_app/configuration.rb', line 15 def end |
#embedded_redirect_url ⇒ Object
Returns the value of attribute embedded_redirect_url.
30 31 32 |
# File 'lib/shopify_app/configuration.rb', line 30 def end |
#log_level ⇒ Object
Returns the value of attribute log_level.
24 25 26 |
# File 'lib/shopify_app/configuration.rb', line 24 def log_level @log_level end |
#login_callback_url ⇒ Object
71 72 73 74 |
# File 'lib/shopify_app/configuration.rb', line 71 def login_callback_url # Not including @root_url to keep historic behaviour @login_callback_url || File.join("auth/shopify/callback") end |
#login_url ⇒ Object
67 68 69 |
# File 'lib/shopify_app/configuration.rb', line 67 def login_url @login_url || File.join(@root_url, "login") end |
#myshopify_domain ⇒ Object
configure myshopify domain for local shopify development
40 41 42 |
# File 'lib/shopify_app/configuration.rb', line 40 def myshopify_domain @myshopify_domain end |
#new_embedded_auth_strategy ⇒ Object
Enables new authorization flow using token exchange
55 56 57 |
# File 'lib/shopify_app/configuration.rb', line 55 def end |
#old_secret ⇒ Object
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_changes ⇒ Object
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_url ⇒ Object
customise urls
27 28 29 |
# File 'lib/shopify_app/configuration.rb', line 27 def root_url @root_url end |
#scope ⇒ Object
Returns the value of attribute scope.
12 13 14 |
# File 'lib/shopify_app/configuration.rb', line 12 def scope @scope end |
#script_tags ⇒ Object
Returns the value of attribute script_tags.
18 19 20 |
# File 'lib/shopify_app/configuration.rb', line 18 def end |
#script_tags_manager_queue_name ⇒ Object
customise ActiveJob queue names
36 37 38 |
# File 'lib/shopify_app/configuration.rb', line 36 def end |
#secret ⇒ Object
Returns the value of attribute secret.
10 11 12 |
# File 'lib/shopify_app/configuration.rb', line 10 def secret @secret end |
#shop_access_scopes ⇒ Object
126 127 128 |
# File 'lib/shopify_app/configuration.rb', line 126 def shop_access_scopes @shop_access_scopes || scope end |
#unified_admin_domain ⇒ Object
configure the unified admin domain for local shopify development
43 44 45 |
# File 'lib/shopify_app/configuration.rb', line 43 def unified_admin_domain @unified_admin_domain end |
#user_access_scopes ⇒ Object
130 131 132 |
# File 'lib/shopify_app/configuration.rb', line 130 def user_access_scopes @user_access_scopes || scope end |
#webhook_jobs_namespace ⇒ Object
allow namespacing webhook jobs
49 50 51 |
# File 'lib/shopify_app/configuration.rb', line 49 def webhook_jobs_namespace @webhook_jobs_namespace end |
#webhooks ⇒ Object
Returns the value of attribute webhooks.
17 18 19 |
# File 'lib/shopify_app/configuration.rb', line 17 def webhooks @webhooks end |
#webhooks_manager_queue_name ⇒ Object
Returns the value of attribute webhooks_manager_queue_name.
37 38 39 |
# File 'lib/shopify_app/configuration.rb', line 37 def webhooks_manager_queue_name @webhooks_manager_queue_name end |
Instance Method Details
#has_script_tags? ⇒ Boolean
118 119 120 |
# File 'lib/shopify_app/configuration.rb', line 118 def .present? end |
#has_webhooks? ⇒ Boolean
114 115 116 |
# File 'lib/shopify_app/configuration.rb', line 114 def has_webhooks? webhooks.present? end |
#online_token_configured? ⇒ Boolean
138 139 140 |
# File 'lib/shopify_app/configuration.rb', line 138 def online_token_configured? !ShopifyApp.configuration.user_session_repository.blank? && ShopifyApp::SessionRepository.user_storage.present? end |
#post_authenticate_tasks ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/shopify_app/configuration.rb', line 142 def post_authenticate_tasks @post_authenticate_tasks || begin if custom_post_authenticate_tasks custom_class = if custom_post_authenticate_tasks.respond_to?(:safe_constantize) custom_post_authenticate_tasks.safe_constantize else custom_post_authenticate_tasks end end task_class = custom_class || ShopifyApp::Auth::PostAuthenticateTasks [ :perform, ].each do |method| raise( ::ShopifyApp::ConfigurationError, "Missing method - '#{method}' for custom_post_authenticate_tasks", ) unless task_class.respond_to?(method) end task_class end end |
#requires_billing? ⇒ Boolean
122 123 124 |
# File 'lib/shopify_app/configuration.rb', line 122 def requires_billing? billing.present? end |
#shop_access_scopes_strategy ⇒ Object
92 93 94 95 96 |
# File 'lib/shopify_app/configuration.rb', line 92 def shop_access_scopes_strategy return ShopifyApp::AccessScopes::NoopStrategy unless reauth_on_access_scope_changes ShopifyApp::AccessScopes::ShopStrategy end |
#shop_session_repository ⇒ Object
88 89 90 |
# File 'lib/shopify_app/configuration.rb', line 88 def shop_session_repository ShopifyApp::SessionRepository.shop_storage end |
#shop_session_repository=(klass) ⇒ Object
84 85 86 |
# File 'lib/shopify_app/configuration.rb', line 84 def shop_session_repository=(klass) ShopifyApp::SessionRepository.shop_storage = klass end |
#use_new_embedded_auth_strategy? ⇒ Boolean
134 135 136 |
# File 'lib/shopify_app/configuration.rb', line 134 def && end |
#user_access_scopes_strategy ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/shopify_app/configuration.rb', line 106 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
98 99 100 101 102 103 104 |
# File 'lib/shopify_app/configuration.rb', line 98 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_repository ⇒ Object
80 81 82 |
# File 'lib/shopify_app/configuration.rb', line 80 def user_session_repository ShopifyApp::SessionRepository.user_storage end |
#user_session_repository=(klass) ⇒ Object
76 77 78 |
# File 'lib/shopify_app/configuration.rb', line 76 def user_session_repository=(klass) ShopifyApp::SessionRepository.user_storage = klass end |