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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 37cf9d9129cf565114ca4f4b83ffeea474d5d448e16400a93bc566b92f1344a2
4
+ data.tar.gz: 236d9df971bd47bac9c0bab46673f3c0e48dddf14f7110835609788554b42861
5
+ SHA512:
6
+ metadata.gz: 8ca2d78aaaec9acbf0c28a38a85c73176613c131cae3888d5d63c285f0c94b04116a3a4a728e7639bf8e1b36540b8a87e8260dbd3ee33d081d355e308a3e27fe
7
+ data.tar.gz: c14094a306bf705b4289a7455a0818a34fe5b926e25fcb20a65f750891c3e554c5cfc468775cb6deaae2a550b68525a7ab533b1bae1164dd27c5fffa9ead0a11
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_JOBS: "12"
@@ -0,0 +1,41 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ # Always take the latest version of the orb, this allows us to
5
+ # run specs against Solidus supported versions only without the need
6
+ # to change this configuration every time a Solidus version is released
7
+ # or goes EOL.
8
+ solidusio_extensions: solidusio/extensions@volatile
9
+
10
+ jobs:
11
+ run-specs-with-postgres:
12
+ executor: solidusio_extensions/postgres
13
+ steps:
14
+ - solidusio_extensions/run-tests
15
+ run-specs-with-mysql:
16
+ executor: solidusio_extensions/mysql
17
+ steps:
18
+ - solidusio_extensions/run-tests
19
+ lint-code:
20
+ executor: solidusio_extensions/sqlite-memory
21
+ steps:
22
+ - solidusio_extensions/lint-code
23
+
24
+ workflows:
25
+ "Run specs on supported Solidus versions":
26
+ jobs:
27
+ - run-specs-with-postgres
28
+ - run-specs-with-mysql
29
+ - lint-code
30
+
31
+ "Weekly run specs against master":
32
+ triggers:
33
+ - schedule:
34
+ cron: "0 0 * * 4" # every Thursday
35
+ filters:
36
+ branches:
37
+ only:
38
+ - master
39
+ jobs:
40
+ - run-specs-with-postgres
41
+ - run-specs-with-mysql
data/.gem_release.yml ADDED
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_shipstation/version.rb'
4
+ message: Bump SolidusShipstation to %{version}
5
+ tag: true
data/.github/stale.yml ADDED
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: false
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: stale
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It might be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
@@ -0,0 +1,2 @@
1
+ issues=false
2
+ exclude-labels=infrastructure
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
10
+ Gemfile.lock
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
16
+ spec/examples.txt
17
+ /sandbox
18
+ .rvmrc
19
+ .ruby-version
20
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ require:
4
+ - solidus_dev_support/rubocop
5
+
6
+ AllCops:
7
+ NewCops: disable
8
+
9
+ Layout/LineLength:
10
+ Enabled: false
11
+
12
+ Rails/SkipsModelValidations:
13
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,40 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-09-22 09:09:44 UTC using RuboCop version 0.87.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Lint/UselessAssignment:
11
+ Exclude:
12
+ - 'app/controllers/spree/shipstation_controller.rb'
13
+
14
+ # Offense count: 1
15
+ RSpec/AnyInstance:
16
+ Exclude:
17
+ - 'spec/lib/solidus_shipstation/shipment_notice_spec.rb'
18
+
19
+ # Offense count: 5
20
+ RSpec/MultipleExpectations:
21
+ Max: 2
22
+
23
+ # Offense count: 8
24
+ RSpec/NestedGroups:
25
+ Max: 5
26
+
27
+ # Offense count: 6
28
+ # Configuration parameters: ForbiddenMethods, AllowedMethods.
29
+ # ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
30
+ Rails/SkipsModelValidations:
31
+ Exclude:
32
+ - 'spec/lib/solidus_shipstation/shipment_notice_spec.rb'
33
+ - 'spec/models/spree/shipment_spec.rb'
34
+ - 'spec/support/shipment_helper.rb'
35
+
36
+ # Offense count: 1
37
+ # Configuration parameters: MinBodyLength.
38
+ Style/GuardClause:
39
+ Exclude:
40
+ - 'spec/support/configuration_helper.rb'
data/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ ## [v1.0.0](https://github.com/solidusio-contrib/solidus_shipstation/tree/v1.0.0) (2021-05-26)
4
+
5
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_shipstation/compare/v2.0.1...v1.0.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Prepare Solidus Shipstation for Solidus 3.0 [\#6](https://github.com/solidusio-contrib/solidus_shipstation/issues/6)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Fix pending API sync query returning synced shipments [\#15](https://github.com/solidusio-contrib/solidus_shipstation/pull/15) ([aldesantis](https://github.com/aldesantis))
14
+ - Swallow errors in `Api::SyncShipmentsJob` [\#14](https://github.com/solidusio-contrib/solidus_shipstation/pull/14) ([aldesantis](https://github.com/aldesantis))
15
+ - API sync improvements [\#13](https://github.com/solidusio-contrib/solidus_shipstation/pull/13) ([aldesantis](https://github.com/aldesantis))
16
+ - Error handling & configuration improvements [\#12](https://github.com/solidusio-contrib/solidus_shipstation/pull/12) ([aldesantis](https://github.com/aldesantis))
17
+ - API integration [\#10](https://github.com/solidusio-contrib/solidus_shipstation/pull/10) ([aldesantis](https://github.com/aldesantis))
18
+ - Deprecate Spree::Shipment decorators [\#9](https://github.com/solidusio-contrib/solidus_shipstation/pull/9) ([aldesantis](https://github.com/aldesantis))
19
+ - Fix ShipmentNotice not handling double shipments [\#8](https://github.com/solidusio-contrib/solidus_shipstation/pull/8) ([aldesantis](https://github.com/aldesantis))
20
+ - Update extension skeleton [\#7](https://github.com/solidusio-contrib/solidus_shipstation/pull/7) ([aldesantis](https://github.com/aldesantis))
21
+ - Add configuration to export canceled shipments [\#4](https://github.com/solidusio-contrib/solidus_shipstation/pull/4) ([igorbp](https://github.com/igorbp))
22
+ - Fix shipment tracking number not being propagated to carton [\#3](https://github.com/solidusio-contrib/solidus_shipstation/pull/3) ([aldesantis](https://github.com/aldesantis))
23
+ - Fix installer [\#2](https://github.com/solidusio-contrib/solidus_shipstation/pull/2) ([kennyadsl](https://github.com/kennyadsl))
24
+ - Make extension compatible with latest Solidus [\#1](https://github.com/solidusio-contrib/solidus_shipstation/pull/1) ([aldesantis](https://github.com/aldesantis))
25
+
26
+ ## [v2.0.1](https://github.com/solidusio-contrib/solidus_shipstation/tree/v2.0.1) (2014-05-01)
27
+
28
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_shipstation/compare/v1.3.2...v2.0.1)
29
+
30
+ ## [v1.3.2](https://github.com/solidusio-contrib/solidus_shipstation/tree/v1.3.2) (2013-11-22)
31
+
32
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_shipstation/compare/077ee0bcdf9faf66121faa4387ec645122892c98...v1.3.2)
33
+
34
+
35
+
36
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
+
9
+ # Needed to help Bundler figure out how to resolve dependencies,
10
+ # otherwise it takes forever to resolve them.
11
+ # See https://github.com/bundler/bundler/issues/6677
12
+ gem 'rails', '>0.a'
13
+
14
+ # Provides basic authentication functionality for testing parts of your engine
15
+ gem 'solidus_auth_devise'
16
+
17
+ case ENV['DB']
18
+ when 'mysql'
19
+ gem 'mysql2'
20
+ when 'postgresql'
21
+ gem 'pg'
22
+ else
23
+ gem 'sqlite3'
24
+ end
25
+
26
+ gemspec
27
+
28
+ # Use a local Gemfile to include development dependencies that might not be
29
+ # relevant for the project or for other contributors, e.g. pry-byebug.
30
+ #
31
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
32
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
33
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2013 Boomer Digital
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,208 @@
1
+ # Solidus ShipStation
2
+
3
+ [![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_shipstation.svg?style=shield)](https://circleci.com/gh/solidusio-contrib/solidus_shipstation)
4
+ [![codecov](https://codecov.io/gh/solidusio-contrib/solidus_shipstation/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio-contrib/solidus_shipstation)
5
+
6
+ This gem integrates [ShipStation](http://www.shipstation.com) with [Solidus](http://solidus.io). It
7
+ enables ShipStation to pull shipments from the system and update tracking numbers.
8
+
9
+ This integration is a fork of [spree_shipstation](https://github.com/DynamoMTL/spree_shipstation)
10
+ that adds Solidus and Rails 4.2+ compatibility.
11
+
12
+ ## Installation
13
+
14
+ Add solidus_shipstation to your Gemfile:
15
+
16
+ ```ruby
17
+ gem 'solidus_shipstation', github: 'solidusio-contrib/solidus_shipstation'
18
+ ```
19
+
20
+ Bundle your dependencies and run the installation generator:
21
+
22
+ ```shell
23
+ bin/rails generate solidus_shipstation:install
24
+ ```
25
+
26
+ The installer will create a configuration initializer that you'll need to customize.
27
+
28
+ The installer will also create a migration, which is required by the API integration. If you are
29
+ going to use the XML integration, feel free to delete the migration file, as those columns won't be
30
+ used by the extension.
31
+
32
+ ## Usage
33
+
34
+ This extension can integrate with ShipStation in two ways.
35
+
36
+ ### XML integration
37
+
38
+ The [XML integration](https://help.shipstation.com/hc/en-us/articles/360025856192-Custom-Store-Development-Guide)
39
+ works by exposing a route in your Solidus application that generates an XML feed of all recently
40
+ created and updated shipments in your Solidus store.
41
+
42
+ #### XML integration: Configuration
43
+
44
+ In order to enable the XML integration, make sure to configure the relevant section of the
45
+ configuration initializer, and configure your ShipStation store accordingly:
46
+
47
+ - **Username**: the username defined in your configuration.
48
+ - **Password**: the password defined in your configuration.
49
+ - **URL to custom page**: `https://yourdomain.com/shipstation.xml`.
50
+
51
+ You can also configure your ShipStation store to pull the XML feed automatically on a recurring
52
+ basis, or manually by clicking the "Refresh stores" button.
53
+
54
+ There are five shipment states for an order (= shipment) in ShipStation. These states do not
55
+ necessarily align with Solidus, but you can configure ShipStation to create a mapping for your
56
+ specific needs. Here's the recommended mapping:
57
+
58
+ ShipStation description | ShipStation status | Solidus status
59
+ ------------------------|--------------------|---------------
60
+ Awaiting Payment | `unpaid` | `pending`
61
+ Awaiting Shipment | `paid` | `ready`
62
+ Shipped | `shipped` | `shipped`
63
+ Cancelled | `cancelled` | `cancelled`
64
+ On-Hold | `on-hold` | `pending`
65
+
66
+ Once you've configured the XML integration in your app and ShipStation, there's nothing else you
67
+ need to do. ShipStation will
68
+
69
+ #### XML integration: Usage
70
+
71
+ There's nothing you need to do. Once properly configured, the integration just works!
72
+
73
+ #### XML integration: Gotchas
74
+
75
+ There are a few gotchas you need to be aware of:
76
+
77
+ - If you change the shipping method of an order in ShipStation, the change will not be reflected in
78
+ Solidus and the tracking link might not work properly.
79
+ - When `shipstation_capture_at_notification` is enabled, any errors during payment capture will
80
+ prevent the update of the shipment's tracking number.
81
+
82
+ ### API integration
83
+
84
+ The [API integration](https://www.shipstation.com/docs/api/) works by calling the ShipStation API
85
+ to sync all of your shipments continuously.
86
+
87
+ Because ShipStation has very low rate limits (i.e., 40 reqs/minute at the time of writing), the
88
+ API integration does not send an API request for every single shipment update, as you would expect
89
+ from a traditional API integration.
90
+
91
+ Instead, a background job runs on a recurring basis and batches together all the shipments that need
92
+ to be created or updated in ShipStation. These shipments are then sent in groups of 100 (by default)
93
+ to ShipStation's [bulk order upsert endpoint](https://www.shipstation.com/docs/api/orders/create-update-multiple-orders/).
94
+
95
+ This allows us to work around ShipStation's rate limit and sync up to 4000 shipments/minute.
96
+
97
+ As you may imagine, this technique also comes at the expense of some additional complexity in the
98
+ implementation, but the extension abstracts it all away for you.
99
+
100
+ #### API integration: Configuration
101
+
102
+ In order to enable the API integration, make sure to configure the relevant section of the
103
+ configuration initializer. At the very least, the integration needs to know your API credentials
104
+ and store ID, but there are additional options you can configure — just look at the initializer!
105
+
106
+ #### API integration: Usage
107
+
108
+ Once you've configured the integration, you will also need to enqueue the `ScheduleShipmentSyncsJob`
109
+ on a recurring basis, to kick off the synchronization process. Because every app uses a different
110
+ background processing library, this is left up to the user.
111
+
112
+ Here's what an example with [sidekiq-scheduler](https://github.com/moove-it/sidekiq-scheduler) might
113
+ look like:
114
+
115
+ ```yaml
116
+ # config/sidekiq.yml
117
+ :schedule:
118
+ schedule_shipment_syncs:
119
+ every: ['1m', first_in: '0s']
120
+ class: 'SolidusShipstation::Api::ScheduleShipmentSyncsJob'
121
+ ```
122
+
123
+ This will schedule the job to run every minute. This is generally a good starting point, but feel
124
+ free to adjust it as needed.
125
+
126
+ #### API integration: Gotchas
127
+
128
+ There's one possible problem you need to be aware of, when integrating via the API.
129
+
130
+ You should make sure the interval between your syncs is, on average, larger than your latency in
131
+ processing background jobs, or you are going to experience sync overlaps.
132
+
133
+ As an example, if it takes your Sidekiq process 10 seconds to execute a job from the time it's
134
+ scheduled, but you schedule a shipment sync every 5 seconds, your sync jobs will start overlapping,
135
+ making your latency even worse.
136
+
137
+ This is a problem that is faced by all recurring jobs. The solution is two-fold:
138
+
139
+ 1. Monitor the latency of your background processing queues. Seriously, do it.
140
+ 2. Make sure your sync interval is not too aggressive: unless you really need to, there's no point
141
+ in syncing your shipments more often than once a minute.
142
+
143
+ ## Development
144
+
145
+ ### Testing the extension
146
+
147
+ First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
148
+ app if it does not exist, then it will run specs. The dummy app can be regenerated by using
149
+ `bin/rake extension:test_app`.
150
+
151
+ ```shell
152
+ bin/rake
153
+ ```
154
+
155
+ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
156
+
157
+ ```shell
158
+ bundle exec rubocop
159
+ ```
160
+
161
+ When testing your application's integration with this extension you may use its factories.
162
+ Simply add this require statement to your `spec/spec_helper.rb`:
163
+
164
+ ```ruby
165
+ require 'solidus_shipstation/testing_support/factories'
166
+ ```
167
+
168
+ Or, if you are using `FactoryBot.definition_file_paths`, you can load Solidus core
169
+ factories along with this extension's factories using this statement:
170
+
171
+ ```ruby
172
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusShipstation::Engine)
173
+ ```
174
+
175
+ ### Running the sandbox
176
+
177
+ To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
178
+ the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
179
+ `sandbox/bin/rails`.
180
+
181
+ Here's an example:
182
+
183
+ ```
184
+ $ bin/rails server
185
+ => Booting Puma
186
+ => Rails 6.0.2.1 application starting in development
187
+ * Listening on tcp://127.0.0.1:3000
188
+ Use Ctrl-C to stop
189
+ ```
190
+
191
+ ### Updating the changelog
192
+
193
+ Before and after releases the changelog should be updated to reflect the up-to-date status of
194
+ the project:
195
+
196
+ ```shell
197
+ bin/rake changelog
198
+ git add CHANGELOG.md
199
+ git commit -m "Update the changelog"
200
+ ```
201
+
202
+ ### Releasing new versions
203
+
204
+ Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
205
+
206
+ ## License
207
+
208
+ Copyright (c) 2013 Boomer Digital, released under the New BSD License.