avatax 18.4.0 → 18.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: add871ab3afdc0119f99b02c044b02bd8225ecf932a5b6d03a05dca34b634c42
4
- data.tar.gz: 81010bad716cfc21394149b55922060a35a17d1246e330c489a66bac65678c96
3
+ metadata.gz: 5c682c2d510ba0f739f3528ea2e37581b8c00e0150ca278f8fac37b612e88bc0
4
+ data.tar.gz: 45b64370a02b2f67278a300f057730b674e372da22ffbd2cf9605a13eb68f70e
5
5
  SHA512:
6
- metadata.gz: 5d017ab32652887888d279f02ff25b4dff502c0c37d5d94baf43c9cd48d0a8b9473a6e094e44d418bed5202bb348cc7a214c7d39724576bee5d8849b1f7e83ee
7
- data.tar.gz: 5c56513540926d23b348b4f3c3e7a861c0f23a3403f21523ff5e76d1f93bebd5f1f92d197d60801a9db1549783540ca246ab6089553bd034a0150282f798aab6
6
+ metadata.gz: bcf764f94c7845a671f54e271098edac1630ddd1f1defcb3f6ef4e86fbdb5b305216cdadbaa107fa754d1b9bb5d450ad5893dfd8a1885393786c1bf45d3e562b
7
+ data.tar.gz: 33088610c8a59d0b8b77ead54972f4073c1f29724cb523ae17c2e557c5f8458c64185711113cbcad86bc3a6ba58f7aae6e44d433c4d458050e157cfa577e364b
@@ -18,11 +18,11 @@ end
18
18
 
19
19
  @client = AvaTax::Client.new(:logger => true)
20
20
 
21
- #puts @client.query_companies
21
+ # puts @client.query_companies
22
22
 
