workarea-emarsys 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +7 -8
  3. data/CHANGELOG.md +6 -9
  4. data/Gemfile +1 -3
  5. data/README.md +4 -3
  6. data/app/controllers/workarea/storefront/email_signups_controller.decorator +1 -0
  7. data/app/services/{workarea/emarsys → emarsys}/contact/order.rb +0 -0
  8. data/app/services/{workarea/emarsys → emarsys}/contact/user.rb +0 -0
  9. data/app/services/{workarea/emarsys → emarsys}/contact.rb +0 -0
  10. data/app/views/workarea/storefront/_emarsys_tracking.html.haml +2 -2
  11. data/app/workers/workarea/emarsys/{save_order_contact.rb → save_order.rb} +1 -4
  12. data/app/workers/workarea/emarsys/save_user.rb +1 -5
  13. data/config/initializers/appends.rb +0 -5
  14. data/config/initializers/fields.rb +21 -0
  15. data/config/initializers/workarea.rb +0 -4
  16. data/config/routes.rb +1 -6
  17. data/lib/workarea/emarsys/version.rb +1 -1
  18. data/lib/workarea/emarsys.rb +7 -5
  19. data/test/services/{workarea/emarsys → emarsys}/contact_test.rb +0 -0
  20. data/test/system/workarea/storefront/emarsys_tracking_system_test.rb +2 -3
  21. data/test/workers/workarea/emarsys/save_user_test.rb +2 -2
  22. data/test/workers/workarea/emarsys/sync_orders_test.rb +12 -18
  23. data/workarea-emarsys.gemspec +1 -1
  24. metadata +10 -21
  25. data/app/controllers/workarea/admin/emarsys/configurations_controller.rb +0 -33
  26. data/app/models/emarsys/configuration.rb +0 -16
  27. data/app/view_models/workarea/admin/emarsys_configuration_view_model.rb +0 -19
  28. data/app/views/workarea/admin/emarsys/configurations/edit.html.haml +0 -68
  29. data/app/views/workarea/admin/shared/_emarsys_configuration_link.html.haml +0 -1
  30. data/test/integration/workarea/admin/emarsys_configuration_integration_test.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9869878b31972e6d9b7b55576055fab4c5d0988bb0c51d10126835d5cdee59b
4
- data.tar.gz: 61ac2858b906871dc5f530f8020b6bfce5741bc651c63f42a8800bf3d599f0c1
3
+ metadata.gz: 94cf477df712c5d3c8a1b2151f48ef900faea02c58cb7f3fda832a5199d3b21b
4
+ data.tar.gz: f450274e16cbf9d7f3f1bc629b0eb9743537bb87b29b5d2bb7e0f20a862b24e5
5
5
  SHA512:
6
- metadata.gz: 36fd3a01e9f16ec08f88a989e6f15b7f4c41204eb30a01c4a804d357dbb0628a5d31a3af1e729c630824154a3418a178edeb0650f96714a7740ed5fd6f938c18
7
- data.tar.gz: d91e5080adb8563885e8601533acbfecd95acbf003e400e92269259690a32522565523d8ecb0dbfffce8dbc26d02883c2c2b07c15bf3c2baaa9405cdff843f95
6
+ metadata.gz: f40bf6d8f666c3c478cace1a8e8e8d440bfc5bcb3189e44707954762140869731e0e4dff938949fefa520195909f5c8c560cb6d3aad5b8a739c6663bedc3d544
7
+ data.tar.gz: 7057465c102e2ad513dd8124fefaaa854d5021f317a21ecbffd41cf52051c74119219e5a0bc6290b60da094811e4c8bda5ddc313cd47935f9524a4150cea30a6
@@ -1,14 +1,13 @@
1
1
  name: CI
2
2
  on: [push]
3
- env:
4
- BUNDLE_GEMS__WEBLINC__COM: ${{ secrets.BUNDLE_GEMS__WEBLINC__COM }}
3
+
5
4
  jobs:
6
5
  static_analysis:
7
6
  runs-on: ubuntu-latest
8
7
  steps:
9
8
  - uses: actions/checkout@v1
10
- - uses: workarea-commerce/ci/bundler-audit@ruby-2.4
11
- - uses: workarea-commerce/ci/rubocop@ruby-2.4
9
+ - uses: workarea-commerce/ci/bundler-audit@v1
10
+ - uses: workarea-commerce/ci/rubocop@v1
12
11
  - uses: workarea-commerce/ci/eslint@v1
13
12
  with:
14
13
  args: '**/*.js'
@@ -19,7 +18,7 @@ jobs:
19
18
  - uses: actions/checkout@v1
20
19
  - uses: actions/setup-ruby@v1
21
20
  with:
22
- ruby-version: 2.4.x
21
+ ruby-version: 2.6.x
23
22
  - uses: workarea-commerce/ci/test@v1
24
23
  with:
25
24
  command: bin/rails app:workarea:test:admin
@@ -30,7 +29,7 @@ jobs:
30
29
  - uses: actions/checkout@v1
31
30
  - uses: actions/setup-ruby@v1
32
31
  with:
33
- ruby-version: 2.4.x
32
+ ruby-version: 2.6.x
34
33
  - uses: workarea-commerce/ci/test@v1
35
34
  with:
36
35
  command: bin/rails app:workarea:test:core
@@ -41,7 +40,7 @@ jobs:
41
40
  - uses: actions/checkout@v1
42
41
  - uses: actions/setup-ruby@v1
43
42
  with:
44
- ruby-version: 2.4.x
43
+ ruby-version: 2.6.x
45
44
  - uses: workarea-commerce/ci/test@v1
46
45
  with:
47
46
  command: bin/rails app:workarea:test:storefront
@@ -52,7 +51,7 @@ jobs:
52
51
  - uses: actions/checkout@v1
53
52
  - uses: actions/setup-ruby@v1
54
53
  with:
55
- ruby-version: 2.4.x
54
+ ruby-version: 2.6.x
56
55
  - uses: workarea-commerce/ci/test@v1
57
56
  with:
58
57
  command: bin/rails app:workarea:test:plugins
data/CHANGELOG.md CHANGED
@@ -1,16 +1,13 @@
1
- Workarea Emarsys 1.0.4 (2020-02-04)
1
+ Workarea Emarsys 1.1.0 (2019-11-26)
2
2
  --------------------------------------------------------------------------------
3
3
 
4
- * Fix Class Paths
4
+ * Updates for v3.5 compatibility.
5
5
 
6
- Some paths in `app/` did not match their constant names, resulting in
7
- issues when trying to decorate these classes. Move the offending files
8
- to their correct location so as to enable decorating them.
6
+ Removes the custom build configuration panel in favor
7
+ of the out-of-box admin settings available in 3.5.
9
8
 
10
- Fixes #10
11
-
12
- EMARSYS-3
13
- Tom Scott
9
+ EMARSYS-1
10
+ Jeff Yucis
14
11
 
15
12
 
16
13
 
data/Gemfile CHANGED
@@ -3,9 +3,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
4
  gemspec
5
5
 
6
- source 'https://gems.weblinc.com' do
7
- gem 'workarea'
8
- end
6
+ gem 'workarea', github: 'workarea-commerce/workarea'
9
7
 
10
8
  group :test do
11
9
  gem 'simplecov', require: false
data/README.md CHANGED
@@ -10,6 +10,9 @@ This integration supports the following:
10
10
  3. Order syncronization
11
11
  4. Full Web-Extend Analytics integration
12
12
 
13
+ The Workarea Emarsys integration is a Emarsys Add-on. Contact your Emarsys support person to
14
+ have the Workarea Emarsys integration enabled for your account.
15
+
13
16
  Getting Started
14
17
  --------------------------------------------------------------------------------
15
18
 
@@ -30,9 +33,7 @@ bundle
30
33
 
31
34
  Configuration
32
35
  --------------------------------------------------------------------------------
33
- An administration panel in the Worakrea Admin has been provided to set some configuration values. Users must have permissions to **settings** to access this feature.
34
-
35
- The follow is accessible via the configuration panel:
36
+ The following fields can be edited via the admin site settings:
36
37
 
37
38
  1. **Production:** A toggle switch to set the integration into production mode, defaults to false.
38
39
  2. **Customer ID:** The customer ID of account. Ask your Emarsys account manager for this value.
@@ -4,6 +4,7 @@ module Workarea
4
4
  signup = Email.signup(params[:email])
5
5
 
6
6
  if signup.try(:valid?)
7
+ update_tracking!(email: signup.email)
7
8
  cookies[:emarsys_email] = params[:email]
8
9
  flash[:success] = t('workarea.storefront.flash_messages.email_signed_up')
9
10
  else
@@ -1,10 +1,10 @@
1
- - if Workarea::Emarsys::Configuration.current.merchant_id.present?
1
+ - if Workarea.config.merchant_id.present?
2
2
  :javascript
3
3
  var ScarabQueue = ScarabQueue || [];
4
4
  (function(id) {
5
5
  if (document.getElementById(id)) return;
6
6
  var js = document.createElement('script'); js.id = id;
7
- js.src = '//cdn.scarabresearch.com/js/#{Workarea::Emarsys::Configuration.current.merchant_id}/scarab-v2.js';
7
+ js.src = '//cdn.scarabresearch.com/js/#{Workarea.config.merchant_id}/scarab-v2.js';
8
8
  var fs = document.getElementsByTagName('script')[0];
9
9
  fs.parentNode.insertBefore(js, fs);
10
10
  })('scarab-js-api');
@@ -10,7 +10,7 @@ module Workarea
10
10
  )
11
11
 
12
12
  def perform(id)
13
- return unless settings.customer_id.present?
13
+ return unless Emarsys.customer_id.present?
14
14
 
15
15
  order = Workarea::Order.find(id)
16
16
  address = Workarea::Payment.find(order.id).address
@@ -20,9 +20,6 @@ module Workarea
20
20
  end
21
21
 
22
22
  private
23
- def settings
24
- Workarea::Emarsys::Configuration.current
25
- end
26
23
 
27
24
  def gateway
28
25
  Emarsys.gateway
@@ -10,7 +10,7 @@ module Workarea
10
10
  )
11
11
 
12
12
  def perform(id)
13
- return unless settings.customer_id.present?
13
+ return unless Emarsys.customer_id.present?
14
14
 
15
15
  user = Workarea::User.find(id)
16
16
 
@@ -29,10 +29,6 @@ module Workarea
29
29
  Emarsys.gateway
30
30
  end
31
31
 
32
- def settings
33
- Workarea::Emarsys::Configuration.current
34
- end
35
-
36
32
  def address(user)
37
33
  return unless user.addresses.present?
38
34
 
@@ -8,11 +8,6 @@ Workarea.append_partials(
8
8
  'workarea/storefront/emarsys/current_user_emarsys_cart'
9
9
  )
10
10
 
