solidus_backtracs 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a599802f23077392477db03b1e36eecf30633ef3b5892b85a35304d15b061fe3
4
- data.tar.gz: cc197de83a593fbdd81872c61e27a69cc9a09ddf3ba359407e823caad22cc102
3
+ metadata.gz: d58f212b33488781331c666724e857474d6c60852d8acc845990b380c6727611
4
+ data.tar.gz: '09aacc1386429a22c7b953a7d09e192799fa8901c4a9b1fa26bb6fa9e744d995'
5
5
  SHA512:
6
- metadata.gz: 5ddd0296522fa664cd9e92229438f25fa38698dfa9fa66316311b41b49d40bfc2a92bb7507a32d5789b5978ae71b71f3ac75c03f07c6ea657c440d8e960473fc
7
- data.tar.gz: 60781ae6012c98e4a88d440e9d7faba29eb2f05b51106da5c3883fe8b12fe6616b4cd4260bc1ffc3a685221ed03d4c07c2b174befec222e999caf84c9287bba9
6
+ metadata.gz: d2b077b182bb182625eaa55567353d78c250e24f322dac1a6f31bad0ec262c5c5c8952a890b75914e212f55ae42f4a12b1fd19eddd9af0968a82fd3f986bddc2
7
+ data.tar.gz: bcf82e512fae4a40bc721aa7811440922815e0488feab5096d15e1a0da3c075935fb5a7e411b39a5e83ec9f44c048b1564028ec69aac6ac33456083899aaf366
data/CHANGELOG.md CHANGED
@@ -1,2 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2.0
4
+
5
+ Support the Solidus Assembly gem, consider allowed SKUs within assemblies/bundles
6
+ Retry logic for the authenticated request
7
+
8
+ ## 2.1.0
9
+
10
+ New auth and API patterns for Backtracs
11
+ Support specific SKUs to be mapped
12
+
13
+ ## 2.0.0
14
+
15
+ Diverged the gem from Shipstation to the Bactracs API
16
+
@@ -11,6 +11,7 @@ SolidusBacktracs.configure do |config|
11
11
 
12
12
  ## API Configuration
13
13
  config.api_base = ENV['BACKTRACS_API_BASE'] || 'https://bactracstest.andlor.com'
14
+ config.api_retries = ENV['BACKTRACS_API_RETRIES'] || 3
14
15
 
15
16
  # Backtracs expects the endpoint to be protected by HTTP Basic Auth.
16
17
  # Set the username and password you desire for Backtracs to use.
@@ -32,7 +33,7 @@ SolidusBacktracs.configure do |config|
32
33
  config.sku_map = {}
33
34
  config.default_rma_type = "W"
34
35
  config.default_carrier = "FedExGrnd"
35
- config.default_ship_method = "GROUND"
36
+ config.default_ship_method = "GROUND"
36
37
  config.default_status = "OPEN"
37
38
  config.default_rp_location = "FG-NEW"
38
39
  config.shippable_skus = []
@@ -10,27 +10,41 @@ module SolidusBacktracs
10
10
  @username = SolidusBacktracs.configuration.authentication_username
11
11
  @password = SolidusBacktracs.configuration.authentication_password
12
12
  @api_base = SolidusBacktracs.configuration.api_base
13
+ @retries = SolidusBacktracs.configuration.api_retries
13
14
  end
14
15
 
15
- def authenticated_call(method: nil, path: nil, serializer: nil, shipment: nil)
16
- unless @username.present? || @password.present? || @api_base.present?
17
- raise "Credentials not defined for Authentication"
18
- end
16
+ def authenticated_call(method: nil, path: nil, serializer: nil, shipment: nil, count: 0)
17
+ if count <= @retries
18
+ unless @username.present? || @password.present? || @api_base.present?
19
+ raise "Credentials not defined for Authentication"
20
+ end
19
21
 
20
- Rails.cache.fetch("backtracks_cache_key", expires_in: 1.hour) do
21
- @response = self.call(method: :get, path: "/webservices/user/Authentication.asmx/Login?sUserName=#{@username}&sPassword=#{@password}")
22
- end
23
-
24
- authenticted = parse_authentication_response(@response, "Result")
22
+ @response = Rails.cache.fetch("backtracks_cache_key", expires_in: 1.hour, skip_nil: true) do
23
+ self.call(method: :get, path: "/webservices/user/Authentication.asmx/Login?sUserName=#{@username}&sPassword=#{@password}")
24
+ end
25
25
 
26
- if authenticted == 'false'
27
- raise RequestError.from_response(@response)
28
- else
26
+ raise RequestError.from_response(@response) unless @response # just try again for @retries?
27
+ authenticted = parse_authentication_response(@response, "Result")
28
+ raise RequestError.from_response(@response) if authenticted == "false"
29
29
  sguid = parse_authentication_response(@response, "Message")
30
- params = serializer.call(shipment, sguid)
31
30
 
32
- rma_response = call(method: :post, path: path, params: params)
33
- sync_shipment(shipment, rma_response)
31
+ if authenticted == 'false'
32
+ clear_cache
33
+ raise "User Not Authenticated"
34
+ else
35
+ sguid = parse_authentication_response(@response, "Message")
36
+ params = serializer.call(shipment, sguid)
37
+
38
+ rma_response = call(method: :post, path: path, params: params)
39
+ unless parse_rma_creation_response(rma_response) == 'true'
40
+ clear_cache
41
+ count += 1
42
+ self.authenticated_call(method: :post, path: '/webservices/rma/rmaservice.asmx', serializer: serializer, shipment: shipment, count: count)
43
+ end
44
+ shipment_synced(shipment)
45
+ end
46
+ else
47
+ shipment_sync_failed(shipment)
34
48
  end
35
49
  end
36
50
 
@@ -62,25 +76,33 @@ module SolidusBacktracs
62
76
  end
63
77
  end
64
78
 
79
+ def clear_cache
80
+ Rails.cache.delete('backtracks_cache_key')
81
+ @response = nil
82
+ end
83
+
65
84
  def parse_authentication_response(response, type)
66
85
  response.dig("AuthenticationResponse", type)
67
86
  end
68
87
 
69
- def sync_shipment(shipment, response)
70
- result = response.dig("Envelope", "Body", "CreateNewResponse", "CreateNewResult", "Result")
71
- if result == 'true'
72
- shipment.update_column(:backtracs_synced_at, Time.zone.now)
88
+ def parse_rma_creation_response(response)
89
+ response.dig("Envelope", "Body", "CreateNewResponse", "CreateNewResult", "Result")
90
+ end
73
91
 
74
- ::Spree::Event.fire(
75
- 'solidus_backtracs.api.sync_completed',
76
- shipment: shipment
77
- )
78
- else
79
- ::Spree::Event.fire(
80
- 'solidus_backtracs.api.sync_failed',
81
- shipment: shipment
82
- )
83
- end
92
+ def shipment_synced(shipment)
93
+ shipment.update_column(:backtracs_synced_at, Time.zone.now)
94
+
95
+ ::Spree::Event.fire(
96
+ 'solidus_backtracs.api.sync_completed',
97
+ shipment: shipment
98
+ )
99
+ end
100
+
101
+ def shipment_sync_failed(shipment)
102
+ ::Spree::Event.fire(
103
+ 'solidus_backtracs.api.sync_failed',
104
+ shipment: shipment
105
+ )
84
106
  end
85
107
  end
86
108
  end
@@ -19,7 +19,8 @@ module SolidusBacktracs
19
19
  :shipment_notice_class,
20
20
  :authentication_username,
21
21
  :authentication_password,
22
- :api_base,
22
+ :api_base,
23
+ :api_retries,
23
24
  :proxy_address,
24
25
  :proxy_port,
25
26
  :proxy_username,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBacktracs
4
- VERSION = '2.2.1'
4
+ VERSION = '2.2.2'
5
5
  end
@@ -9,12 +9,12 @@ Gem::Specification.new do |spec|
9
9
  spec.email = 'zkhan@suvie.com'
10
10
 
11
11
  spec.summary = 'A Solidus extension for integrating the Backtracs API.'
12
- spec.homepage = 'https://github.com/solidusio-contrib/solidus_backtracs'
12
+ spec.homepage = 'https://github.com/suvie-eng/solidus_backtracs'
13
13
  spec.license = 'BSD-3-Clause'
14
14
 
15
15
  spec.metadata['homepage_uri'] = spec.homepage
16
- spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_backtracs'
17
- spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_backtracs/blob/master/CHANGELOG.md'
16
+ spec.metadata['source_code_uri'] = 'https://github.com/suvie-eng/solidus_backtracs/'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/suvie-eng/solidus_backtracs/blob/master/CHANGELOG.md'
18
18
 
19
19
  spec.required_ruby_version = Gem::Requirement.new('>= 2.5')
20
20
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_backtracs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeryab Ali
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-13 00:00:00.000000000 Z
11
+ date: 2022-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -174,7 +174,7 @@ files:
174
174
  - lib/solidus_backtracs/shipment_notice.rb
175
175
  - lib/solidus_backtracs/testing_support/factories.rb
176
176
  - lib/solidus_backtracs/version.rb
177
- - solidus_shipstation.gemspec
177
+ - solidus_bactracs.gemspec
178
178
  - spec/controllers/spree/backtracs_controller_spec.rb
179
179
  - spec/fixtures/backtracs_xml_schema.xsd
180
180
  - spec/jobs/solidus_backtracs/api/schedule_shipment_syncs_job_spec.rb
@@ -197,13 +197,13 @@ files:
197
197
  - spec/support/controllers.rb
198
198
  - spec/support/webmock.rb
199
199
  - spec/support/xsd.rb
200
- homepage: https://github.com/solidusio-contrib/solidus_backtracs
200
+ homepage: https://github.com/suvie-eng/solidus_backtracs
201
201
  licenses:
202
202
  - BSD-3-Clause
203
203
  metadata:
204
- homepage_uri: https://github.com/solidusio-contrib/solidus_backtracs
205
- source_code_uri: https://github.com/solidusio-contrib/solidus_backtracs
206
- changelog_uri: https://github.com/solidusio-contrib/solidus_backtracs/blob/master/CHANGELOG.md
204
+ homepage_uri: https://github.com/suvie-eng/solidus_backtracs
205
+ source_code_uri: https://github.com/suvie-eng/solidus_backtracs/
206
+ changelog_uri: https://github.com/suvie-eng/solidus_backtracs/blob/master/CHANGELOG.md
207
207
  post_install_message:
208
208
  rdoc_options: []
209
209
  require_paths: