workarea-ship_station 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/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  3. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. data/.github/workflows/ci.yml +54 -0
  6. data/.gitignore +19 -0
  7. data/.rubocop.yml +3 -0
  8. data/CHANGELOG.md +13 -0
  9. data/Gemfile +17 -0
  10. data/LICENSE +52 -0
  11. data/README.md +89 -0
  12. data/Rakefile +57 -0
  13. data/app/assets/images/workarea/admin/ship_station/.keep +0 -0
  14. data/app/assets/images/workarea/storefront/ship_station/.keep +0 -0
  15. data/app/assets/javascripts/workarea/admin/ship_station/.keep +0 -0
  16. data/app/assets/javascripts/workarea/storefront/ship_station/.keep +0 -0
  17. data/app/assets/stylesheets/workarea/admin/ship_station/.keep +0 -0
  18. data/app/assets/stylesheets/workarea/storefront/ship_station/.keep +0 -0
  19. data/app/controllers/workarea/admin/orders_controller.decorator +50 -0
  20. data/app/controllers/workarea/storefront/ship_station_webhook_controller.rb +52 -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/models/workarea/order.decorator +25 -0
  25. data/app/services/workarea/ship_station/order.rb +161 -0
  26. data/app/services/workarea/ship_station/webhook.rb +27 -0
  27. data/app/services/workarea/ship_station/webhook/item_ship_notify.rb +33 -0
  28. data/app/views/.keep +0 -0
  29. data/app/views/workarea/admin/orders/_ship_station.html.haml +12 -0
  30. data/app/views/workarea/admin/orders/_ship_station_bar_actions.html.haml +7 -0
  31. data/app/views/workarea/admin/orders/hold_date.html.haml +27 -0
  32. data/app/workers/workarea/ship_station/save_order.rb +24 -0
  33. data/bin/rails +25 -0
  34. data/config/initializers/appends.rb +9 -0
  35. data/config/initializers/workarea.rb +11 -0
  36. data/config/locales/en.yml +20 -0
  37. data/config/routes.rb +13 -0
  38. data/lib/workarea/ship_station.rb +39 -0
  39. data/lib/workarea/ship_station/bogus_gateway.rb +297 -0
  40. data/lib/workarea/ship_station/engine.rb +10 -0
  41. data/lib/workarea/ship_station/gateway.rb +92 -0
  42. data/lib/workarea/ship_station/response.rb +17 -0
  43. data/lib/workarea/ship_station/version.rb +5 -0
  44. data/test/dummy/Rakefile +6 -0
  45. data/test/dummy/app/assets/config/manifest.js +3 -0
  46. data/test/dummy/app/assets/images/.keep +0 -0
  47. data/test/dummy/app/assets/javascripts/application.js +14 -0
  48. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  49. data/test/dummy/app/controllers/application_controller.rb +2 -0
  50. data/test/dummy/app/controllers/concerns/.keep +0 -0
  51. data/test/dummy/app/helpers/application_helper.rb +2 -0
  52. data/test/dummy/app/jobs/application_job.rb +2 -0
  53. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  54. data/test/dummy/app/models/concerns/.keep +0 -0
  55. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  56. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  57. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  58. data/test/dummy/bin/bundle +3 -0
  59. data/test/dummy/bin/rails +4 -0
  60. data/test/dummy/bin/rake +4 -0
  61. data/test/dummy/bin/setup +25 -0
  62. data/test/dummy/bin/update +25 -0
  63. data/test/dummy/config.ru +5 -0
  64. data/test/dummy/config/application.rb +34 -0
  65. data/test/dummy/config/boot.rb +5 -0
  66. data/test/dummy/config/environment.rb +5 -0
  67. data/test/dummy/config/environments/development.rb +52 -0
  68. data/test/dummy/config/environments/production.rb +83 -0
  69. data/test/dummy/config/environments/test.rb +45 -0
  70. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  71. data/test/dummy/config/initializers/assets.rb +12 -0
  72. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  73. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  74. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  75. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  76. data/test/dummy/config/initializers/inflections.rb +16 -0
  77. data/test/dummy/config/initializers/mime_types.rb +4 -0
  78. data/test/dummy/config/initializers/workarea.rb +5 -0
  79. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  80. data/test/dummy/config/locales/en.yml +33 -0
  81. data/test/dummy/config/puma.rb +34 -0
  82. data/test/dummy/config/routes.rb +5 -0
  83. data/test/dummy/config/spring.rb +6 -0
  84. data/test/dummy/db/seeds.rb +2 -0
  85. data/test/dummy/lib/assets/.keep +0 -0
  86. data/test/dummy/log/.keep +0 -0
  87. data/test/integration/workarea/admin/ship_station_integration_test.rb +36 -0
  88. data/test/integration/workarea/storefront/ship_station_webhook_test.rb +37 -0
  89. data/test/integration/workarea/storefront/ship_station_webhooks/notify_shipment_test.rb +56 -0
  90. data/test/services/workarea/ship_station/order_test.rb +67 -0
  91. data/test/teaspoon_env.rb +6 -0
  92. data/test/test_helper.rb +10 -0
  93. data/test/workers/workarea/ship_station/save_order_test.rb +16 -0
  94. data/workarea-ship_station.gemspec +20 -0
  95. metadata +157 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dab40a2886377073b6804cf0c61bb5a17340e4a1b873b40b8faf608c95b1b32d