11
- Workarea.append_partials(
12
- "admin.settings_menu",
13
- "workarea/admin/shared/emarsys_configuration_link"
14
- )
15
-
16
11
  Workarea.append_javascripts(
17
12
  'storefront.modules',
18
13
  'workarea/storefront/emarsys/modules/web_extend_adapter'
@@ -0,0 +1,21 @@
1
+ Workarea::Configuration.define_fields do
2
+ fieldset 'Emarsys', namespaced: false do
3
+ field 'Customer ID',
4
+ type: :string,
5
+ default: '',
6
+ description: 'Emarsys customer ID. Required for using API endpoints. Contact your Emarays Support team to get this value.',
7
+ allow_blank: true
8
+
9
+ field 'Merchant ID',
10
+ type: :string,
11
+ default: '',
12
+ description: 'Your Emarsys merchant ID. This value is required for the Web Extend data integration.',
13
+ allow_blank: true
14
+
15
+ field 'Emarsys Production API',
16
+ id: :emarsys_production,
17
+ type: :boolean,
18
+ default: false,
19
+ description: 'Whether to use the production API endpoints.'
20
+ end
21
+ end
@@ -7,10 +7,6 @@ Workarea.configure do |config|
7
7
 
8
8
  config.emarsys.export_interval = 1.day
9
9
 
10
- # Merchant ID used for web extend JS
11
- # this is required for the web extend javascript
12
- config.emarsys.merchant_id = nil
13
-
14
10
  config.emarsys.api_timeout = 3
15
11
  config.emarsys.open_timeout = 3
16
12
  end
data/config/routes.rb CHANGED
@@ -1,7 +1,2 @@
1
- Workarea::Admin::Engine.routes.draw do
2
- scope '(:locale)', constraints: Workarea::I18n.routes_constraint do
3
- namespace :emarsys do
4
- resource :configuration, only: [:edit, :update]
5
- end
6
- end
1
+ Rails.application.routes.draw do
7
2
  end
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module Emarsys
3
- VERSION = "1.0.4"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -27,7 +27,11 @@ module Workarea
27
27
  end
28
28
 
29
29
  def self.customer_id
30
- credentials[:customer_id]
30
+ Workarea.config.customer_id
31
+ end
32
+
33
+ def self.merchant_id
34
+ Workarea.config.merchant_id
31
35
  end
32
36
 
33
37
  def self.config
@@ -40,8 +44,7 @@ module Workarea
40
44
  # @return [Emarsys::Gateway]
41
45
  def self.gateway
42
46
  if credentials.present?
43
- settings = Workarea::Emarsys::Configuration.current
44
- Emarsys::Gateway.new(secret_key, settings.customer_id, { test: !settings.production? })
47
+ Emarsys::Gateway.new(secret_key, Emarsys.customer_id, { test: !Workarea.config.emarsys_production_api })
45
48
  else
46
49
  Emarsys::BogusGateway.new
47
50
  end
@@ -49,8 +52,7 @@ module Workarea
49
52
 
50
53
  def self.sales_data_gateway
51
54
  if credentials.present?
52
- settings = Workarea::Emarsys::Configuration.current
53
- Emarsys::SalesDataGateway.new(api_token, { merchant_id: settings.merchant_id })
55
+ Emarsys::SalesDataGateway.new(api_token, { merchant_id: Emarsys.merchant_id })
54
56
  else
55
57
  Emarsys::SalesDataBogusGateway.new
56
58
  end
@@ -4,15 +4,14 @@ module Workarea
4
4
  module Storefront
5
5
  class EmarsysTrackingSystemTest < Workarea::SystemTest
6
6
  def test_emarsys_tracking_js
7
- settings = Workarea::Emarsys::Configuration.create!(merchant_id: 'abcdefg')
7
+ Workarea.config.merchant_id = 'abcdefg'
8
8
  visit storefront.root_path
9
9
 
10
10
  emarsys_script = find('script', text: 'abcdefg', visible: false)
11
11
 
12
12
  assert(emarsys_script.present?)
13
13
 
14
- settings.merchant_id = nil
15
- settings.save!
14
+ Workarea.config.merchant_id = nil
16
15
 
17
16
  visit storefront.root_path
18
17
  emarsys_script = find('script', text: 'abcdefg', visible: false) rescue nil
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Workarea
4
4
  class Emarsys::SaveUserTest < TestCase
5
5
  def test_save_user_sets_time_stamp
6
- Workarea::Emarsys::Configuration.create(customer_id: '1234')
6
+ Workarea.config.customer_id = '1234'
7
7
  user = create_user
8
8
 
9
9
  Workarea::Emarsys::SaveUser.new.perform(user.id)
@@ -15,7 +15,7 @@ module Workarea
15
15
  end
16
16
 
17
17
  def test_save_user_does_nothing_without_customer_id_set
18
- Workarea::Emarsys::Configuration.create(customer_id: nil)
18
+ Workarea.config.customer_id = nil
19
19
  user = create_user
20
20
 
21
21
  Workarea::Emarsys::SaveUser.new.perform(user.id)
@@ -5,34 +5,28 @@ module Workarea
5
5
  include EmarsysApiConfig
6
6
 
7
7
  def test_sync_orders_sends_file
8
- VCR.use_cassette("emarsys/sales/send_data", match_requests_on: [:method, :uri]) do
9
- Workarea.with_config do |config|
10
- merchant_id = Workarea::Emarsys::Configuration.create!(merchant_id: "19CAA097101B372A").merchant_id
11
-
12
- api_url = "https://admin.scarabresearch.com/hapi/merchant/#{merchant_id}/sales-data/api"
8
+ merchant_id = "19CAA097101B372A"
9
+ Workarea.config.merchant_id = merchant_id
13
10
 
14
- config.emarsys.merchant_id = merchant_id
11
+ VCR.use_cassette("emarsys/sales/send_data", match_requests_on: [:method, :uri]) do
12
+ api_url = "https://admin.scarabresearch.com/hapi/merchant/#{merchant_id}/sales-data/api"
15
13
 
16
- create_placed_order
14
+ create_placed_order
17
15
 
18
- Workarea::Emarsys::SyncOrders.new.perform
16
+ Workarea::Emarsys::SyncOrders.new.perform
19
17
 
20
- assert_requested :post, api_url
21
- end
18
+ assert_requested :post, api_url
22
19
  end
23
20
  end
24
21
 
25
22
  def test_sync_orders_sends_nothing_when_no_orders
26
- Workarea.with_config do |config|
27
- merchant_id = Workarea::Emarsys::Configuration.create!(merchant_id: "19CAA097101B372A").merchant_id
28
- api_url = "https://admin.scarabresearch.com/hapi/merchant/#{merchant_id}/sales-data/api"
29
-
30
- config.emarsys.merchant_id = merchant_id
23
+ merchant_id = "19CAA097101B372A"
24
+ Workarea.config.merchant_id = merchant_id
31
25
 
32
- Workarea::Emarsys::SyncOrders.new.perform
26
+ api_url = "https://admin.scarabresearch.com/hapi/merchant/#{merchant_id}/sales-data/api"
27
+ Workarea::Emarsys::SyncOrders.new.perform
33
28
 
34
- refute_requested :post, api_url
35
- end
29
+ refute_requested :post, api_url
36
30
  end
37
31
  end
38
32
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.license = 'Business Software License'
19
19
 
20
- s.add_dependency 'workarea', '>= 3.3.0', '< 3.5'
20
+ s.add_dependency 'workarea', '>= 3.5.x'
21
21
  s.add_dependency 'workarea-google_product_feed', '~> 3.x'
22
22
  s.add_dependency "escher"
23
23
  s.add_dependency "faraday", "~> 0.10"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-emarsys
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Yucis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-04 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.3.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '3.5'
19
+ version: 3.5.x
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 3.3.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '3.5'
26
+ version: 3.5.x
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: workarea-google_product_feed
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,7 +94,6 @@ files:
100
94
  - app/assets/javascripts/workarea/storefront/emarsys/modules/web_extend_adapter.js
101
95
  - app/assets/stylesheets/emarsys/.keep
102
96
  - app/controllers/.keep
103
- - app/controllers/workarea/admin/emarsys/configurations_controller.rb
104
97
  - app/controllers/workarea/storefront/email_signups_controller.decorator
105
98
  - app/controllers/workarea/storefront/users/addresses_controller.decorator
106
99
  - app/helpers/.keep
@@ -110,25 +103,22 @@ files:
110
103
  - app/lib/workarea/emarsys/response.rb
111
104
  - app/lib/workarea/emarsys/sales_data_bogus_gateway.rb
112
105
  - app/lib/workarea/emarsys/sales_data_gateway.rb
113
- - app/models/emarsys/configuration.rb
114
106
  - app/models/emarsys/country.rb
115
107
  - app/models/workarea/email/signup.decorator
116
108
  - app/models/workarea/order.decorator
117
109
  - app/models/workarea/user.decorator
118
- - app/services/workarea/emarsys/contact.rb
119
- - app/services/workarea/emarsys/contact/order.rb
120
- - app/services/workarea/emarsys/contact/user.rb
121
- - app/view_models/workarea/admin/emarsys_configuration_view_model.rb
122
- - app/views/workarea/admin/emarsys/configurations/edit.html.haml
123
- - app/views/workarea/admin/shared/_emarsys_configuration_link.html.haml
110
+ - app/services/emarsys/contact.rb
111
+ - app/services/emarsys/contact/order.rb
112
+ - app/services/emarsys/contact/user.rb
124
113
  - app/views/workarea/storefront/_emarsys_tracking.html.haml
125
114
  - app/views/workarea/storefront/emarsys/_current_user_emarsys_cart.json.jbuilder
126
115
  - app/workers/workarea/emarsys/save_email_signup.rb
127
- - app/workers/workarea/emarsys/save_order_contact.rb
116
+ - app/workers/workarea/emarsys/save_order.rb
128
117
  - app/workers/workarea/emarsys/save_user.rb
129
118
  - app/workers/workarea/emarsys/sync_orders.rb
130
119
  - bin/rails
131
120
  - config/initializers/appends.rb
121
+ - config/initializers/fields.rb
132
122
  - config/initializers/scheduled_jobs.rb
133
123
  - config/initializers/workarea.rb
134
124
  - config/locales/en.yml
@@ -181,9 +171,8 @@ files:
181
171
  - test/dummy/db/seeds.rb
182
172
  - test/dummy/lib/assets/.keep
183
173
  - test/dummy/log/.keep
184
- - test/integration/workarea/admin/emarsys_configuration_integration_test.rb
185
174
  - test/lib/workarea/emarsys/gateway_test.rb
186
- - test/services/workarea/emarsys/contact_test.rb
175
+ - test/services/emarsys/contact_test.rb
187
176
  - test/support/workarea/emarsys_api_config.rb
188
177
  - test/system/workarea/storefront/emarsys_tracking_system_test.rb
189
178
  - test/teaspoon_env.rb
@@ -1,33 +0,0 @@
1
- module Workarea
2
- module Admin
3
- module Emarsys
4
- class ConfigurationsController < Admin::ApplicationController
5
- required_permissions :settings
6
-
7
- def edit
8
- @configuration = configuration
9
- end
10
-
11
- def update
12
- if configuration.update_attributes(configuration_params)
13
- redirect_to admin.edit_emarsys_configuration_path, flash: { success: t('workarea.admin.emarsys_configuration.edit.flash_messages.updated') }
14
- else
15
- flash[:error] = t('workarea.admin.emarsys_configuration.edit.flash_messages.save_error')
16
- @configuration = configuration
17
- render :edit, status: :unprocessable_entity
18
- end
19
- end
20
-
21
- private
22
- def configuration
23
- model = Workarea::Emarsys::Configuration.current
24
- Workarea::Admin::EmarsysConfigurationViewModel.new(model)
25
- end
26
-
27
- def configuration_params
28
- params.permit(:production, :merchant_id, :customer_id)
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,16 +0,0 @@
1
- module Workarea
2
- module Emarsys
3
- class Configuration
4
- include ApplicationDocument
5
-
6
- field :merchant_id, type: String
7
- field :customer_id, type: String
8
-
9
- field :production, type: Boolean, default: false
10
-
11
- def self.current
12
- first || new
13
- end
14
- end
15
- end
16
- end
@@ -1,19 +0,0 @@
1
- module Workarea
2
- module Admin
3
- class EmarsysConfigurationViewModel < ApplicationViewModel
4
- def masked_api_key
5
- return unless Workarea::Emarsys.secret_key.present?
6
- key = Workarea::Emarsys.secret_key
7
- last_digits = key.to_s.slice(-4..-1)
8
- "XXXXXXXXXX#{last_digits}"
9
- end
10
-
11
- def masked_sales_api_key
12
- return unless Workarea::Emarsys.api_token.present?
13
- key = Workarea::Emarsys.api_token
14
- last_digits = key.to_s.slice(-4..-1)
15
- "XXXXXXXXXX#{last_digits}"
16
- end
17
- end
18
- end
19
- end
@@ -1,68 +0,0 @@
1
- - @page_title = t('workarea.admin.emarsys_configuration.edit.title')
2
-
3
- .view
4
- .view__header
5
- .view__heading
6
- = link_to "↑ #{t('workarea.admin.search_settings.show.dashboard_link')}", settings_dashboards_path
7
- %h1= t('workarea.admin.emarsys_configuration.edit.title')
8
-
9
- .view__container
10
- = form_tag emarsys_configuration_path, method: :patch, data: { unsaved_changes: '' } do
11
-
12
- .grid__cell.grid__cell--50-at-medium
13
-
14
- .property
15
- %span.property__name
16
- = t('workarea.admin.emarsys_configuration.edit.api_key')
17
- = link_to '#api-key', data: { tooltip: '' } do
18
- = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.emarsys_configuration.edit.api_key'))
19
- #api-key.tooltip-content
20
- %p= t('workarea.admin.emarsys_configuration.edit.help.api_key')
21
-
22
- - if @configuration.masked_api_key.present?
23
- %p= @configuration.masked_api_key
24
- - else
25
- %p= t('workarea.admin.emarsys_configuration.edit.no_key')
26
-
27
- %span.property__name
28
- = t('workarea.admin.emarsys_configuration.edit.sales_api_key')
29
- = link_to '#sales-api-key', data: { tooltip: '' } do
30
- = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.emarsys_configuration.edit.sales_api_key'))
31
- #sales-api-key.tooltip-content
32
- %p= t('workarea.admin.emarsys_configuration.edit.help.sales_api_key')
33
-
34
- - if @configuration.masked_sales_api_key.present?
35
- %p= @configuration.masked_sales_api_key
36
- - else
37
- %p= t('workarea.admin.emarsys_configuration.edit.no_key')
38
-
39
- %span.property__name
40
- = t('workarea.admin.emarsys_configuration.edit.production')
41
- = link_to '#enabled', data: { tooltip: '' } do
42
- = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.emarsys_configuration.edit.production'))
43
- #enabled.tooltip-content
44
- %p= t('workarea.admin.emarsys_configuration.edit.help.production')
45
-
46
- = toggle_button_for 'production', @configuration.production?
47
-
48
- %span.property__name
49
- = t('workarea.admin.emarsys_configuration.edit.customer_id')
50
- = link_to '#show-on-pdp', data: { tooltip: '' } do
51
- = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.emarsys_configuration.edit.customer_id'))
52
- #show-on-pdp.tooltip-content
53
- %p= t('workarea.admin.emarsys_configuration.edit.help.customer_id')
54
-
55
- = text_field_tag 'customer_id', @configuration.customer_id, class: 'text-box', id: "customer_id"
56
-
57
- %span.property__name
58
- = t('workarea.admin.emarsys_configuration.edit.merchant_id')
59
- = link_to '#show-on-cart', data: { tooltip: '' } do
60
- = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.emarsys_configuration.edit.merchant_id'))
61
- #show-on-cart.tooltip-content
62
- %p= t('workarea.admin.emarsys_configuration.edit.help.merchant_id')
63
-
64
- = text_field_tag 'merchant_id', @configuration.merchant_id, class: 'text-box', id: "merchant_id"
65
-
66
- .workflow-bar
67
- .grid.grid--auto.grid--right.grid--middle
68
- .grid__cell= button_tag t('workarea.admin.emarsys_configuration.edit.button'), value: 'save_settings', class: 'workflow-bar__button workflow-bar__button--update'
@@ -1 +0,0 @@
1
- %li{ class: "primary-nav__item" }= link_to t('workarea.admin.shared.primary_nav.emarsys_configuration_title'), edit_emarsys_configuration_path, class: navigation_link_classes(edit_emarsys_configuration_path)
@@ -1,25 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Workarea
4
- module Admin
5
- class EmarsysConfigurationIntegrationTest < Workarea::IntegrationTest
6
- include Admin::IntegrationTest
7
-
8
- def test_create_configuration
9
- patch admin.emarsys_configuration_path,
10
- params: {
11
- customer_id: '12345',
12
- merchant_id: 'ABCDEFG',
13
- production: true
14
- }
15
-
16
- assert_equal(1, Workarea::Emarsys::Configuration.count)
17
-
18
- result = Workarea::Emarsys::Configuration.current
19
- assert_equal('12345', result.customer_id)
20
- assert_equal('ABCDEFG', result.merchant_id)
21
- assert(result.production?)
22
- end
23
- end
24
- end
25
- end