solidus_backtracs 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/generators/solidus_backtracs/install/templates/initializer.rb +2 -1
- data/lib/solidus_backtracs/api/request_runner.rb +51 -29
- data/lib/solidus_backtracs/configuration.rb +2 -1
- data/lib/solidus_backtracs/version.rb +1 -1
- data/{solidus_shipstation.gemspec → solidus_bactracs.gemspec} +3 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d58f212b33488781331c666724e857474d6c60852d8acc845990b380c6727611
|
4
|
+
data.tar.gz: '09aacc1386429a22c7b953a7d09e192799fa8901c4a9b1fa26bb6fa9e744d995'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
33
|
-
|
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
|
70
|
-
|
71
|
-
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
@@ -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/
|
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/
|
17
|
-
spec.metadata['changelog_uri'] = 'https://github.com/
|
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.
|
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-
|
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
|
-
-
|
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/
|
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/
|
205
|
-
source_code_uri: https://github.com/
|
206
|
-
changelog_uri: https://github.com/
|
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:
|