workarea-emarsys 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.gitignore +22 -0
  7. data/CHANGELOG.md +28 -0
  8. data/CODE_OF_CONDUCT.md +3 -0
  9. data/CONTRIBUTING.md +3 -0
  10. data/Gemfile +12 -0
  11. data/LICENSE +52 -0
  12. data/LICENSE.md +3 -0
  13. data/README.md +93 -0
  14. data/Rakefile +60 -0
  15. data/app/assets/images/emarsys/.keep +0 -0
  16. data/app/assets/javascripts/emarsys/.keep +0 -0
  17. data/app/assets/javascripts/workarea/storefront/emarsys/modules/web_extend_adapter.js +128 -0
  18. data/app/assets/stylesheets/emarsys/.keep +0 -0
  19. data/app/controllers/.keep +0 -0
  20. data/app/controllers/workarea/admin/configurations_controller.rb +33 -0
  21. data/app/controllers/workarea/storefront/email_signups_controller.decorator +16 -0
  22. data/app/controllers/workarea/storefront/users/addresses_controller.decorator +13 -0
  23. data/app/helpers/.keep +0 -0
  24. data/app/helpers/workarea/storefront/emarsys_analytics_helper.rb +13 -0
  25. data/app/lib/workarea/emarsys/bogus_gateway.rb +36 -0
  26. data/app/lib/workarea/emarsys/gateway.rb +94 -0
  27. data/app/lib/workarea/emarsys/response.rb +18 -0
  28. data/app/lib/workarea/emarsys/sales_data_bogus_gateway.rb +29 -0
  29. data/app/lib/workarea/emarsys/sales_data_gateway.rb +51 -0
  30. data/app/models/emarsys/configuration.rb +16 -0
  31. data/app/models/emarsys/country.rb +220 -0
  32. data/app/models/workarea/email/signup.decorator +8 -0
  33. data/app/models/workarea/order.decorator +8 -0
  34. data/app/models/workarea/user.decorator +8 -0
  35. data/app/services/emarsys/contact/order.rb +31 -0
  36. data/app/services/emarsys/contact/user.rb +25 -0
  37. data/app/services/emarsys/contact.rb +55 -0
  38. data/app/view_models/workarea/admin/emarsys_configuration_view_model.rb +20 -0
  39. data/app/views/workarea/admin/emarsys/configurations/edit.html.haml +68 -0
  40. data/app/views/workarea/admin/shared/_emarsys_configuration_link.html.haml +1 -0
  41. data/app/views/workarea/storefront/_emarsys_tracking.html.haml +11 -0
  42. data/app/views/workarea/storefront/emarsys/_current_user_emarsys_cart.json.jbuilder +6 -0
  43. data/app/workers/workarea/emarsys/save_email_signup.rb +40 -0
  44. data/app/workers/workarea/emarsys/save_order.rb +32 -0
  45. data/app/workers/workarea/emarsys/save_user.rb +44 -0
  46. data/app/workers/workarea/emarsys/sync_orders.rb +50 -0
  47. data/bin/rails +20 -0
  48. data/config/initializers/appends.rb +19 -0
  49. data/config/initializers/scheduled_jobs.rb +6 -0
  50. data/config/initializers/workarea.rb +16 -0
  51. data/config/locales/en.yml +28 -0
  52. data/config/routes.rb +7 -0
  53. data/lib/workarea/emarsys/engine.rb +12 -0
  54. data/lib/workarea/emarsys/version.rb +5 -0
  55. data/lib/workarea/emarsys.rb +59 -0
  56. data/test/dummy/Rakefile +6 -0
  57. data/test/dummy/app/assets/config/manifest.js +4 -0
  58. data/test/dummy/app/assets/images/.keep +0 -0
  59. data/test/dummy/app/assets/javascripts/application.js +13 -0
  60. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  61. data/test/dummy/app/controllers/application_controller.rb +3 -0
  62. data/test/dummy/app/controllers/concerns/.keep +0 -0
  63. data/test/dummy/app/helpers/application_helper.rb +2 -0
  64. data/test/dummy/app/jobs/application_job.rb +2 -0
  65. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  66. data/test/dummy/app/models/concerns/.keep +0 -0
  67. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  68. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  69. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  70. data/test/dummy/bin/bundle +3 -0
  71. data/test/dummy/bin/rails +4 -0
  72. data/test/dummy/bin/rake +4 -0
  73. data/test/dummy/bin/setup +30 -0
  74. data/test/dummy/bin/update +26 -0
  75. data/test/dummy/bin/yarn +11 -0
  76. data/test/dummy/config/application.rb +30 -0
  77. data/test/dummy/config/boot.rb +5 -0
  78. data/test/dummy/config/cable.yml +10 -0
  79. data/test/dummy/config/environment.rb +5 -0
  80. data/test/dummy/config/environments/development.rb +51 -0
  81. data/test/dummy/config/environments/production.rb +88 -0
  82. data/test/dummy/config/environments/test.rb +44 -0
  83. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  84. data/test/dummy/config/initializers/assets.rb +14 -0
  85. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  86. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  87. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  88. data/test/dummy/config/initializers/inflections.rb +16 -0
  89. data/test/dummy/config/initializers/mime_types.rb +4 -0
  90. data/test/dummy/config/initializers/workarea.rb +5 -0
  91. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  92. data/test/dummy/config/locales/en.yml +33 -0
  93. data/test/dummy/config/puma.rb +56 -0
  94. data/test/dummy/config/routes.rb +5 -0
  95. data/test/dummy/config/secrets.yml +32 -0
  96. data/test/dummy/config/spring.rb +6 -0
  97. data/test/dummy/config.ru +5 -0
  98. data/test/dummy/db/seeds.rb +2 -0
  99. data/test/dummy/lib/assets/.keep +0 -0
  100. data/test/dummy/log/.keep +0 -0
  101. data/test/integration/workarea/admin/emarsys_configuration_integration_test.rb +25 -0
  102. data/test/lib/workarea/emarsys/gateway_test.rb +26 -0
  103. data/test/services/emarsys/contact_test.rb +44 -0
  104. data/test/support/workarea/emarsys_api_config.rb +19 -0
  105. data/test/system/workarea/storefront/emarsys_tracking_system_test.rb +25 -0
  106. data/test/teaspoon_env.rb +6 -0
  107. data/test/test_helper.rb +10 -0
  108. data/test/vcr_cassettes/emarsys/add_contact.yml +67 -0
  109. data/test/vcr_cassettes/emarsys/get_contact.yml +129 -0
  110. data/test/vcr_cassettes/emarsys/sales/send_data.yml +42 -0
  111. data/test/workers/workarea/emarsys/save_user_test.rb +30 -0
  112. data/test/workers/workarea/emarsys/sync_orders_test.rb +38 -0
  113. data/workarea-emarsys.gemspec +24 -0
  114. metadata +211 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9bf08626204f88ffee6ab6fa870e77600c0665d21044100e4f32befe82768e40
