workarea-yotpo 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) 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/.github/workflows/ci.yml +54 -0
  7. data/.gitignore +23 -0
  8. data/.rubocop.yml +3 -0
  9. data/.travis.yml +27 -0
  10. data/CHANGELOG.md +20 -0
  11. data/CODE_OF_CONDUCT.md +3 -0
  12. data/CONTRIBUTING.md +3 -0
  13. data/Gemfile +6 -0
  14. data/LICENSE.md +3 -0
  15. data/README.md +86 -0
  16. data/Rakefile +60 -0
  17. data/app/assets/images/yotpo/.keep +0 -0
  18. data/app/assets/javascripts/yotpo/.keep +0 -0
  19. data/app/assets/stylesheets/yotpo/.keep +0 -0
  20. data/app/controllers/.keep +0 -0
  21. data/app/helpers/.keep +0 -0
  22. data/app/mailers/.keep +0 -0
  23. data/app/models/.keep +0 -0
  24. data/app/services/yotpo/order.rb +81 -0
  25. data/app/views/workarea/storefront/_yotpo_tracking.html.haml +3 -0
  26. data/app/views/workarea/storefront/checkouts/_yotpo_order_tracking.html.haml +7 -0
  27. data/app/views/workarea/storefront/products/_yotpo_product_summary.html.haml +2 -0
  28. data/app/views/workarea/storefront/products/_yotpo_reviews.html.haml +2 -0
  29. data/app/views/workarea/storefront/products/_yotpo_summary.html.haml +2 -0
  30. data/app/workers/workarea/yotpo/save_order.rb +20 -0
  31. data/bin/rails +25 -0
  32. data/config/initializers/appends.rb +24 -0
  33. data/config/initializers/workarea.rb +11 -0
  34. data/config/routes.rb +2 -0
  35. data/lib/workarea/yotpo.rb +41 -0
  36. data/lib/workarea/yotpo/authentication.rb +45 -0
  37. data/lib/workarea/yotpo/bogus_gateway.rb +33 -0
  38. data/lib/workarea/yotpo/engine.rb +10 -0
  39. data/lib/workarea/yotpo/gateway.rb +64 -0
  40. data/lib/workarea/yotpo/response.rb +17 -0
  41. data/lib/workarea/yotpo/version.rb +5 -0
  42. data/script/static_analysis +29 -0
  43. data/script/travis +6 -0
  44. data/test/dummy/.ruby-version +1 -0
  45. data/test/dummy/Rakefile +6 -0
  46. data/test/dummy/app/assets/config/manifest.js +3 -0
  47. data/test/dummy/app/assets/images/.keep +0 -0
  48. data/test/dummy/app/assets/javascripts/application.js +14 -0
  49. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  50. data/test/dummy/app/controllers/application_controller.rb +2 -0
  51. data/test/dummy/app/controllers/concerns/.keep +0 -0
  52. data/test/dummy/app/helpers/application_helper.rb +2 -0
  53. data/test/dummy/app/jobs/application_job.rb +2 -0
  54. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  55. data/test/dummy/app/models/concerns/.keep +0 -0
  56. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  57. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  58. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  59. data/test/dummy/bin/bundle +3 -0
  60. data/test/dummy/bin/rails +4 -0
  61. data/test/dummy/bin/rake +4 -0
  62. data/test/dummy/bin/setup +28 -0
  63. data/test/dummy/bin/update +28 -0
  64. data/test/dummy/bin/yarn +11 -0
  65. data/test/dummy/config.ru +5 -0
  66. data/test/dummy/config/application.rb +34 -0
  67. data/test/dummy/config/boot.rb +5 -0
  68. data/test/dummy/config/environment.rb +5 -0
  69. data/test/dummy/config/environments/development.rb +52 -0
  70. data/test/dummy/config/environments/production.rb +83 -0
  71. data/test/dummy/config/environments/test.rb +45 -0
  72. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  73. data/test/dummy/config/initializers/assets.rb +14 -0
  74. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  75. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  76. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  77. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  78. data/test/dummy/config/initializers/inflections.rb +16 -0
  79. data/test/dummy/config/initializers/mime_types.rb +4 -0
  80. data/test/dummy/config/initializers/workarea.rb +5 -0
  81. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  82. data/test/dummy/config/locales/en.yml +33 -0
  83. data/test/dummy/config/puma.rb +34 -0
  84. data/test/dummy/config/routes.rb +5 -0
  85. data/test/dummy/config/spring.rb +6 -0
  86. data/test/dummy/db/seeds.rb +2 -0
  87. data/test/dummy/lib/assets/.keep +0 -0
  88. data/test/dummy/log/.keep +0 -0
  89. data/test/integration/workarea/yotpo/yotpo_integration_test.rb +44 -0
  90. data/test/services/yotpo/order_test.rb +61 -0
  91. data/test/teaspoon_env.rb +6 -0
  92. data/test/test_helper.rb +10 -0
  93. data/test/workers/workarea/yotpo/save_order_test.rb +13 -0
  94. data/workarea-yotpo.gemspec +20 -0
  95. metadata +163 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b80de1a1a156c40c8bfed1a1c2d320f8c12ebd044b166a331687487c498864e2
4
+ data.tar.gz: bcb49c56831060862d49b983dcb6f295da78c8d53d1d116d3c3327df4daf589f
5
+ SHA512:
6
+ metadata.gz: c43000aa5d2074db6b09c1432a7b7c10fecb7a1bb18efa579f05bd9349402064b6175a54015f2529b7649098df69141d55bed2e049b41eb58ce37935c4fa0183
7
+ data.tar.gz: 43bcfcbeb05b01598b1456bf08c8930afc54fca02ab7e9a69ee94f6ab8842e3a7b1c81dfc73c19a04d82a76a2ae00396211ad1e24366424055bcf5aaefc9cf7d
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.
@@ -0,0 +1,54 @@
1
+ name: CI
2
+ on: [push]
3
+
4
+ jobs:
5
+ static_analysis:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v1
9
+ - uses: workarea-commerce/ci/bundler-audit@v1
10
+ - uses: workarea-commerce/ci/rubocop@v1
11
+
12
+ admin_tests:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v1
16
+ - uses: actions/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.6.x
19
+ - uses: workarea-commerce/ci/test@v1
20
+ with:
21
+ command: bin/rails app:workarea:test:admin
22
+
23
+ core_tests:
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v1
27
+ - uses: actions/setup-ruby@v1
28
+ with:
29
+ ruby-version: 2.6.x
30
+ - uses: workarea-commerce/ci/test@v1
31
+ with:
32
+ command: bin/rails app:workarea:test:core
33
+
34
+ storefront_tests:
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v1
38
+ - uses: actions/setup-ruby@v1
39
+ with:
40
+ ruby-version: 2.6.x
41
+ - uses: workarea-commerce/ci/test@v1
42
+ with:
43
+ command: bin/rails app:workarea:test:storefront
44
+
45
+ plugins_tests:
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - uses: actions/checkout@v1
49
+ - uses: actions/setup-ruby@v1
50
+ with:
51
+ ruby-version: 2.6.x
52
+ - uses: workarea-commerce/ci/test@v1
53
+ with:
54
+ command: bin/rails app:workarea:test:plugins
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/log/*.log
5
+ test/dummy/node_modules/
6
+ test/dummy/yarn-error.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
23
+ .rubocop-http*
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
3
+
data/.travis.yml ADDED
@@ -0,0 +1,27 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.6
4
+
5
+ env:
6
+ global:
7
+ - CI=true RAILS_ENV=test WORKAREA_CAPYBARA_MAX_WAIT_TIME=15
8
+ matrix:
9
+ - TEST_COMMAND="bin/rails app:workarea:test:admin --trace"
10
+ - TEST_COMMAND="bin/rails app:workarea:test:core --trace"
11
+ - TEST_COMMAND="bin/rails app:workarea:test:storefront --trace"
12
+ - TEST_COMMAND="bin/rails app:workarea:test:plugins --trace"
13
+ - TEST_COMMAND="bin/rails test test/**/*_test.rb -b"
14
+ - TEST_COMMAND="script/static_analysis"
15
+
16
+ services:
17
+ - docker
18
+
19
+ addons:
20
+ chrome: stable
21
+
22
+ bundler_args: --jobs 3 --retry 3
23
+
24
+ cache: bundler
25
+
26
+ script: 'script/travis'
27
+
data/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ Workarea Yotpo 1.0.0 (2019-11-26)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Create YOPTO plugin
5
+
6
+ Curt Howard
7
+
8
+
9
+
10
+ Workarea Yotpo 1.0.0 (2019-09-04)
11
+ --------------------------------------------------------------------------------
12
+
13
+ * Releasing v1.0.0
14
+
15
+ Yotpo for review UGC. Integration includes review widget, order exports and
16
+ product export via the Google Product Feed format.
17
+ Eric Pigeon
18
+
19
+
20
+
@@ -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,6 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ gemspec
5
+
6
+ gem 'workarea', github: 'workarea-commerce/workarea'
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,86 @@
1
+ Workarea Yotpo
2
+ ================================================================================
3
+
4
+ Yotpo plugin for the Workarea platform.
5
+
6
+ The following features are supported:
7
+
8
+ * Yotpo JS SDK included on every page
9
+ * Order tracking JS on confirmation page
10
+ * Order export via the API
11
+ * Review display on PDP and product summaries.
12
+
13
+ Configuration
14
+ --------------------------------------------------------------------------------
15
+
16
+ An app key must be set in configuration to enable reviews.
17
+
18
+ Add the following to an initializer:
19
+
20
+ config.yotpo.app_key = nil
21
+
22
+ A secret must be provided in the secrets to send orders via the API.
23
+
24
+ Add the following to secrets:
25
+
26
+ yotpo:
27
+ secret_key: YOUR-SECRET-KEY
28
+
29
+ Additional configuration options are available for displaying reviews:
30
+
31
+ # show review summary on PDP
32
+ config.yotpo.show_review_summary_on_pdp = true #
33
+
34
+ # show review summaries on product summaries in search,
35
+ # browse, and recommendations
36
+ config.yotpo.show_review_summary_on_product_summary = true
37
+
38
+ config.curalate.site_name = 'YOUR_SITE_NAME'
39
+
40
+
41
+ Getting Started
42
+ --------------------------------------------------------------------------------
43
+
44
+ This gem contains a rails engine that must be mounted onto a host Rails application.
45
+
46
+ To access Workarea gems and source code, you must be an employee or a licensed retailer or partner.
47
+
48
+ Workarea gems are hosted privately at https://gems.weblinc.com/.
49
+ You must have individual or team credentials to install gems from this server. Add your gems server credentials to Bundler:
50
+
51
+ bundle config gems.weblinc.com my_username:my_password
52
+
53
+ Or set the appropriate environment variable in a shell startup file:
54
+
55
+ export BUNDLE_GEMS__WEBLINC__COM='my_username:my_password'
56
+
57
+ Then add the gem to your application's Gemfile specifying the source:
58
+
59
+ # ...
60
+ gem 'workarea-yotpo', source: 'https://gems.weblinc.com'
61
+ # ...
62
+
63
+ Or use a source block:
64
+
65
+ # ...
66
+ source 'https://gems.weblinc.com' do
67
+ gem 'workarea-yotpo'
68
+ end
69
+ # ...
70
+
71
+ Update your application's bundle.
72
+
73
+ cd path/to/application
74
+ bundle
75
+
76
+ Workarea Platform Documentation
77
+ --------------------------------------------------------------------------------
78
+
79
+ See [http://developer.workarea.com](http://developer.workarea.com) for Workarea platform documentation.
80
+
81
+ Copyright & Licensing
82
+ --------------------------------------------------------------------------------
83
+
84
+ Copyright Workarea 2019. All rights reserved.
85
+
86
+ 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 = 'Yotpo'
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/yotpo/version'
32
+
33
+ desc "Release version #{Workarea::Yotpo::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::Yotpo::VERSION} -m 'Tagging #{Workarea::Yotpo::VERSION}'"
43
+ system 'git push --tags'
44
+
45
+ system "gem build workarea-yotpo.gemspec"
46
+ system "gem push workarea-yotpo-#{Workarea::Yotpo::VERSION}.gem"
47
+ system "gem push workarea-yotpo-#{Workarea::Yotpo::VERSION}.gem --host #{host}"
48
+ system "rm workarea-yotpo-#{Workarea::Yotpo::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
File without changes
File without changes
data/app/helpers/.keep ADDED
File without changes
data/app/mailers/.keep ADDED
File without changes
data/app/models/.keep ADDED
File without changes
@@ -0,0 +1,81 @@
1
+ module Workarea
2
+ module Yotpo
3
+ class Order
4
+ module ProductUrl
5
+ include Workarea::I18n::DefaultUrlOptions
6
+ include Storefront::Engine.routes.url_helpers
7
+ extend self
8
+ end
9
+
10
+ module ProductImageUrl
11
+ include Workarea::ApplicationHelper
12
+ include Workarea::I18n::DefaultUrlOptions
13
+ include ActionView::Helpers::AssetUrlHelper
14
+ include Core::Engine.routes.url_helpers
15
+ extend self
16
+
17
+ def mounted_core
18
+ self
19
+ end
20
+ end
21
+
22
+ attr_reader :order_id, :options
23
+
24
+ def initialize(order_id, options = {})
25
+ @order_id = order_id
26
+ @options = options
27
+ end
28
+
29
+ # Builds an order hash for Yotpo
30
+ # API consumption
31
+ #
32
+ # @return [Hash]
33
+ def to_h
34
+ {
35
+ validate_data: true,
36
+ platform: "general", # TODO - get on the list of approved yotpo platforms
37
+ email: order.email,
38
+ customer_name: order.billing_address.first_name + " " + order.billing_address.last_name,
39
+ order_id: order.id,
40
+ order_date: order.placed_at,
41
+ currency_iso: order.total_price.currency.iso_code,
42
+ products: products,
43
+ customer: customer
44
+ }
45
+ end
46
+
47
+ private
48
+
49
+ def order
50
+ @order ||=
51
+ begin
52
+ o = Workarea::Order.find(order_id)
53
+ Workarea::Storefront::OrderViewModel.new(o)
54
+ end
55
+ end
56
+
57
+ # @return [Hash]
58
+ def products
59
+ order.items.inject({}) do |memo, item|
60
+ memo[item.product.id] = {
61
+ url: ProductUrl.product_url(id: item.product.to_param, host: Workarea.config.host),
62
+ name: item.product.name,
63
+ description: item.product.description,
64
+ price: item.original_price.to_s,
65
+ image: ProductImageUrl.product_image_url(item.image, :detail)
66
+ }
67
+ memo
68
+ end
69
+ end
70
+
71
+ def customer
72
+ address = order.shipping_address || order.billing_address
73
+ {
74
+ state: address.region,
75
+ country: address.country.alpha2,
76
+ address: address.street
77
+ }
78
+ end
79
+ end
80
+ end
81
+ end