solidus_bactracs 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gem_release.yml +2 -2
  3. data/.github/CODEOWNERS +54 -0
  4. data/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +3 -0
  5. data/.github/workflows/release.yml +50 -0
  6. data/.gitignore +0 -2
  7. data/.rubocop_todo.yml +3 -3
  8. data/.ruby-version +1 -0
  9. data/.tool-versions +1 -0
  10. data/CHANGELOG.md +7 -1
  11. data/PULL_REQUEST_TEMPLATE.md +3 -0
  12. data/README.md +5 -5
  13. data/app/assets/javascripts/spree/backend/{solidus_backtracs.js → solidus_bactracs.js} +0 -0
  14. data/app/assets/javascripts/spree/frontend/{solidus_backtracs.js → solidus_bactracs.js} +0 -0
  15. data/app/assets/stylesheets/spree/backend/{solidus_backtracs.css → solidus_bactracs.css} +0 -0
  16. data/app/assets/stylesheets/spree/frontend/{solidus_backtracs.css → solidus_bactracs.css} +0 -0
  17. data/app/controllers/spree/{backtracs_controller.rb → bactracs_controller.rb} +9 -9
  18. data/app/decorators/models/{solidus_backtracs → solidus_bactracs}/spree/shipment_decorator.rb +5 -5
  19. data/app/helpers/{solidus_backtracs → solidus_bactracs}/export_helper.rb +2 -2
  20. data/app/jobs/{solidus_backtracs → solidus_bactracs}/api/schedule_shipment_syncs_job.rb +7 -7
  21. data/app/jobs/{solidus_backtracs → solidus_bactracs}/api/sync_shipment_job.rb +1 -1
  22. data/app/jobs/{solidus_backtracs → solidus_bactracs}/api/sync_shipments_job.rb +3 -3
  23. data/app/queries/{solidus_backtracs → solidus_bactracs}/shipment/between_query.rb +1 -1
  24. data/app/queries/{solidus_backtracs → solidus_bactracs}/shipment/exportable_query.rb +3 -3
  25. data/app/queries/{solidus_backtracs → solidus_bactracs}/shipment/pending_api_sync_query.rb +6 -6
  26. data/app/views/spree/{backtracs → bactracs}/export.xml.builder +5 -5
  27. data/bin/console +1 -1
  28. data/bin/rails-engine +1 -1
  29. data/bin/sandbox +1 -1
  30. data/config/routes.rb +2 -2
  31. data/db/migrate/{20210220093010_add_backtracs_api_sync_fields.rb → 20210220093010_add_bactracs_api_sync_fields.rb} +2 -2
  32. data/lib/generators/{solidus_backtracs → solidus_bactracs}/install/install_generator.rb +3 -3
  33. data/lib/generators/{solidus_backtracs → solidus_bactracs}/install/templates/initializer.rb +42 -12
  34. data/lib/solidus_backtracs/version.rb +1 -1
  35. data/lib/{solidus_backtracs → solidus_bactracs}/api/batch_syncer.rb +5 -5
  36. data/lib/{solidus_backtracs → solidus_bactracs}/api/client.rb +4 -4
  37. data/lib/{solidus_backtracs → solidus_bactracs}/api/rate_limited_error.rb +1 -1
  38. data/lib/{solidus_backtracs → solidus_bactracs}/api/request_error.rb +1 -1
  39. data/lib/solidus_bactracs/api/request_runner.rb +135 -0
  40. data/lib/{solidus_backtracs → solidus_bactracs}/api/shipment_serializer.rb +28 -27
  41. data/lib/{solidus_backtracs → solidus_bactracs}/api/threshold_verifier.rb +6 -6
  42. data/lib/{solidus_backtracs → solidus_bactracs}/configuration.rb +4 -4
  43. data/lib/{solidus_backtracs → solidus_bactracs}/engine.rb +2 -2
  44. data/lib/{solidus_backtracs → solidus_bactracs}/errors.rb +1 -1
  45. data/lib/{solidus_backtracs → solidus_bactracs}/shipment_notice.rb +2 -2
  46. data/lib/{solidus_backtracs → solidus_bactracs}/testing_support/factories.rb +0 -0
  47. data/lib/solidus_bactracs/version.rb +5 -0
  48. data/lib/solidus_bactracs.rb +16 -0
  49. data/solidus_bactracs.gemspec +3 -2
  50. data/spec/controllers/spree/{backtracs_controller_spec.rb → bactracs_controller_spec.rb} +9 -9
  51. data/spec/fixtures/{backtracs_xml_schema.xsd → bactracs_xml_schema.xsd} +0 -0
  52. data/spec/jobs/{solidus_backtracs → solidus_bactracs}/api/schedule_shipment_syncs_job_spec.rb +5 -5
  53. data/spec/jobs/{solidus_backtracs → solidus_bactracs}/api/sync_shipments_job_spec.rb +10 -10
  54. data/spec/lib/{solidus_backtracs → solidus_bactracs}/api/batch_syncer_spec.rb +28 -28
  55. data/spec/lib/{solidus_backtracs → solidus_bactracs}/api/client_spec.rb +10 -10
  56. data/spec/lib/{solidus_backtracs → solidus_bactracs}/api/rate_limited_error_spec.rb +1 -1
  57. data/spec/lib/{solidus_backtracs → solidus_bactracs}/api/request_error_spec.rb +1 -1
  58. data/spec/lib/{solidus_backtracs → solidus_bactracs}/api/request_runner_spec.rb +3 -3
  59. data/spec/lib/{solidus_backtracs → solidus_bactracs}/api/shipment_serializer_spec.rb +1 -1
  60. data/spec/lib/{solidus_backtracs → solidus_bactracs}/api/threshold_verifier_spec.rb +9 -9
  61. data/spec/lib/{solidus_backtracs → solidus_bactracs}/shipment_notice_spec.rb +4 -4
  62. data/spec/lib/solidus_bactracs_spec.rb +9 -0
  63. data/spec/models/spree/shipment_spec.rb +2 -2
  64. data/spec/queries/{solidus_backtracs → solidus_bactracs}/shipment/between_query_spec.rb +1 -1
  65. data/spec/queries/{solidus_backtracs → solidus_bactracs}/shipment/exportable_query_spec.rb +1 -1
  66. data/spec/queries/{solidus_backtracs → solidus_bactracs}/shipment/pending_api_sync_query_spec.rb +4 -4
  67. data/spec/spec_helper.rb +2 -2
  68. data/spec/support/configuration_helper.rb +1 -1
  69. metadata +72 -64
  70. data/lib/solidus_backtracs/api/request_runner.rb +0 -109
  71. data/lib/solidus_backtracs.rb +0 -16
  72. data/spec/lib/solidus_backtracs_spec.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b7e4705f8b153de50fd8758b429b25bb10aaac9026ee0623fcb3fb4abab3fbb