4
+ data.tar.gz: 4855ac55cbcbd188a59b4f592bab181af4d1f3f9c2c88e3ffc85776b1f1c99f8
5
+ SHA512:
6
+ metadata.gz: f647bcf5a621619b560b23a925d90774b42cb3bdb1c8ddd13624e849e29061e1b236153865accc5e2a745c99537e69cad906e4d019ab84a0664f72ad52462778
7
+ data.tar.gz: 627dee053fb03fd07316dd6e2dd1d395b023dcfbb2f23de70de9ba2de4d16f8ad2fcb15d798943c7d5947ebffb2ee456b05d34bbcf0c73b257b8e116d0a6654f
@@ -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,19 @@
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
+ test/dummy/.ruby-version
9
+ .DS_Store
10
+ .byebug_history
11
+ .bundle/
12
+ .sass-cache/
13
+ Gemfile.lock
14
+ test/dummy/public/
15
+ node_modules
16
+ coverage/
17
+ package.json
18
+ yarn.lock
19
+ .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/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ Workarea Ship Station 1.0.0 (2019-10-30)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Integrate ShipStation
5
+
6
+ Send orders to shipstation on order place and
7
+ receive fulfillment date via webhook
8
+
9
+ SHIPSTATION-1
10
+ Jeff Yucis
11
+
12
+
13
+
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in ship_station.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ # To use a debugger
15
+ # gem 'byebug', group: [:development, :test]
16
+
17
+ gem 'workarea', github: 'workarea-commerce/workarea', branch: 'v3.4-stable'
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/README.md ADDED
@@ -0,0 +1,89 @@
1
+ Workarea Ship Station
2
+ ================================================================================
3
+
4
+ ShipStation plugin for the Workarea platform.
5
+
6
+ Overview
7
+ --------------------------------------------------------------------------------
8
+
9
+ ShipStation integration for the Workarea Commerce Platform. This plugin handles
10
+ sending orders via the ShipStation API as well as receiving fulfillment updates
11
+ from webhooks.
12
+
13
+ This integration supports the following features:
14
+
15
+ * API integration to send orders to from Workarea to ShipStation
16
+ * Webhook endpoints to receive fulfillment data from ShipStation
17
+ * Administration controls for setting and removing on hold status
18
+ * Configuration options for ship by date
19
+
20
+ Workarea admins with access to the orders screen will have the option to set an order on hold until a specified date.
21
+ An admin can set a specific hold untill date as well as release orders from on hold that have been placed on hold from the Workarea admin.
22
+
23
+
24
+ Configuration
25
+ --------------------------------------------------------------------------------
26
+
27
+ ShipStation API credentials are required to send orders and receive fulfillments.
28
+ You can get your API credentials by logging into your ShipStation account and going
29
+ to settings, then clicking "API settings" under the "Account" tab.
30
+
31
+ Generate API keys if there are none present and add them to your host apps secrets file:
32
+
33
+ ```
34
+ ship_station:
35
+ api_key: YOUR-API-KEY
36
+ api_secret: YOUR-API-SECRET
37
+ ```
38
+
39
+ **Fulfillment Notification**
40
+
41
+ Workarea receives fulfillment notifications via ShipStation webhooks.
42
+
43
+ Documentation on setting up ShipStation Webhooks can be found [here](https://help.shipstation.com/hc/en-us/articles/360025856252-ShipStation-Webhooks#UUID-1a4971f4-8fb5-f4a5-c399-f36cff610435_UUID-9336531a-ef72-7c0f-6fbb-598f8f144cf3)
44
+
45
+ When setting up your integration in ShipStation set the following values:
46
+
47
+ * Name Description: Can be anything you want, for example "Workarea Fulfillment notification"
48
+ * Select "On Items Shipped" from the drop down.
49
+ * Select "All Stores" from the second dropdown.
50
+ * Send Url: Put "https://YOURDOMAINHERE/ship_station_webhook" - Be sure to change replace YOURDOMAINHERE with your actual domain.
51
+
52
+ Workarea supports the "On Items Shipped" action only.
53
+
54
+ **Be sure to create a webhook for each domain your Workarea app supports if you have a multisite setup**
55
+
56
+ You can add an optional ship by date lead time via a configuration value.
57
+ This value will be added to the current date and sent to ShipStation when an order is placed. This date will show as the "Ship By" date in the orders admin screen in ShipStation.
58
+
59
+ ```ruby
60
+ config.ship_station.ship_by_date_lead_days = 5
61
+ ```
62
+
63
+
64
+ Getting Started
65
+ --------------------------------------------------------------------------------
66
+
67
+ This gem contains a Rails engine that must be mounted onto a host Rails application.
68
+
69
+ Then add the gem to your application's Gemfile specifying the source:
70
+
71
+ # ...
72
+ gem 'workarea-ship_station'
73
+ # ...
74
+
75
+ Update your application's bundle.
76
+
77
+ cd path/to/application
78
+ bundle
79
+
80
+
81
+ Workarea Platform Documentation
82
+ --------------------------------------------------------------------------------
83
+
84
+ See [https://developer.workarea.com](https://developer.workarea.com) for Workarea platform documentation.
85
+
86
+ License
87
+ --------------------------------------------------------------------------------
88
+
89
+ Workarea Ship Station is released under the [Business Software License](LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,57 @@
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 = 'Ship Station'
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/ship_station/version'
32
+
33
+ desc "Release version #{Workarea::ShipStation::VERSION} of the gem"
34
+ task :release do
35
+ Rake::Task['workarea:changelog'].execute
36
+ system 'git add CHANGELOG.md'
37
+ system 'git commit -m "Update CHANGELOG"'
38
+ system 'git push origin HEAD'
39
+
40
+ system "git tag -a v#{Workarea::ShipStation::VERSION} -m 'Tagging #{Workarea::ShipStation::VERSION}'"
41
+ system 'git push --tags'
42
+
43
+ system "gem build workarea-ship_station.gemspec"
44
+ system "gem push workarea-ship_station-#{Workarea::ShipStation::VERSION}.gem"
45
+ system "rm workarea-ship_station-#{Workarea::ShipStation::VERSION}.gem"
46
+ end
47
+
48
+ desc 'Run the JavaScript tests'
49
+ ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
50
+ task teaspoon: 'app:teaspoon'
51
+
52
+ desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
53
+ task :teaspoon_server do
54
+ Dir.chdir("test/dummy")
55
+ teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
56
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
57
+ end
@@ -0,0 +1,50 @@
1
+ module Workarea
2
+ decorate Admin::OrdersController, with: :ship_station do
3
+
4
+ def save_hold_date
5
+ response = Workarea::ShipStation.gateway.hold_order(ship_station_hold_attrs)
6
+
7
+ if response.success?
8
+ @order.update_attributes!(ship_station_on_hold_until: params[:hold_until])
9
+
10
+ flash[:success] = t('workarea.admin.orders.placed_on_hold_success')
11
+ redirect_to order_path(@order)
12
+ else
13
+ flash[:error] = t('workarea.admin.orders.placed_on_hold_error')
14
+ render :select_hold_date
15
+ end
16
+ end
17
+
18
+ def clear_hold_date
19
+ response = Workarea::ShipStation.gateway.clear_hold_order(ship_station_clear_hold_attrs)
20
+
21
+ if response.success?
22
+ @order.update_attributes!(ship_station_on_hold_until: nil)
23
+
24
+ flash[:success] = t('workarea.admin.orders.clear_on_hold_success')
25
+ redirect_to order_path(@order)
26
+ else
27
+ flash[:error] = t('workarea.admin.orders.clear_on_hold_error')
28
+ render :select_hold_date
29
+ end
30
+ end
31
+
32
+ def select_hold_date
33
+ end
34
+
35
+ private
36
+
37
+ def ship_station_hold_attrs
38
+ {
39
+ orderId: @order.ship_station_order_id,
40
+ holdUntilDate: params[:hold_until]
41
+ }
42
+ end
43
+
44
+ def ship_station_clear_hold_attrs
45
+ {
46
+ orderId: @order.ship_station_order_id
47
+ }
48
+ end
49
+ end
50
+ end