solidus_shipstation 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.bundle/config +2 -0
  3. data/.circleci/config.yml +41 -0
  4. data/.gem_release.yml +5 -0
  5. data/.github/stale.yml +17 -0
  6. data/.github_changelog_generator +2 -0
  7. data/.gitignore +20 -0
  8. data/.rspec +2 -0
  9. data/.rubocop.yml +13 -0
  10. data/.rubocop_todo.yml +40 -0
  11. data/CHANGELOG.md +36 -0
  12. data/Gemfile +33 -0
  13. data/LICENSE +26 -0
  14. data/README.md +208 -0
  15. data/Rakefile +6 -0
  16. data/app/assets/javascripts/spree/backend/solidus_shipstation.js +2 -0
  17. data/app/assets/javascripts/spree/frontend/solidus_shipstation.js +2 -0
  18. data/app/assets/stylesheets/spree/backend/solidus_shipstation.css +4 -0
  19. data/app/assets/stylesheets/spree/frontend/solidus_shipstation.css +4 -0
  20. data/app/controllers/spree/shipstation_controller.rb +45 -0
  21. data/app/decorators/models/solidus_shipstation/spree/shipment_decorator.rb +33 -0
  22. data/app/helpers/solidus_shipstation/export_helper.rb +32 -0
  23. data/app/jobs/solidus_shipstation/api/schedule_shipment_syncs_job.rb +19 -0
  24. data/app/jobs/solidus_shipstation/api/sync_shipments_job.rb +41 -0
  25. data/app/queries/solidus_shipstation/shipment/between_query.rb +14 -0
  26. data/app/queries/solidus_shipstation/shipment/exportable_query.rb +24 -0
  27. data/app/queries/solidus_shipstation/shipment/pending_api_sync_query.rb +63 -0
  28. data/app/views/spree/shipstation/export.xml.builder +58 -0
  29. data/bin/console +17 -0
  30. data/bin/rails +7 -0
  31. data/bin/rails-engine +13 -0
  32. data/bin/rails-sandbox +16 -0
  33. data/bin/rake +7 -0
  34. data/bin/sandbox +86 -0
  35. data/bin/setup +8 -0
  36. data/config/locales/en.yml +5 -0
  37. data/config/routes.rb +6 -0
  38. data/db/migrate/20210220093010_add_shipstation_api_sync_fields.rb +9 -0
  39. data/lib/generators/solidus_shipstation/install/install_generator.rb +27 -0
  40. data/lib/generators/solidus_shipstation/install/templates/initializer.rb +62 -0
  41. data/lib/solidus_shipstation.rb +16 -0
  42. data/lib/solidus_shipstation/api/batch_syncer.rb +70 -0
  43. data/lib/solidus_shipstation/api/client.rb +38 -0
  44. data/lib/solidus_shipstation/api/rate_limited_error.rb +23 -0
  45. data/lib/solidus_shipstation/api/request_error.rb +33 -0
  46. data/lib/solidus_shipstation/api/request_runner.rb +50 -0
  47. data/lib/solidus_shipstation/api/shipment_serializer.rb +84 -0
  48. data/lib/solidus_shipstation/api/threshold_verifier.rb +28 -0
  49. data/lib/solidus_shipstation/configuration.rb +44 -0
  50. data/lib/solidus_shipstation/engine.rb +19 -0
  51. data/lib/solidus_shipstation/errors.rb +23 -0
  52. data/lib/solidus_shipstation/shipment_notice.rb +58 -0
  53. data/lib/solidus_shipstation/testing_support/factories.rb +4 -0
  54. data/lib/solidus_shipstation/version.rb +5 -0
  55. data/solidus_shipstation.gemspec +40 -0
  56. data/spec/controllers/spree/shipstation_controller_spec.rb +103 -0
  57. data/spec/fixtures/shipstation_xml_schema.xsd +171 -0
  58. data/spec/jobs/solidus_shipstation/api/schedule_shipment_syncs_job_spec.rb +32 -0
  59. data/spec/jobs/solidus_shipstation/api/sync_shipments_job_spec.rb +102 -0
  60. data/spec/lib/solidus_shipstation/api/batch_syncer_spec.rb +229 -0
  61. data/spec/lib/solidus_shipstation/api/client_spec.rb +120 -0
  62. data/spec/lib/solidus_shipstation/api/rate_limited_error_spec.rb +21 -0
  63. data/spec/lib/solidus_shipstation/api/request_error_spec.rb +20 -0
  64. data/spec/lib/solidus_shipstation/api/request_runner_spec.rb +64 -0
  65. data/spec/lib/solidus_shipstation/api/shipment_serializer_spec.rb +12 -0
  66. data/spec/lib/solidus_shipstation/api/threshold_verifier_spec.rb +61 -0
  67. data/spec/lib/solidus_shipstation/shipment_notice_spec.rb +111 -0
  68. data/spec/lib/solidus_shipstation_spec.rb +9 -0
  69. data/spec/models/spree/shipment_spec.rb +49 -0
  70. data/spec/queries/solidus_shipstation/shipment/between_query_spec.rb +53 -0
  71. data/spec/queries/solidus_shipstation/shipment/exportable_query_spec.rb +53 -0
  72. data/spec/queries/solidus_shipstation/shipment/pending_api_sync_query_spec.rb +37 -0
  73. data/spec/spec_helper.rb +31 -0
  74. data/spec/support/configuration_helper.rb +13 -0
  75. data/spec/support/controllers.rb +1 -0
  76. data/spec/support/webmock.rb +3 -0
  77. data/spec/support/xsd.rb +5 -0
  78. metadata +248 -0