4
+ data.tar.gz: 99229d93a96c5641bfcd0080255b018ce17b90b1b575e05e115f3f4223035bcf
5
+ SHA512:
6
+ metadata.gz: 175be3626fc157fe1a93e88ea47f2d761b8ecd1bdbb585260e27045d6e1832ef7799a52415b0655b9a113ca0ce70508162a3e36ee56ed102a1f2e2afc51df651
7
+ data.tar.gz: 3bfcd9e665cf6d68f953e981ed59c9c9a157242fd06d493f58e965a7096eb954f5bcc169c962c79ee89cfe85e6dd08821341874f1d57df68c74fdd2011c21a03
data/.editorconfig ADDED
@@ -0,0 +1,20 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ end_of_line = lf
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [{*.rb,*.haml,*.decorator,*.yml,*.yaml,*.jbuilder}]
12
+ indent_size = 2
13
+ indent_style = space
14
+
15
+ [{*.js,*.jst,*.ejs,*.scss}]
16
+ indent_size = 4
17
+
18
+ [*.md]
19
+ indent_size = 4
20
+ trim_trailing_whitespace = false
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve Workarea
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ ⚠️**Before you create**⚠️
11
+ Please verify the issue you're experiencing is not part of your Workarea project customizations. The best way to do this is with a [vanilla Workarea installation](https://developer.workarea.com/articles/create-a-new-host-application.html). This will help us spend time on fixes/improvements for the whole community. Thank you!
12
+
13
+ **Describe the bug**
14
+ A clear and concise description of what the bug is.
15
+
16
+ **To Reproduce**
17
+ Steps to reproduce the behavior:
18
+ 1. Go to '...'
19
+ 2. Click on '....'
20
+ 3. Scroll down to '....'
21
+ 4. See error
22
+
23
+ **Expected behavior**
24
+ A clear and concise description of what you expected to happen.
25
+
26
+ **Workarea Setup (please complete the following information):**
27
+ - Workarea Version: [e.g. v3.4.6]
28
+ - Plugins [e.g. workarea-blog, workarea-sitemaps]
29
+
30
+ **Attachments**
31
+ If applicable, add any attachments to help explain your problem, things like:
32
+ - screenshots
33
+ - Gemfile.lock
34
+ - test cases
35
+
36
+ **Additional context**
37
+ Add any other context about the problem here.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Documentation request
3
+ about: Suggest documentation
4
+ title: ''
5
+ labels: documentation
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your documentation related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm confused by [...]
12
+
13
+ **Describe the article you'd like**
14
+ A clear and concise description of what would be in the documentation article.
15
+
16
+ **Additional context**
17
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for Workarea
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/db/*.sqlite3-journal
6
+ test/dummy/log/*.log
7
+ test/dummy/tmp/
8
+ .DS_Store
9
+ .byebug_history
10
+ .bundle/
11
+ .sass-cache/
12
+ Gemfile.lock
13
+ pkg/
14
+ test/dummy/tmp/
15
+ test/dummy/public/
16
+ log/*.log
17
+ test/dummy/log/*.log
18
+ test/dummy/db/*.sqlite3
19
+ test/dummy/db/*.sqlite3-journal
20
+ node_modules
21
+ package.json
22
+ yarn.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ Workarea Emarsys 1.0.2 (2019-08-22)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Open Source!
5
+
6
+
7
+
8
+ Workarea Emarsys 1.0.1 (2019-06-25)
9
+ --------------------------------------------------------------------------------
10
+
11
+ * Update test to allow support for Workarea < v3.4
12
+
13
+ EMARSYS-11
14
+ Jake Beresford
15
+
16
+
17
+
18
+ Workarea Emarsys 1.0.0 (2019-06-11)
19
+ --------------------------------------------------------------------------------
20
+
21
+ * Workarea Emarsys
22
+
23
+ Emarsys marketing platform integration. Includes contact, order and product
24
+ syncing as well as a full Web Extend Integration.
25
+ Eric Pigeon
26
+
27
+
28
+
@@ -0,0 +1,3 @@
1
+ View this plugin's code of conduct here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CODE_OF_CONDUCT.md>
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
1
+ View this plugin's contribution guidelines here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CONTRIBUTING.md>
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "git@github.com:#{repo}.git" }
3
+
4
+ gemspec
5
+
6
+ gem 'workarea'
7
+ gem 'workarea-ci'
8
+
9
+ group :test do
10
+ gem 'simplecov', require: false
11
+ gem 'workarea-testing'
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ WebLinc
2
+ Business Source License
3
+
4
+ Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
5
+
6
+ Licensed Work: Workarea Commerce Platform
7
+ The Licensed Work is (c) 2019 WebLinc Corporation
8
+
9
+ Additional Use Grant:
10
+ You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
11
+
12
+ A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
13
+
14
+ For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
15
+
16
+ Change Date: 2019-08-20
17
+
18
+ Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
19
+
20
+ Terms
21
+
22
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
25
+
26
+ If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
27
+
28
+ All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
29
+
30
+ You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
31
+
32
+ Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
33
+
34
+ This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
35
+
36
+ Covenants of Licensor
37
+ In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
38
+
39
+ To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
40
+
41
+ To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
42
+
43
+ To specify a Change Date.
44
+
45
+ Not to modify this License in any other way.
46
+
47
+ Notice
48
+ The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
49
+
50
+ For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
51
+
52
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
data/LICENSE.md ADDED
@@ -0,0 +1,3 @@
1
+ View this plugin's license here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/LICENSE.md>
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ Workarea Emarsys
2
+ ================================================================================
3
+
4
+ Emarsys plugin for the Workarea platform.
5
+
6
+ This integration supports the following:
7
+
8
+ 1. Contact syncronization
9
+ 2. Product files
10
+ 3. Order syncronization
11
+ 4. Full Web-Extend Analytics integration
12
+
13
+ Configuration
14
+ --------------------------------------------------------------------------------
15
+ 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.
16
+
17
+ The follow is accessible via the configuration panel:
18
+
19
+ 1. **Production:** A toggle switch to set the integration into production mode, defaults to false.
20
+ 2. **Customer ID:** The customer ID of account. Ask your Emarsys account manager for this value.
21
+ 3. **Merchant ID:** The merchant ID of the Emarsys account. This value is required for the Web Extend Analytics Integration
22
+
23
+
24
+ The contact and sales data APIs require different access keys that require storage in the secrets file.
25
+
26
+ Add the following to your secrets:
27
+
28
+ emarsys:
29
+ secret_key: YOUR_SECRET_KEY_HERE
30
+ emarsys_sales:
31
+ api_token: YOUR_TOKEN_HERE
32
+
33
+
34
+ Data Exporting
35
+ --------------------------------------------------------------------------------
36
+ **Product Data**
37
+
38
+ Emarsys supports the google product feed specification for product catalog. This integration includes the Workarea Google Product feed to support exporting products. The Google product feed will generate at 5:00 AM daily.
39
+
40
+ You can access the Google product feed at: https://www.your_domain.com/google_feed
41
+
42
+ **Order Files**
43
+
44
+ Order files are exported every six hours. The default order fields are supported.
45
+
46
+ More information about order files can be found here: https://help.emarsys.com/hc/en-us/articles/360003070654-Preparing-your-sales-data-file
47
+
48
+ Getting Started
49
+ --------------------------------------------------------------------------------
50
+
51
+ This gem contains a rails engine that must be mounted onto a host Rails application.
52
+
53
+ To access Workarea gems and source code, you must be an employee of WebLinc or a licensed retailer or partner.
54
+
55
+ Workarea gems are hosted privately at https://gems.weblinc.com/.
56
+ You must have individual or team credentials to install gems from this server. Add your gems server credentials to Bundler:
57
+
58
+ bundle config gems.weblinc.com my_username:my_password
59
+
60
+ Or set the appropriate environment variable in a shell startup file:
61
+
62
+ export BUNDLE_GEMS__WEBLINC__COM='my_username:my_password'
63
+
64
+ Then add the gem to your application's Gemfile specifying the source:
65
+
66
+ # ...
67
+ gem 'workarea-emarsys', source: 'https://gems.weblinc.com'
68
+ # ...
69
+
70
+ Or use a source block:
71
+
72
+ # ...
73
+ source 'https://gems.weblinc.com' do
74
+ gem 'workarea-emarsys'
75
+ end
76
+ # ...
77
+
78
+ Update your application's bundle.
79
+
80
+ cd path/to/application
81
+ bundle
82
+
83
+ Workarea Platform Documentation
84
+ --------------------------------------------------------------------------------
85
+
86
+ See [http://developer.weblinc.com](http://developer.weblinc.com) for Workarea platform documentation.
87
+
88
+ Copyright & Licensing
89
+ --------------------------------------------------------------------------------
90
+
91
+ Copyright WebLinc 2019. All rights reserved.
92
+
93
+ For licensing, contact sales@workarea.com.
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+ RDoc::Task.new(:rdoc) do |rdoc|
9
+ rdoc.rdoc_dir = 'rdoc'
10
+ rdoc.title = 'Emarsys'
11
+ rdoc.options << '--line-numbers'
12
+ rdoc.rdoc_files.include('README.md')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ load 'rails/tasks/engine.rake'
18
+ load 'rails/tasks/statistics.rake'
19
+ load 'workarea/changelog.rake'
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << 'lib'
24
+ t.libs << 'test'
25
+ t.pattern = 'test/**/*_test.rb'
26
+ t.verbose = false
27
+ end
28
+ task default: :test
29
+
30
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
31
+ require 'workarea/emarsys/version'
32
+
33
+ desc "Release version #{Workarea::Emarsys::VERSION} of the gem"
34
+ task :release do
35
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
36
+
37
+ #Rake::Task['workarea:changelog'].execute
38
+ #system 'git add CHANGELOG.md'
39
+ #system 'git commit -m "Update CHANGELOG"'
40
+ #system 'git push origin HEAD'
41
+
42
+ system "git tag -a v#{Workarea::Emarsys::VERSION} -m 'Tagging #{Workarea::Emarsys::VERSION}'"
43
+ system 'git push --tags'
44
+
45
+ system "gem build workarea-emarsys.gemspec"
46
+ system "gem push workarea-emarsys-#{Workarea::Emarsys::VERSION}.gem"
47
+ system "gem push workarea-emarsys-#{Workarea::Emarsys::VERSION}.gem --host #{host}"
48
+ system "rm workarea-emarsys-#{Workarea::Emarsys::VERSION}.gem"
49
+ end
50
+
51
+ desc 'Run the JavaScript tests'
52
+ ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
53
+ task teaspoon: 'app:teaspoon'
54
+
55
+ desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
56
+ task :teaspoon_server do
57
+ Dir.chdir("test/dummy")
58
+ teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
59
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
60
+ end
File without changes
File without changes
@@ -0,0 +1,128 @@
1
+ /* eslint no-console: "off" */
2
+ /* global console, ScarabQueue */
3
+
4
+ /**
5
+ * @namespace WORKAREA.webExtendAdapter
6
+ */
7
+ WORKAREA.analytics.registerAdapter('webExtendAdapter', function () {
8
+ 'use strict';
9
+
10
+ var pushEmarsysEvent = function(event, payload) {
11
+ if (WORKAREA.environment.isTest || _.isUndefined(window.ScarabQueue)) {
12
+ console.log('Emarsys is not configured or is disabled in test');
13
+ return;
14
+ }
15
+
16
+ if (WORKAREA.analytics.debug) {
17
+ console.log("Sending event to Emarsys", event, payload);
18
+ }
19
+
20
+ if (event === 'go') {
21
+ ScarabQueue.push(['go']);
22
+ } else {
23
+ ScarabQueue.push([event, payload]);
24
+ }
25
+ },
26
+
27
+ reportCart = function (items) {
28
+ pushEmarsysEvent('cart', items);
29
+ },
30
+
31
+ /**
32
+ * Returns the email address from emarsys_email cookie set in
33
+ * email_signups_controller#create.
34
+ * @return String
35
+ */
36
+ emailFromCookie = function() {
37
+ var email = WORKAREA.cookie.read('emarsys_email');
38
+
39
+ if (_.isNull(email)) {
40
+ return('');
41
+ } else {
42
+ return(decodeURIComponent(email));
43
+ }
44
+ },
45
+
46
+ setEmail = function (currentUserEmail) {
47
+ var email = currentUserEmail || emailFromCookie();
48
+
49
+ if (_.isEmpty(email)) { return; }
50
+
51
+ pushEmarsysEvent('setEmail', email);
52
+ },
53
+
54
+ firedEventNames = function() {
55
+ return(
56
+ WORKAREA.analytics.events.map( function (event) {
57
+ return event.name;
58
+ })
59
+ );
60
+ },
61
+
62
+ sendEmailFromUser = function() {
63
+ var firedEvents = firedEventNames(),
64
+ eventsWithEmailPayload = [
65
+ 'checkoutShippingView',
66
+ 'checkoutPaymentView',
67
+ 'checkoutOrderPlaced'
68
+ ];
69
+
70
+ return (_.isEmpty(_.intersection(firedEvents, eventsWithEmailPayload)));
71
+ },
72
+
73
+ sendGo = function() {
74
+ pushEmarsysEvent('go');
75
+ };
76
+
77
+ return {
78
+ 'checkoutOrderPlaced': function (payload) {
79
+ var orderItems = _.map(payload.items, function (item) {
80
+ return {
81
+ 'item': item.id,
82
+ 'price': item.price,
83
+ 'quantity': item.quantity
84
+ };
85
+ });
86
+
87
+ setEmail(payload.emarsys_user_email);
88
+ pushEmarsysEvent(
89
+ 'purchase',
90
+ {
91
+ orderId: payload.id,
92
+ items: orderItems
93
+ }
94
+ );
95
+ },
96
+
97
+ 'productView': function (payload) {
98
+ pushEmarsysEvent('view', payload.id);
99
+ },
100
+
101
+ 'categoryView': function (payload) {
102
+ if (_.isUndefined(payload.emarsys_category_path)) { return; }
103
+ pushEmarsysEvent('category', payload.emarsys_category_path);
104
+ },
105
+
106
+ 'searchResultsView': function (payload) {
107
+ pushEmarsysEvent('searchTerm', payload.terms);
108
+ },
109
+
110
+ 'checkoutShippingView': function (payload) {
111
+ setEmail(payload.emarsys_user_email);
112
+ },
113
+
114
+ 'checkoutPaymentView': function (payload) {
115
+ setEmail(payload.emarsys_user_email);
116
+ },
117
+
118
+ 'pageView': function() {
119
+ WORKAREA.currentUser.gettingUserData.done(function(user){
120
+ if (sendEmailFromUser()) {
121
+ setEmail(user.email);
122
+ }
123
+ reportCart(user.emarsys_cart_items);
124
+ sendGo();
125
+ });
126
+ }
127
+ };
128
+ });
File without changes
File without changes
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,16 @@
1
+ module Workarea
2
+ decorate Storefront::EmailSignupsController, with: :emarsys do
3
+ def create
4
+ signup = Email.signup(params[:email])
5
+
6
+ if signup.try(:valid?)
7
+ cookies[:emarsys_email] = params[:email]
8
+ flash[:success] = t('workarea.storefront.flash_messages.email_signed_up')
9
+ else
10
+ flash[:error] = t('workarea.storefront.flash_messages.email_signup_error')
11
+ end
12
+
13
+ redirect_back fallback_location: root_path
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module Workarea
2
+ decorate Storefront::Users::AddressesController, with: :emarsys do
3
+ decorated do
4
+ after_action :save_emarsys_contact, only: [:create, :update]
5
+ end
6
+
7
+ private
8
+
9
+ def save_emarsys_contact
10
+ Emarsys::SaveUser.perform_async(current_user.id)
11
+ end
12
+ end
13
+ end
data/app/helpers/.keep ADDED
File without changes
@@ -0,0 +1,13 @@
1
+ module Workarea
2
+ module Storefront
3
+ module EmarsysAnalyticsHelper
4
+ def category_view_analytics_data(category)
5
+ super.merge(emarsys_category_path: category.google_name)
6
+ end
7
+
8
+ def order_analytics_data(order)
9
+ super.merge(emarsys_user_email: current_user&.email || order.email)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ module Workarea
2
+ module Emarsys
3
+ class BogusGateway
4
+
5
+ attr_reader :options
6
+
7
+ def initialize(options = {})
8
+ @options = options
9
+ end
10
+
11
+ def method_missing(method, *args)
12
+ response
13
+ end
14
+
15
+ private
16
+
17
+ def response
18
+ response = Faraday.new do |builder|
19
+ builder.adapter :test do |stub|
20
+ stub.get('/rest/bogus.json') { |env| [ 200, {}, response_body ] }
21
+ end
22
+ end
23
+ r = response.get('/rest/bogus.json')
24
+ Response.new(r)
25
+ end
26
+
27
+ def response_body
28
+ {
29
+ "data" => {
30
+ "ids" => ['123456']
31
+ }
32
+ }.to_json
33
+ end
34
+ end
35
+ end
36
+ end