vertex_client 0.6.5 → 0.6.6
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 518b7b683046fdb177417cca3da6178ec857e6f9fe5c81f50561c342264bc2b8
|
|
4
|
+
data.tar.gz: 53a4a331a51c7abd3e6f0f8c450ae4b1cb2d14f38bb45c57a7a8d6f1be4ed589
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5b857fb79ef25f2d750b79e7dfa0ed17297e4a69e9febdf055a5f7e5459e6eeedb2be30e1845cbd8487c6bf35513a932beb6a50eac4bf4e74eaa7027f07c2e6d
|
|
7
|
+
data.tar.gz: a6828b54743e0f630ec6b3614a7a7eb25a84f7436d1550195bd2b8e812f1d94c70c8c17247ad322a3025e439fc031b76d33ed72bcc1f6fa73917c5f1d585368a
|
|
@@ -4,6 +4,30 @@ VertexClient.configure do |config|
|
|
|
4
4
|
config.trusted_id = ENV.fetch('VERTEX_TRUSTED_ID')
|
|
5
5
|
config.soap_api = ENV.fetch('VERTEX_SOAP_API')
|
|
6
6
|
|
|
7
|
+
# Global timeout options passed to Savon
|
|
8
|
+
config.read_timeout = 10
|
|
9
|
+
config.open_timeout = 10
|
|
10
|
+
|
|
11
|
+
# Per-resource timeout options
|
|
12
|
+
config.resource_config = {
|
|
13
|
+
quotation: {
|
|
14
|
+
read_timeout: 5,
|
|
15
|
+
open_timeout: 5
|
|
16
|
+
},
|
|
17
|
+
invoice: {
|
|
18
|
+
read_timeout: 300,
|
|
19
|
+
open_timeout: 300
|
|
20
|
+
},
|
|
21
|
+
distribute_tax: {
|
|
22
|
+
read_timeout: 300,
|
|
23
|
+
open_timeout: 300
|
|
24
|
+
},
|
|
25
|
+
tax_area: {
|
|
26
|
+
read_timeout: 5,
|
|
27
|
+
open_timeout: 5
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
7
31
|
# Circuitbox configuration.
|
|
8
32
|
# https://github.com/yammer/circuitbox#per-circuit-configuration
|
|
9
33
|
# config.circuit_config = {
|
|
@@ -13,7 +13,8 @@ module VertexClient
|
|
|
13
13
|
]
|
|
14
14
|
}.freeze
|
|
15
15
|
|
|
16
|
-
attr_accessor :trusted_id, :soap_api, :circuit_config
|
|
16
|
+
attr_accessor :trusted_id, :soap_api, :circuit_config, :open_timeout,
|
|
17
|
+
:read_timeout, :resource_config
|
|
17
18
|
|
|
18
19
|
def initialize
|
|
19
20
|
@trusted_id = ENV['VERTEX_TRUSTED_ID']
|
|
@@ -28,6 +29,10 @@ module VertexClient
|
|
|
28
29
|
@soap_api.gsub(/\/+$/ ,'') + '/'
|
|
29
30
|
end
|
|
30
31
|
|
|
32
|
+
def resource_config
|
|
33
|
+
@resource_config || {}
|
|
34
|
+
end
|
|
35
|
+
|
|
31
36
|
def fallback_rates
|
|
32
37
|
RATES
|
|
33
38
|
end
|
|
@@ -4,8 +4,9 @@ module VertexClient
|
|
|
4
4
|
VERTEX_NAMESPACE = 'urn:vertexinc:o-series:tps:7:0'.freeze
|
|
5
5
|
ERROR_MESSAGE = 'The Vertex API returned an error or is unavailable'.freeze
|
|
6
6
|
|
|
7
|
-
def initialize(endpoint)
|
|
7
|
+
def initialize(endpoint, resource_key=nil)
|
|
8
8
|
@endpoint = endpoint
|
|
9
|
+
@resource_key = resource_key
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def request(payload)
|
|
@@ -24,14 +25,20 @@ module VertexClient
|
|
|
24
25
|
globals.convert_request_keys_to :camelcase
|
|
25
26
|
globals.env_namespace :soapenv
|
|
26
27
|
globals.namespace_identifier :urn
|
|
28
|
+
globals.open_timeout open_timeout if open_timeout.present?
|
|
29
|
+
globals.read_timeout read_timeout if read_timeout.present?
|
|
27
30
|
end
|
|
28
31
|
end
|
|
29
32
|
|
|
33
|
+
private
|
|
34
|
+
|
|
30
35
|
def config
|
|
31
36
|
@config ||= VertexClient.configuration
|
|
32
37
|
end
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
def resource_config
|
|
40
|
+
config.resource_config[@resource_key] || {}
|
|
41
|
+
end
|
|
35
42
|
|
|
36
43
|
def call_with_circuit_if_available
|
|
37
44
|
if VertexClient.circuit
|
|
@@ -54,5 +61,13 @@ module VertexClient
|
|
|
54
61
|
def clean_endpoint
|
|
55
62
|
URI.join(config.soap_api, @endpoint).to_s
|
|
56
63
|
end
|
|
64
|
+
|
|
65
|
+
def read_timeout
|
|
66
|
+
resource_config[:read_timeout] || config.read_timeout
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def open_timeout
|
|
70
|
+
resource_config[:open_timeout] || config.open_timeout
|
|
71
|
+
end
|
|
57
72
|
end
|
|
58
73
|
end
|
|
@@ -11,6 +11,10 @@ module VertexClient
|
|
|
11
11
|
@result ||= (response ? formatted_response : fallback_response)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def config_key
|
|
15
|
+
demodulized_class_name.underscore.to_sym
|
|
16
|
+
end
|
|
17
|
+
|
|
14
18
|
private
|
|
15
19
|
|
|
16
20
|
def response
|
|
@@ -18,7 +22,7 @@ module VertexClient
|
|
|
18
22
|
end
|
|
19
23
|
|
|
20
24
|
def connection
|
|
21
|
-
@connection ||= Connection.new(self.class::ENDPOINT)
|
|
25
|
+
@connection ||= Connection.new(self.class::ENDPOINT, config_key)
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
def formatted_response
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vertex_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Custom Ink
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-04-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|