@@ -0,0 +1,37 @@
1
+ RSpec.describe SolidusShipstation::Shipment::PendingApiSyncQuery do
2
+ describe '.apply' do
3
+ context 'when dealing with shipments that were never synced' do
4
+ it 'returns the shipments that are within the threshold' do
5
+ stub_configuration(api_sync_threshold: 10.minutes)
6
+ shipment = create(:order_ready_to_ship).shipments.first.tap do |s|
7
+ s.order.update_columns(updated_at: 9.minutes.ago)
8
+ end
9
+ create(:order_ready_to_ship).shipments.first.tap do |s|
10
+ s.order.update_columns(updated_at: 11.minutes.ago)
11
+ end
12
+
13
+ expect(described_class.apply(Spree::Shipment.all)).to match_array([shipment])
14
+ end
15
+ end
16
+
17
+ context 'when dealing with shipments that were already synced' do
18
+ it 'returns the shipments that are within the threshold and pending a re-sync' do
19
+ stub_configuration(api_sync_threshold: 10.minutes)
20
+ shipment = create(:order_ready_to_ship).shipments.first.tap do |s|
21
+ s.order.update_columns(updated_at: 7.minutes.ago)
22
+ s.update_columns(shipstation_synced_at: 8.minutes.ago)
23
+ end
24
+ create(:order_ready_to_ship).shipments.first.tap do |s|
25
+ s.order.update_columns(updated_at: 9.minutes.ago)
26
+ s.update_columns(shipstation_synced_at: 8.minutes.ago)
27
+ end
28
+ create(:order_ready_to_ship).shipments.first.tap do |s|
29
+ s.order.update_columns(updated_at: 11.minutes.ago)
30
+ s.update_columns(shipstation_synced_at: 10.minutes.ago)
31
+ end
32
+
33
+ expect(described_class.apply(Spree::Shipment.all)).to match_array([shipment])
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Configure Rails Environment
4
+ ENV['RAILS_ENV'] = 'test'
5
+
6
+ # Run Coverage report
7
+ require 'solidus_dev_support/rspec/coverage'
8
+
9
+ # Create the dummy app if it's still missing.
10
+ dummy_env = "#{__dir__}/dummy/config/environment.rb"
11
+ system 'bin/rake extension:test_app' unless File.exist? dummy_env
12
+ require dummy_env
13
+
14
+ # Requires factories and other useful helpers defined in spree_core.
15
+ require 'solidus_dev_support/rspec/feature_helper'
16
+
17
+ # Requires supporting ruby files with custom matchers and macros, etc,
18
+ # in spec/support/ and its subdirectories.
19
+ Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
20
+
21
+ # Requires factories defined in lib/solidus_shipstation/testing_support/factories.rb
22
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusShipstation::Engine)
23
+
24
+ RSpec.configure do |config|
25
+ config.infer_spec_type_from_file_location!
26
+ config.use_transactional_fixtures = false
27
+
28
+ if Spree.solidus_gem_version < Gem::Version.new('2.11')
29
+ config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ module ConfigurationHelper
2
+ def stub_configuration(options)
3
+ allow(SolidusShipstation.configuration).to receive_messages(options)
4
+
5
+ if options[:capture_at_notification]
6
+ stub_spree_preferences(require_payment_to_ship: false)
7
+ end
8
+ end
9
+ end
10
+
11
+ RSpec.configure do |config|
12
+ config.include ConfigurationHelper
13
+ end
@@ -0,0 +1 @@
1
+ require 'rails-controller-testing'
@@ -0,0 +1,3 @@
1
+ require 'webmock/rspec'
2
+
3
+ WebMock.disable_net_connect!
@@ -0,0 +1,5 @@
1
+ require 'rspec/xsd'
2
+
3
+ RSpec.configure do |config|
4
+ config.include RSpec::XSD
5
+ end
metadata ADDED
@@ -0,0 +1,248 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solidus_shipstation
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Puiszis
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: solidus_core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '4'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.0.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '4'
47
+ - !ruby/object:Gem::Dependency
48
+ name: solidus_support
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.5'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.5'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rails-controller-testing
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec-xsd
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: solidus_dev_support
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '2.5'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2.5'
103
+ - !ruby/object:Gem::Dependency
104
+ name: webmock
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ description: Integrates ShipStation API with Solidus. Supports exporting shipments
118
+ and importing tracking numbers
119
+ email: steve@tablexi.com
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - ".bundle/config"
125
+ - ".circleci/config.yml"
126
+ - ".gem_release.yml"
127
+ - ".github/stale.yml"
128
+ - ".github_changelog_generator"
129
+ - ".gitignore"
130
+ - ".rspec"
131
+ - ".rubocop.yml"
132
+ - ".rubocop_todo.yml"
133
+ - CHANGELOG.md
134
+ - Gemfile
135
+ - LICENSE
136
+ - README.md
137
+ - Rakefile
138
+ - app/assets/javascripts/spree/backend/solidus_shipstation.js
139
+ - app/assets/javascripts/spree/frontend/solidus_shipstation.js
140
+ - app/assets/stylesheets/spree/backend/solidus_shipstation.css
141
+ - app/assets/stylesheets/spree/frontend/solidus_shipstation.css
142
+ - app/controllers/spree/shipstation_controller.rb
143
+ - app/decorators/models/solidus_shipstation/spree/shipment_decorator.rb
144
+ - app/helpers/solidus_shipstation/export_helper.rb
145
+ - app/jobs/solidus_shipstation/api/schedule_shipment_syncs_job.rb
146
+ - app/jobs/solidus_shipstation/api/sync_shipments_job.rb
147
+ - app/queries/solidus_shipstation/shipment/between_query.rb
148
+ - app/queries/solidus_shipstation/shipment/exportable_query.rb
149
+ - app/queries/solidus_shipstation/shipment/pending_api_sync_query.rb
150
+ - app/views/spree/shipstation/export.xml.builder
151
+ - bin/console
152
+ - bin/rails
153
+ - bin/rails-engine
154
+ - bin/rails-sandbox
155
+ - bin/rake
156
+ - bin/sandbox
157
+ - bin/setup
158
+ - config/locales/en.yml
159
+ - config/routes.rb
160
+ - db/migrate/20210220093010_add_shipstation_api_sync_fields.rb
161
+ - lib/generators/solidus_shipstation/install/install_generator.rb
162
+ - lib/generators/solidus_shipstation/install/templates/initializer.rb
163
+ - lib/solidus_shipstation.rb
164
+ - lib/solidus_shipstation/api/batch_syncer.rb
165
+ - lib/solidus_shipstation/api/client.rb
166
+ - lib/solidus_shipstation/api/rate_limited_error.rb
167
+ - lib/solidus_shipstation/api/request_error.rb
168
+ - lib/solidus_shipstation/api/request_runner.rb
169
+ - lib/solidus_shipstation/api/shipment_serializer.rb
170
+ - lib/solidus_shipstation/api/threshold_verifier.rb
171
+ - lib/solidus_shipstation/configuration.rb
172
+ - lib/solidus_shipstation/engine.rb
173
+ - lib/solidus_shipstation/errors.rb
174
+ - lib/solidus_shipstation/shipment_notice.rb
175
+ - lib/solidus_shipstation/testing_support/factories.rb
176
+ - lib/solidus_shipstation/version.rb
177
+ - solidus_shipstation.gemspec
178
+ - spec/controllers/spree/shipstation_controller_spec.rb
179
+ - spec/fixtures/shipstation_xml_schema.xsd
180
+ - spec/jobs/solidus_shipstation/api/schedule_shipment_syncs_job_spec.rb
181
+ - spec/jobs/solidus_shipstation/api/sync_shipments_job_spec.rb
182
+ - spec/lib/solidus_shipstation/api/batch_syncer_spec.rb
183
+ - spec/lib/solidus_shipstation/api/client_spec.rb
184
+ - spec/lib/solidus_shipstation/api/rate_limited_error_spec.rb
185
+ - spec/lib/solidus_shipstation/api/request_error_spec.rb
186
+ - spec/lib/solidus_shipstation/api/request_runner_spec.rb
187
+ - spec/lib/solidus_shipstation/api/shipment_serializer_spec.rb
188
+ - spec/lib/solidus_shipstation/api/threshold_verifier_spec.rb
189
+ - spec/lib/solidus_shipstation/shipment_notice_spec.rb
190
+ - spec/lib/solidus_shipstation_spec.rb
191
+ - spec/models/spree/shipment_spec.rb
192
+ - spec/queries/solidus_shipstation/shipment/between_query_spec.rb
193
+ - spec/queries/solidus_shipstation/shipment/exportable_query_spec.rb
194
+ - spec/queries/solidus_shipstation/shipment/pending_api_sync_query_spec.rb
195
+ - spec/spec_helper.rb
196
+ - spec/support/configuration_helper.rb
197
+ - spec/support/controllers.rb
198
+ - spec/support/webmock.rb
199
+ - spec/support/xsd.rb
200
+ homepage: https://github.com/solidusio-contrib/solidus_shipstation
201
+ licenses:
202
+ - BSD-3-Clause
203
+ metadata:
204
+ homepage_uri: https://github.com/solidusio-contrib/solidus_shipstation
205
+ source_code_uri: https://github.com/solidusio-contrib/solidus_shipstation
206
+ changelog_uri: https://github.com/solidusio-contrib/solidus_shipstation/blob/master/CHANGELOG.md
207
+ post_install_message:
208
+ rdoc_options: []
209
+ require_paths:
210
+ - lib
211
+ required_ruby_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '2.5'
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ requirements: []
222
+ rubygems_version: 3.1.4
223
+ signing_key:
224
+ specification_version: 4
225
+ summary: Solidus/ShipStation Integration
226
+ test_files:
227
+ - spec/controllers/spree/shipstation_controller_spec.rb
228
+ - spec/fixtures/shipstation_xml_schema.xsd
229
+ - spec/jobs/solidus_shipstation/api/schedule_shipment_syncs_job_spec.rb
230
+ - spec/jobs/solidus_shipstation/api/sync_shipments_job_spec.rb
231
+ - spec/lib/solidus_shipstation/api/batch_syncer_spec.rb
232
+ - spec/lib/solidus_shipstation/api/client_spec.rb
233
+ - spec/lib/solidus_shipstation/api/rate_limited_error_spec.rb
234
+ - spec/lib/solidus_shipstation/api/request_error_spec.rb
235
+ - spec/lib/solidus_shipstation/api/request_runner_spec.rb
236
+ - spec/lib/solidus_shipstation/api/shipment_serializer_spec.rb
237
+ - spec/lib/solidus_shipstation/api/threshold_verifier_spec.rb
238
+ - spec/lib/solidus_shipstation/shipment_notice_spec.rb
239
+ - spec/lib/solidus_shipstation_spec.rb
240
+ - spec/models/spree/shipment_spec.rb
241
+ - spec/queries/solidus_shipstation/shipment/between_query_spec.rb
242
+ - spec/queries/solidus_shipstation/shipment/exportable_query_spec.rb
243
+ - spec/queries/solidus_shipstation/shipment/pending_api_sync_query_spec.rb
244
+ - spec/spec_helper.rb
245
+ - spec/support/configuration_helper.rb
246
+ - spec/support/controllers.rb
247
+ - spec/support/webmock.rb
248
+ - spec/support/xsd.rb