4
- data.tar.gz: 4ce4611fba9dbc776d89800e081f95221b71019ad6d04200f0cc171957a18a21
3
+ metadata.gz: dc8997f6f0e758dad7788168d7277d6995338887221e16eaf5173c5f8e56a93a
4
+ data.tar.gz: 1e8e6ce7ecba59996b70cebbd91f49153074eb5cad64af726ba3f0bca3aa40c8
5
5
  SHA512:
6
- metadata.gz: 17c8b9f6e4ee8523d4f9fa69c7608a87bbed339ec4ba2afd26c0f071d9da0db84cf3e371604c26c4e9dec84bb41d4f66646ee14ec229740c2bbffd2c31d67eb2
7
- data.tar.gz: 6891b4cff40267a4f8762b271fa1a69633c3b0f658ccda99dbce45941b56d8895f9ecaef0dbb0f91597271c880cb66f6545e396c98c74ac98f64577484a23193
6
+ metadata.gz: 86bd10aa960cf5e863e71df839786a7b960a88eb846bf615688ca47d005207d40cd7249e313260888ec35eb496473159539720c66346e622062f613ed4d54a66
7
+ data.tar.gz: 7ee9d87aec037766f6c92d5696e66213fcd10183d09ea0e193cce4253c99743c96fcfacc857e0998d87a652079aae58cd4dc46cd2139804d24fb9fcea6cb15f6
data/.gem_release.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  bump:
2
2
  recurse: false
3
- file: 'lib/solidus_backtracs/version.rb'
4
- message: Bump SolidusBacktracs to %{version}
3
+ file: 'lib/solidus_bactracs/version.rb'
4
+ message: Bump SolidusBactracs to %{version}
5
5
  tag: true
@@ -0,0 +1,54 @@
1
+ # This is a comment.
2
+ # Each line is a file pattern followed by one or more owners.
3
+
4
+ # These owners will be the default owners for everything in
5
+ # the repo. Unless a later match takes precedence,
6
+ # @global-owner1 and @global-owner2 will be requested for
7
+ # review when someone opens a pull request.
8
+ * @suvie-eng/software-admin
9
+
10
+ # Order is important; the last matching pattern takes the most
11
+ # precedence. When someone opens a pull request that only
12
+ # modifies JS files, only @js-owner and not the global
13
+ # owner(s) will be requested for a review.
14
+ # *.js @js-owner
15
+
16
+ # You can also use email addresses if you prefer. They'll be
17
+ # used to look up users just like we do for commit author
18
+ # emails.
19
+ # *.go docs@example.com
20
+
21
+ # Teams can be specified as code owners as well. Teams should
22
+ # be identified in the format @org/team-name. Teams must have
23
+ # explicit write access to the repository. In this example,
24
+ # the octocats team in the octo-org organization owns all .txt files.
25
+ .github/ @suvie-eng/software-admin
26
+
27
+ # In this example, @doctocat owns any files in the build/logs
28
+ # directory at the root of the repository and any of its
29
+ # subdirectories.
30
+ # /build/logs/ @doctocat
31
+
32
+ # The `docs/*` pattern will match files like
33
+ # `docs/getting-started.md` but not further nested files like
34
+ # `docs/build-app/troubleshooting.md`.
35
+ # docs/* docs@example.com
36
+
37
+ # In this example, @octocat owns any file in an apps directory
38
+ # anywhere in your repository.
39
+ # apps/ @octocat
40
+
41
+ # In this example, @doctocat owns any file in the `/docs`
42
+ # directory in the root of your repository and any of its
43
+ # subdirectories.
44
+ # /docs/ @doctocat
45
+
46
+ # In this example, any change inside the `/scripts` directory
47
+ # will require approval from @doctocat or @octocat.
48
+ # /scripts/ @doctocat @octocat
49
+
50
+ # In this example, @octocat owns any file in the `/apps`
51
+ # directory in the root of your repository except for the `/apps/github`
52
+ # subdirectory, as its owners are left empty.
53
+ # /apps/ @octocat
54
+ # /apps/github
@@ -0,0 +1,3 @@
1
+
2
+ * [ ] replaced this with an outline of changes?
3
+ * [ ] updated the gem version number according to semver?
@@ -0,0 +1,50 @@
1
+ name: CI
2
+ # actions ref: https://github.com/fac/ruby-gem-push-action
3
+ # https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
4
+
5
+ on:
6
+ push:
7
+ branches:
8
+ - main
9
+ pull_request:
10
+
11
+ jobs:
12
+ # build:
13
+ # runs-on: ubuntu-latest
14
+
15
+ # steps: # (your tests go here)
16
+
17
+ release:
18
+ name: Gem / Release
19
+ # needs: test # Only release IF the tests pass
20
+ runs-on: ubuntu-latest
21
+
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ - uses: ruby/setup-ruby@v1.111.0
25
+ with:
26
+ ruby-version: '2.7.2' # Not needed with a .ruby-version file
27
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
28
+ - uses: fac/ruby-gem-setup-credentials-action@v2
29
+ with:
30
+ token: ${{ secrets.GH_TOKEN }}
31
+
32
+ - name: Build Gem
33
+ # run: bundle exec rake build
34
+ run: gem build
35
+
36
+ # Release production gem version from default branch
37
+ - name: Release Gem
38
+ if: github.ref == 'refs/heads/main'
39
+ uses: fac/ruby-gem-push-action@v2
40
+ with:
41
+ gem-glob: '*.gem'
42
+ key: github
43
+
44
+ # PR branch builds will release pre-release gems
45
+ # - name: Pre-Release Gem
46
+ # if: github.ref != 'refs/heads/main'
47
+ # uses: fac/ruby-gem-push-action@v2
48
+ # with:
49
+ # key: github
50
+ # pre-release: true
data/.gitignore CHANGED
@@ -16,7 +16,5 @@ spec/dummy
16
16
  spec/examples.txt
17
17
  /sandbox
18
18
  .rvmrc
19
- .ruby-version
20
19
  .ruby-gemset
21
- .tool-versions
22
20
  TAGS
data/.rubocop_todo.yml CHANGED
@@ -9,12 +9,12 @@
9
9
  # Offense count: 1
10
10
  Lint/UselessAssignment:
11
11
  Exclude:
12
- - 'app/controllers/spree/backtracs_controller.rb'
12
+ - 'app/controllers/spree/bactracs_controller.rb'
13
13
 
14
14
  # Offense count: 1
15
15
  RSpec/AnyInstance:
16
16
  Exclude:
17
- - 'spec/lib/solidus_backtracs/shipment_notice_spec.rb'
17
+ - 'spec/lib/solidus_bactracs/shipment_notice_spec.rb'
18
18
 
19
19
  # Offense count: 5
20
20
  RSpec/MultipleExpectations:
@@ -29,7 +29,7 @@ RSpec/NestedGroups:
29
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
30
  Rails/SkipsModelValidations:
31
31
  Exclude:
32
- - 'spec/lib/solidus_backtracs/shipment_notice_spec.rb'
32
+ - 'spec/lib/solidus_bactracs/shipment_notice_spec.rb'
33
33
  - 'spec/models/spree/shipment_spec.rb'
34
34
  - 'spec/support/shipment_helper.rb'
35
35
 
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.2
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.1.0
4
+ Different retry support for CreateRMA, as well as more logging
5
+
6
+ ## 3.0.0
7
+ Re-release the gem under a new non-forked repo, since this gem is a non-mergeable divergence from the solidus_shipstation gem
8
+
3
9
  ## 2.2.0
4
10
 
5
11
  Support the Solidus Assembly gem, consider allowed SKUs within assemblies/bundles
@@ -7,7 +13,7 @@ Retry logic for the authenticated request
7
13
 
8
14
  ## 2.1.0
9
15
 
10
- New auth and API patterns for Backtracs
16
+ New auth and API patterns for Bactracs
11
17
  Support specific SKUs to be mapped
12
18
 
13
19
  ## 2.0.0
@@ -0,0 +1,3 @@
1
+
2
+ * [ ] replaced this with an outline of changes?
3
+ * [ ] updated the gem version number according to semver?
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Solidus Bactracs
2
2
 
3
3
 
4
- This gem integrates [Bactracs](http://www.backtracs.com) with [Solidus](http://solidus.io). It
4
+ This gem integrates [Bactracs](http://www.bactracs.com) with [Solidus](http://solidus.io). It
5
5
  enables your Solidus system to push shipment RMAs to the system.
6
6
 
7
7
  > This integration was cloned from [spree_shipstation](https://github.com/DynamoMTL/spree_shipstation) to provide some consistency with other Solidus<-->Shipping related patterns.
@@ -32,7 +32,7 @@ This extension can integrate with ShipStation in two ways.
32
32
 
33
33
  ### XML integration
34
34
 
35
- The [XML integration](https://help.backtracs.com/hc/en-us/articles/360025856192-Custom-Store-Development-Guide)
35
+ The [XML integration](https://help.bactracs.com/hc/en-us/articles/360025856192-Custom-Store-Development-Guide)
36
36
  works by exposing a route in your Solidus application that generates an XML feed of all recently
37
37
  created and updated shipments in your Solidus store.
38
38
 
@@ -45,7 +45,7 @@ configuration initializer, and configure your ShipStation store accordingly:
45
45
 
46
46
  - **Username**: the username defined in your configuration.
47
47
  - **Password**: the password defined in your configuration.
48
- - **URL to custom page**: `https://yourdomain.com/backtracs.xml`.
48
+ - **URL to custom page**: `https://yourdomain.com/bactracs.xml`.
49
49
 
50
50
  You can also configure your ShipStation store to pull the XML feed automatically on a recurring
51
51
  basis, or manually by clicking the "Refresh stores" button.
@@ -80,7 +80,7 @@ There are a few gotchas you need to be aware of:
80
80
 
81
81
  ### API integration
82
82
 
83
- The [API integration](https://www.backtracs.com/docs/api/) works by calling the ShipStation API
83
+ The [API integration](https://www.bactracs.com/docs/api/) works by calling the ShipStation API
84
84
  to sync all of your shipments continuously.
85
85
 
86
86
  Because ShipStation has very low rate limits (i.e., 40 reqs/minute at the time of writing), the
@@ -89,7 +89,7 @@ from a traditional API integration.
89
89
 
90
90
  Instead, a background job runs on a recurring basis and batches together all the shipments that need
91
91
  to be created or updated in ShipStation. These shipments are then sent in groups of 100 (by default)
92
- to ShipStation's [bulk order upsert endpoint](https://www.backtracs.com/docs/api/orders/create-update-multiple-orders/).
92
+ to ShipStation's [bulk order upsert endpoint](https://www.bactracs.com/docs/api/orders/create-update-multiple-orders/).
93
93
 
94
94
  This allows us to work around Bactracs's rate limit and sync up to 4000 shipments/minute.
95
95
 
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- class BacktracsController < Spree::BaseController
4
+ class BactracsController < Spree::BaseController
5
5
  protect_from_forgery with: :null_session, only: :shipnotify
6
6
 
7
- before_action :authenticate_backtracs
7
+ before_action :authenticate_bactracs
8
8
 
9
9
  def export
10
- @shipments = SolidusBacktracs::Shipment::ExportableQuery.apply(Spree::Shipment.all)
11
- @shipments = SolidusBacktracs::Shipment::BetweenQuery.apply(
10
+ @shipments = SolidusBactracs::Shipment::ExportableQuery.apply(Spree::Shipment.all)
11
+ @shipments = SolidusBactracs::Shipment::BetweenQuery.apply(
12
12
  @shipments,
13
13
  from: date_param(:start_date),
14
14
  to: date_param(:end_date),
@@ -21,10 +21,10 @@ module Spree
21
21
  end
22
22
 
23
23
  def shipnotify
24
- shipment_notice_class = SolidusBacktracs.configuration.shipment_notice_class.constantize
24
+ shipment_notice_class = SolidusBactracs.configuration.shipment_notice_class.constantize
25
25
  shipment_notice_class.from_payload(params.to_unsafe_h).apply
26
26
  head :ok
27
- rescue SolidusBacktracs::Error => e
27
+ rescue SolidusBactracs::Error => e
28
28
  head :bad_request
29
29
  end
30
30
 
@@ -36,10 +36,10 @@ module Spree
36
36
  Time.strptime("#{params[name]} UTC", '%m/%d/%Y %H:%M %Z')
37
37
  end
38
38
 
39
- def authenticate_backtracs
39
+ def authenticate_bactracs
40
40
  authenticate_or_request_with_http_basic do |username, password|
41
- username == SolidusBacktracs.configuration.username &&
42
- password == SolidusBacktracs.configuration.password
41
+ username == SolidusBactracs.configuration.username &&
42
+ password == SolidusBactracs.configuration.password
43
43
  end
44
44
  end
45
45
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SolidusBacktracs
3
+ module SolidusBactracs
4
4
  module Spree
5
5
  module ShipmentDecorator
6
6
  def self.prepended(base)
@@ -11,19 +11,19 @@ module SolidusBacktracs
11
11
  def exportable
12
12
  ::Spree::Deprecation.warn <<~DEPRECATION
13
13
  `Spree::Shipment.exportable` is deprecated and will be removed in a future version
14
- of solidus_backtracs. Please use `SolidusBacktracs::Shipment::ExportableQuery.apply`.
14
+ of solidus_bactracs. Please use `SolidusBactracs::Shipment::ExportableQuery.apply`.
15
15
  DEPRECATION
16
16
 
17
- SolidusBacktracs::Shipment::ExportableQuery.apply(self)
17
+ SolidusBactracs::Shipment::ExportableQuery.apply(self)
18
18
  end
19
19
 
20
20
  def between(from, to)
21
21
  ::Spree::Deprecation.warn <<~DEPRECATION
22
22
  `Spree::Shipment.between` is deprecated and will be removed in a future version
23
- of solidus_backtracs. Please use `SolidusBacktracs::Shipment::BetweenQuery.apply`.
23
+ of solidus_bactracs. Please use `SolidusBactracs::Shipment::BetweenQuery.apply`.
24
24
  DEPRECATION
25
25
 
26
- SolidusBacktracs::Shipment::BetweenQuery.apply(self, from: from, to: to)
26
+ SolidusBactracs::Shipment::BetweenQuery.apply(self, from: from, to: to)
27
27
  end
28
28
  end
29
29
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'builder'
4
4
 
5
- module SolidusBacktracs
5
+ module SolidusBactracs
6
6
  module ExportHelper
7
7
  DATE_FORMAT = '%m/%d/%Y %H:%M'
8
8
  BACTRACS_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S'
@@ -29,7 +29,7 @@ module SolidusBacktracs
29
29
  }
30
30
  end
31
31
 
32
- def self.backtracs_address(xml, order, type)
32
+ def self.bactracs_address(xml, order, type)
33
33
  address = order.send("#{type}_address")
34
34
  if address.present?
35
35
  name = "#{type.to_s.titleize}To"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SolidusBacktracs
3
+ module SolidusBactracs
4
4
  module Api
5
5
  class ScheduleShipmentSyncsJob < ApplicationJob
6
6
  queue_as :default
@@ -9,24 +9,24 @@ module SolidusBacktracs
9
9
  shipments = query_shipments
10
10
  Rails.logger.info("#{self.class.name} - #{shipments.count} shipments to sync to Bactracs")
11
11
 
12
- shipments.find_in_batches(batch_size: SolidusBacktracs.config.api_batch_size) do |batch|
12
+ shipments.find_in_batches(batch_size: SolidusBactracs.config.api_batch_size) do |batch|
13
13
  SyncShipmentsJob.perform_later(batch.to_a)
14
14
  end
15
15
  rescue StandardError => e
16
- SolidusBacktracs.config.error_handler.call(e, {})
16
+ SolidusBactracs.config.error_handler.call(e, {})
17
17
  end
18
18
 
19
19
  def shippable_skus
20
- SolidusBacktracs.config.shippable_skus.present? ? SolidusBacktracs.config.shippable_skus : Spree::Variant.pluck(:sku)
20
+ SolidusBactracs.config.shippable_skus.present? ? SolidusBactracs.config.shippable_skus : Spree::Variant.pluck(:sku)
21
21
  end
22
22
 
23
23
  def query_shipments
24
- shipments = SolidusBacktracs::Shipment::PendingApiSyncQuery.apply(
24
+ shipments = SolidusBactracs::Shipment::PendingApiSyncQuery.apply(
25
25
  ::Spree::Shipment
26
26
  .joins(inventory_units: [:variant])
27
- .where("spree_variants.sku" => SolidusBacktracs.config.shippable_skus)
27
+ .where("spree_variants.sku" => SolidusBactracs.config.shippable_skus)
28
28
  .where("spree_shipments.state" => :ready)
29
- .where(backtracs_synced_at: nil)
29
+ .where(bactracs_synced_at: nil)
30
30
  .distinct
31
31
  )
32
32
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SolidusBacktracs
3
+ module SolidusBactracs
4
4
  module Api
5
5
  class SyncShipmentJob < ApplicationJob
6
6
  queue_as :default
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SolidusBacktracs
3
+ module SolidusBactracs
4
4
  module Api
5
5
  class SyncShipmentsJob < ApplicationJob
6
6
  queue_as :default
@@ -13,7 +13,7 @@ module SolidusBacktracs
13
13
  rescue RateLimitedError => e
14
14
  self.class.set(wait: e.retry_in).perform_later
15
15
  rescue StandardError => e
16
- SolidusBacktracs.config.error_handler.call(e, {})
16
+ SolidusBactracs.config.error_handler.call(e, {})
17
17
  end
18
18
 
19
19
  private
@@ -24,7 +24,7 @@ module SolidusBacktracs
24
24
  true
25
25
  else
26
26
  ::Spree::Event.fire(
27
- 'solidus_backtracs.api.sync_skipped',
27
+ 'solidus_bactracs.api.sync_skipped',
28
28
  shipment: shipment,
29
29
  )
30
30
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SolidusBacktracs
3
+ module SolidusBactracs
4
4
  module Shipment
5
5
  class BetweenQuery
6
6
  def self.apply(scope, from:, to:)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SolidusBacktracs
3
+ module SolidusBactracs
4
4
  module Shipment
5
5
  class ExportableQuery
6
6
  def self.apply(scope)
@@ -9,11 +9,11 @@ module SolidusBacktracs
9
9
  .joins(:order)
10
10
  .merge(::Spree::Order.complete)
11
11
 
12
- unless SolidusBacktracs.configuration.capture_at_notification
12
+ unless SolidusBactracs.configuration.capture_at_notification
13
13
  scope = scope.where(spree_shipments: { state: ['ready', 'canceled'] })
14
14
  end
15
15
 
16
- unless SolidusBacktracs.configuration.export_canceled_shipments
16
+ unless SolidusBactracs.configuration.export_canceled_shipments
17
17
  scope = scope.where.not(spree_shipments: { state: 'canceled' })
18
18
  end
19
19
 
@@ -1,23 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SolidusBacktracs
3
+ module SolidusBactracs
4
4
  module Shipment
5
5
  class PendingApiSyncQuery
6
6
  SQLITE_CONDITION = <<~SQL.squish
7
7
  (
8
- spree_shipments.backtracs_synced_at IS NULL
8
+ spree_shipments.bactracs_synced_at IS NULL
9
9
  ) AND ((JULIANDAY(CURRENT_TIMESTAMP) - JULIANDAY(spree_orders.updated_at)) * 86400.0) < :threshold
10
10
  SQL
11
11
 
12
12
  POSTGRES_CONDITION = <<~SQL.squish
13
13
  (
14
- spree_shipments.backtracs_synced_at IS NULL
14
+ spree_shipments.bactracs_synced_at IS NULL
15
15
  ) AND (EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - spree_orders.updated_at))) < :threshold
16
16
  SQL
17
17
 
18
18
  MYSQL2_CONDITION = <<~SQL.squish
19
19
  (
20
- spree_shipments.backtracs_synced_at IS NULL
20
+ spree_shipments.bactracs_synced_at IS NULL
21
21
  ) AND (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(spree_orders.updated_at)) < :threshold
22
22
  SQL
23
23
 
@@ -26,7 +26,7 @@ module SolidusBacktracs
26
26
  scope
27
27
  .joins(:order)
28
28
  .merge(::Spree::Order.complete)
29
- .where(condition_for_adapter, threshold: SolidusBacktracs.config.api_sync_threshold / 1.second)
29
+ .where(condition_for_adapter, threshold: SolidusBactracs.config.api_sync_threshold / 1.second)
30
30
  end
31
31
 
32
32
  private
@@ -42,7 +42,7 @@ module SolidusBacktracs
42
42
  when /mysql2/
43
43
  MYSQL2_CONDITION
44
44
  else
45
- fail "Backtracs API sync not supported for DB adapter #{db_adapter}!"
45
+ fail "Bactracs API sync not supported for DB adapter #{db_adapter}!"
46
46
  end
47
47
  end
48
48
  end
@@ -9,9 +9,9 @@ xml.Orders(pages: (@shipments.total_count / 50.0).ceil) {
9
9
  xml.Order {
10
10
  xml.OrderID shipment.id
11
11
  xml.OrderNumber shipment.number # do not use shipment.order.number as this presents lookup issues
12
- xml.OrderDate order.completed_at.strftime(SolidusBacktracs::ExportHelper::DATE_FORMAT)
12
+ xml.OrderDate order.completed_at.strftime(SolidusBactracs::ExportHelper::DATE_FORMAT)
13
13
  xml.OrderStatus shipment.state
14
- xml.LastModified [order.completed_at, shipment.updated_at].max.strftime(SolidusBacktracs::ExportHelper::DATE_FORMAT)
14
+ xml.LastModified [order.completed_at, shipment.updated_at].max.strftime(SolidusBactracs::ExportHelper::DATE_FORMAT)
15
15
  xml.ShippingMethod shipment.shipping_method.try(:name)
16
16
  xml.OrderTotal order.total
17
17
  xml.TaxAmount order.tax_total
@@ -25,8 +25,8 @@ xml.Orders(pages: (@shipments.total_count / 50.0).ceil) {
25
25
 
26
26
  xml.Customer {
27
27
  xml.CustomerCode order.email.slice(0, 50)
28
- SolidusBacktracs::ExportHelper.address(xml, order, :bill)
29
- SolidusBacktracs::ExportHelper.address(xml, order, :ship)
28
+ SolidusBactracs::ExportHelper.address(xml, order, :bill)
29
+ SolidusBactracs::ExportHelper.address(xml, order, :ship)
30
30
  }
31
31
  xml.Items {
32
32
  shipment.line_items.each do |line|
@@ -36,7 +36,7 @@ xml.Orders(pages: (@shipments.total_count / 50.0).ceil) {
36
36
  xml.Name [variant.product.name, variant.options_text].join(' ')
37
37
  xml.ImageUrl variant.images.first.try(:attachment).try(:url)
38
38
  xml.Weight variant.weight.to_f
39
- xml.WeightUnits SolidusBacktracs.configuration.weight_units
39
+ xml.WeightUnits SolidusBactracs.configuration.weight_units
40
40
  xml.Quantity line.quantity
41
41
  xml.UnitPrice line.price
42
42
 
data/bin/console CHANGED
@@ -3,7 +3,7 @@
3
3
  # frozen_string_literal: true
4
4
 
5
5
  require "bundler/setup"
6
- require "solidus_backtracs"
6
+ require "solidus_bactracs"
7
7
 
8
8
  # You can add fixtures and/or initialization code here to make experimenting
9
9
  # with your gem easier. You can also use a different console, if you like.
data/bin/rails-engine CHANGED
@@ -3,7 +3,7 @@
3
3
  # installed from the root of your application.
4
4
 
5
5
  ENGINE_ROOT = File.expand_path('..', __dir__)
6
- ENGINE_PATH = File.expand_path('../lib/solidus_backtracs/engine', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/solidus_bactracs/engine', __dir__)
7
7
 
8
8
  # Set up gems listed in the Gemfile.
9
9
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
data/bin/sandbox CHANGED
@@ -25,7 +25,7 @@ else
25
25
  BRANCH="master"
26
26
  fi
27
27
 
28
- extension_name="solidus_backtracs"
28
+ extension_name="solidus_bactracs"
29
29
 
30
30
  # Stay away from the bundler env of the containing extension.
31
31
  function unbundled {
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Spree::Core::Engine.routes.draw do
4
- # get '/backtracs', to: 'backtracs#export'
5
- # post '/backtracs', to: 'backtracs#shipnotify'
4
+ # get '/bactracs', to: 'bactracs#export'
5
+ # post '/bactracs', to: 'bactracs#shipnotify'
6
6
  end
@@ -1,8 +1,8 @@
1
1
  # NOTE: This migration is only required if you use the API integration strategy.
2
2
  # If you're using the XML file instead, you can safely skip these columns.
3
3
 
4
- class AddBacktracsApiSyncFields < ActiveRecord::Migration[5.2]
4
+ class AddBactracsApiSyncFields < ActiveRecord::Migration[5.2]
5
5
  def change
6
- add_column :spree_shipments, :backtracs_synced_at, :datetime
6
+ add_column :spree_shipments, :bactracs_synced_at, :datetime
7
7
  end
8
8
  end
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SolidusBacktracs
3
+ module SolidusBactracs
4
4
  module Generators
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
  class_option :auto_run_migrations, type: :boolean, default: false
7
7
  source_root File.expand_path('templates', __dir__)
8
8
 
9
9
  def copy_initializer
10
- template 'initializer.rb', 'config/initializers/solidus_backtracs.rb'
10
+ template 'initializer.rb', 'config/initializers/solidus_bactracs.rb'
11
11
  end
12
12
 
13
13
  def add_migrations
14
- run 'bin/rails railties:install:migrations FROM=solidus_backtracs'
14
+ run 'bin/rails railties:install:migrations FROM=solidus_bactracs'
15
15
  end
16
16
 
17
17
  def run_migrations