23
23
  createTransactionModel = {
24
24
  type: 'SalesInvoice',
25
- companyCode: 'DEFAULT',
25
+ companyCode: '12670',
26
26
  date: '2017-06-05',
27
27
  customerCode: 'ABC',
28
28
  "addresses": {
@@ -44,4 +44,4 @@ createTransactionModel = {
44
44
  lines: [{amount: 100}]
45
45
  }
46
46
  transaction = @client.create_transaction(createTransactionModel)
47
- puts transaction
47
+ puts JSON.pretty_generate(transaction)
@@ -15,7 +15,11 @@ module AvaTax
15
15
  :password,
16
16
  :connection_options,
17
17
  :logger,
18
+ :custom_logger,
19
+ :custom_logger_options,
18
20
  :proxy,
21
+ :faraday_response,
22
+ :response_big_decimal_conversion
19
23
  ].freeze
20
24
 
21
25
  DEFAULT_APP_NAME = nil
@@ -27,7 +31,11 @@ module AvaTax
27
31
  DEFAULT_PASSWORD = nil
28
32
  DEFAULT_CONNECTION_OPTIONS = {}
29
33
  DEFAULT_LOGGER = false
34
+ DEFAULT_CUSTOM_LOGGER = nil
35
+ DEFAULT_CUSTOM_LOGGER_OPTIONS = {}
30
36
  DEFAULT_PROXY = nil
37
+ DEFAULT_FARADAY_RESPONSE = false
38
+ DEFAULT_RESPONSE_BIG_DECIMAL_CONVERSION = false
31
39
 
32
40
  attr_accessor *VALID_OPTIONS_KEYS
33
41
 
@@ -57,7 +65,11 @@ module AvaTax
57
65
  self.password = DEFAULT_PASSWORD
58
66
  self.connection_options = DEFAULT_CONNECTION_OPTIONS
59
67
  self.logger = DEFAULT_LOGGER
68
+ self.custom_logger = DEFAULT_CUSTOM_LOGGER
69
+ self.custom_logger_options = DEFAULT_CUSTOM_LOGGER_OPTIONS
60
70
  self.proxy = DEFAULT_PROXY
71
+ self.faraday_response = DEFAULT_FARADAY_RESPONSE
72
+ self.response_big_decimal_conversion = DEFAULT_RESPONSE_BIG_DECIMAL_CONVERSION
61
73
  end
62
74
 
63
75
  end
@@ -4,6 +4,8 @@ module AvaTax
4
4
 
5
5
  module Connection
6
6
  private
7
+ AUTHORIZATION_FILTER_REGEX = /(Authorization\:\ \"Basic\ )(\w+)\=/
8
+ REMOVED_LABEL = '\1[REMOVED]'
7
9
 
8
10
  def connection
9
11
  client_id = "#{app_name};#{app_version};RubySdk;#{AvaTax::VERSION.dup};#{machine_name}"
@@ -19,7 +21,7 @@ module AvaTax
19
21
  }.merge(connection_options)
20
22
 
21
23
  Faraday.new(options) do |faraday|
22
- if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.2.2')
24
+ if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.2.2') and response_big_decimal_conversion
23
25
  Oj.default_options = {
24
26
  bigdecimal_load: :bigdecimal
25
27
  }
@@ -30,7 +32,13 @@ module AvaTax
30
32
 
31
33
  if logger
32
34
  faraday.response :logger do |logger|
33
- logger.filter(/(Authorization\:\ \"Basic\ )(\w+)\=/, '\1[REMOVED]')
35
+ logger.filter(AUTHORIZATION_FILTER_REGEX, REMOVED_LABEL)
36
+ end
37
+ end
38
+
39
+ if custom_logger
40
+ faraday.response :logger, custom_logger, custom_logger_options do |logger|
41
+ logger.filter(AUTHORIZATION_FILTER_REGEX, REMOVED_LABEL)
34
42
  end
35
43
  end
36
44
 
@@ -1,4 +1,5 @@
1
1
  require 'hashie'
2
+ require 'faraday'
2
3
  require 'json'
3
4
 
4
5
  module AvaTax
@@ -32,9 +33,11 @@ module AvaTax
32
33
  end
33
34
  end
34
35
 
35
- #::Hashie::Mash.new response.body
36
- response.body
36
+ if faraday_response
37
+ response
38
+ else
39
+ response.body
40
+ end
37
41
  end
38
-
39
42
  end
40
43
  end
@@ -1,3 +1,3 @@
1
1
  module AvaTax
2
- VERSION = '18.4.0'.freeze unless defined?(::AvaTax::VERSION)
2
+ VERSION = '18.4.1'.freeze unless defined?(::AvaTax::VERSION)
3
3
  end
@@ -37,4 +37,44 @@ describe AvaTax::Client do
37
37
  end
38
38
 
39
39
  end
40
+
41
+
42
+ # Test the option of faraday_response, the returned response should be a type of Faraday response rather than Hashie
43
+ describe ".transaction_with_faraday_response" do
44
+ before do
45
+ @client.faraday_response = true
46
+ @base_transaction = {
47
+ type: 'SalesInvoice',
48
+ companyCode: @company_code,
49
+ date: '2017-06-05',
50
+ customerCode: 'ABC',
51
+ addresses: {
52
+ ShipFrom: {
53
+ line1: "123 Main Street",
54
+ city: "Irvine",
55
+ region: "CA",
56
+ country: "US",
57
+ postalCode: "92615"
58
+ },
59
+ ShipTo: {
60
+ line1: "100 Market Street",
61
+ city: "San Francisco",
62
+ region: "CA",
63
+ country: "US",
64
+ postalCode: "94105"
65
+ }
66
+ },
67
+ lines: [{amount: 100}]
68
+ }
69
+ end
70
+
71
+ it "should create a transaction and return the faraday response" do
72
+ faraday_trans = @client.create_transaction(@base_transaction)
73
+ expect(faraday_trans).to be_a Object
74
+ expect(faraday_trans["status"]) == 201
75
+ expect(faraday_trans["reason_phrase"]) == "Created"
76
+ expect(faraday_trans["request_headers"]).to be_a Object
77
+ expect(faraday_trans["body"]).to be_a Object
78
+ end
79
+ end
40
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avatax
3
3
  version: !ruby/object:Gem::Version
4
- version: 18.4.0
4
+ version: 18.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Vorwaller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-23 00:00:00.000000000 Z
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake