avatax 21.12.0 → 22.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +55 -55
- data/.rspec +1 -1
- data/.travis.yml +18 -18
- data/.vs/VSWorkspaceState.json +5 -5
- data/.yardopts +4 -4
- data/Gemfile +2 -2
- data/LICENSE +201 -201
- data/README.md +98 -98
- data/Rakefile +9 -9
- data/avatax.gemspec +38 -38
- data/example/avatax.rb +47 -47
- data/example/credentials.example.yaml +5 -5
- data/lib/avatax/api.rb +27 -27
- data/lib/avatax/client/accounts.rb +11 -11
- data/lib/avatax/client/addresses.rb +2 -2
- data/lib/avatax/client/advancedrules.rb +5 -5
- data/lib/avatax/client/avafileforms.rb +5 -5
- data/lib/avatax/client/batches.rb +8 -8
- data/lib/avatax/client/certexpressinvites.rb +3 -3
- data/lib/avatax/client/certificates.rb +15 -15
- data/lib/avatax/client/companies.rb +40 -21
- data/lib/avatax/client/compliance.rb +1 -1
- data/lib/avatax/client/contacts.rb +6 -6
- data/lib/avatax/client/customers.rb +13 -13
- data/lib/avatax/client/datasources.rb +6 -6
- data/lib/avatax/client/definitions.rb +70 -70
- data/lib/avatax/client/distancethresholds.rb +6 -6
- data/lib/avatax/client/ecms.rb +73 -73
- data/lib/avatax/client/ecommercetoken.rb +2 -2
- data/lib/avatax/client/errortransactions.rb +61 -61
- data/lib/avatax/client/filingcalendars.rb +3 -3
- data/lib/avatax/client/filings.rb +2 -2
- data/lib/avatax/client/firmclientlinkages.rb +9 -9
- data/lib/avatax/client/free.rb +1 -1
- data/lib/avatax/client/fundingrequests.rb +2 -2
- data/lib/avatax/client/items.rb +25 -25
- data/lib/avatax/client/jurisdictionoverrides.rb +6 -6
- data/lib/avatax/client/locations.rb +12 -12
- data/lib/avatax/client/multidocument.rb +10 -10
- data/lib/avatax/client/nexus.rb +15 -15
- data/lib/avatax/client/notices.rb +4 -4
- data/lib/avatax/client/notifications.rb +3 -3
- data/lib/avatax/client/onboarding.rb +55 -55
- data/lib/avatax/client/pointofsale.rb +21 -21
- data/lib/avatax/client/provisioning.rb +2 -2
- data/lib/avatax/client/registrar.rb +11 -11
- data/lib/avatax/client/reports.rb +4 -4
- data/lib/avatax/client/settings.rb +6 -6
- data/lib/avatax/client/subscriptions.rb +3 -3
- data/lib/avatax/client/taxcodes.rb +6 -6
- data/lib/avatax/client/taxcontent.rb +5 -5
- data/lib/avatax/client/taxprofiles.rb +42 -42
- data/lib/avatax/client/taxrules.rb +6 -6
- data/lib/avatax/client/transactions.rb +21 -21
- data/lib/avatax/client/upcs.rb +6 -6
- data/lib/avatax/client/userdefinedfields.rb +3 -3
- data/lib/avatax/client/users.rb +8 -8
- data/lib/avatax/client/utilities.rb +3 -3
- data/lib/avatax/client.rb +37 -37
- data/lib/avatax/configuration.rb +76 -76
- data/lib/avatax/connection.rb +49 -49
- data/lib/avatax/request.rb +50 -50
- data/lib/avatax/version.rb +3 -3
- data/lib/avatax.rb +26 -26
- data/spec/avatax/client/accounts_spec.rb +13 -13
- data/spec/avatax/client/transactions_spec.rb +80 -80
- data/spec/avatax/request_spec.rb +25 -25
- data/spec/avatax_spec.rb +45 -45
- data/spec/credentials.yaml.example +4 -4
- data/spec/fixtures/accounts.json +15 -15
- data/spec/spec_helper.rb +27 -27
- metadata +6 -13
data/lib/avatax/connection.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
require 'faraday_middleware'
|
2
|
-
|
3
|
-
module AvaTax
|
4
|
-
|
5
|
-
module Connection
|
6
|
-
private
|
7
|
-
AUTHORIZATION_FILTER_REGEX = /(Authorization\:\ \"Basic\ )(\w+)\=/
|
8
|
-
REMOVED_LABEL = '\1[REMOVED]'
|
9
|
-
|
10
|
-
def connection
|
11
|
-
client_id = "#{app_name};#{app_version};RubySdk;API_VERSION;#{machine_name}"
|
12
|
-
options = {
|
13
|
-
:headers =>
|
14
|
-
{
|
15
|
-
'Accept' => "application/json; charset=utf-8",
|
16
|
-
'User-Agent' => user_agent,
|
17
|
-
'X-Avalara-Client' => client_id
|
18
|
-
},
|
19
|
-
:url => endpoint,
|
20
|
-
:proxy => proxy
|
21
|
-
}.merge(connection_options)
|
22
|
-
|
23
|
-
Faraday.new(options) do |faraday|
|
24
|
-
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.2.2') and response_big_decimal_conversion
|
25
|
-
Oj.default_options = {
|
26
|
-
bigdecimal_load: :bigdecimal
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
faraday.response :json, content_type: /\bjson$/
|
31
|
-
faraday.basic_auth(username, password)
|
32
|
-
|
33
|
-
if logger
|
34
|
-
faraday.response :logger do |logger|
|
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)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
faraday.adapter Faraday.default_adapter
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
1
|
+
require 'faraday_middleware'
|
2
|
+
|
3
|
+
module AvaTax
|
4
|
+
|
5
|
+
module Connection
|
6
|
+
private
|
7
|
+
AUTHORIZATION_FILTER_REGEX = /(Authorization\:\ \"Basic\ )(\w+)\=/
|
8
|
+
REMOVED_LABEL = '\1[REMOVED]'
|
9
|
+
|
10
|
+
def connection
|
11
|
+
client_id = "#{app_name};#{app_version};RubySdk;API_VERSION;#{machine_name}"
|
12
|
+
options = {
|
13
|
+
:headers =>
|
14
|
+
{
|
15
|
+
'Accept' => "application/json; charset=utf-8",
|
16
|
+
'User-Agent' => user_agent,
|
17
|
+
'X-Avalara-Client' => client_id
|
18
|
+
},
|
19
|
+
:url => endpoint,
|
20
|
+
:proxy => proxy
|
21
|
+
}.merge(connection_options)
|
22
|
+
|
23
|
+
Faraday.new(options) do |faraday|
|
24
|
+
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.2.2') and response_big_decimal_conversion
|
25
|
+
Oj.default_options = {
|
26
|
+
bigdecimal_load: :bigdecimal
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
faraday.response :json, content_type: /\bjson$/
|
31
|
+
faraday.basic_auth(username, password)
|
32
|
+
|
33
|
+
if logger
|
34
|
+
faraday.response :logger do |logger|
|
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)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
faraday.adapter Faraday.default_adapter
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/avatax/request.rb
CHANGED
@@ -1,51 +1,51 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'json'
|
3
|
-
require "erb"
|
4
|
-
|
5
|
-
|
6
|
-
module AvaTax
|
7
|
-
module Request
|
8
|
-
|
9
|
-
def get(path, options={}, apiversion="")
|
10
|
-
request(:get, path, nil, options, apiversion)
|
11
|
-
end
|
12
|
-
|
13
|
-
def post(path, model, options={}, apiversion="")
|
14
|
-
request(:post, path, model, options, apiversion)
|
15
|
-
end
|
16
|
-
|
17
|
-
def put(path, model, options={}, apiversion="")
|
18
|
-
request(:put, path, model, options, apiversion)
|
19
|
-
end
|
20
|
-
|
21
|
-
def delete(path, options={}, apiversion="")
|
22
|
-
request(:delete, path, nil, options, apiversion)
|
23
|
-
end
|
24
|
-
|
25
|
-
def request(method, path, model, options={}, apiversion="")
|
26
|
-
response = connection.send(method) do |request|
|
27
|
-
request.headers['X-Avalara-Client'] = request.headers['X-Avalara-Client'].gsub("API_VERSION", apiversion)
|
28
|
-
case method
|
29
|
-
when :get, :delete
|
30
|
-
request.url("#{encode_path(path)}?#{URI.encode_www_form(options)}")
|
31
|
-
when :post, :put
|
32
|
-
request.url("#{encode_path(path)}?#{URI.encode_www_form(options)}")
|
33
|
-
request.headers['Content-Type'] = 'application/json'
|
34
|
-
request.body = model.to_json unless model.empty?
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
if faraday_response
|
39
|
-
response
|
40
|
-
else
|
41
|
-
response.body
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def encode_path(path)
|
48
|
-
path.split('/').map { |part| ERB::Util.url_encode(part) }.join('/')
|
49
|
-
end
|
50
|
-
end
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
require "erb"
|
4
|
+
|
5
|
+
|
6
|
+
module AvaTax
|
7
|
+
module Request
|
8
|
+
|
9
|
+
def get(path, options={}, apiversion="")
|
10
|
+
request(:get, path, nil, options, apiversion)
|
11
|
+
end
|
12
|
+
|
13
|
+
def post(path, model, options={}, apiversion="")
|
14
|
+
request(:post, path, model, options, apiversion)
|
15
|
+
end
|
16
|
+
|
17
|
+
def put(path, model, options={}, apiversion="")
|
18
|
+
request(:put, path, model, options, apiversion)
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(path, options={}, apiversion="")
|
22
|
+
request(:delete, path, nil, options, apiversion)
|
23
|
+
end
|
24
|
+
|
25
|
+
def request(method, path, model, options={}, apiversion="")
|
26
|
+
response = connection.send(method) do |request|
|
27
|
+
request.headers['X-Avalara-Client'] = request.headers['X-Avalara-Client'].gsub("API_VERSION", apiversion)
|
28
|
+
case method
|
29
|
+
when :get, :delete
|
30
|
+
request.url("#{encode_path(path)}?#{URI.encode_www_form(options)}")
|
31
|
+
when :post, :put
|
32
|
+
request.url("#{encode_path(path)}?#{URI.encode_www_form(options)}")
|
33
|
+
request.headers['Content-Type'] = 'application/json'
|
34
|
+
request.body = model.to_json unless model.empty?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
if faraday_response
|
39
|
+
response
|
40
|
+
else
|
41
|
+
response.body
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def encode_path(path)
|
48
|
+
path.split('/').map { |part| ERB::Util.url_encode(part) }.join('/')
|
49
|
+
end
|
50
|
+
end
|
51
51
|
end
|
data/lib/avatax/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module AvaTax
|
2
|
-
VERSION = '
|
3
|
-
end
|
1
|
+
module AvaTax
|
2
|
+
VERSION = '22.2.0'.freeze unless defined?(::AvaTax::VERSION)
|
3
|
+
end
|
data/lib/avatax.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
require File.expand_path('../avatax/configuration', __FILE__)
|
2
|
-
require File.expand_path('../avatax/api', __FILE__)
|
3
|
-
require File.expand_path('../avatax/client', __FILE__)
|
4
|
-
|
5
|
-
module AvaTax
|
6
|
-
extend Configuration
|
7
|
-
|
8
|
-
# Alias for Avatax::Client.new
|
9
|
-
#
|
10
|
-
# @return [Avatax::Client]
|
11
|
-
def self.client(options={})
|
12
|
-
AvaTax::Client.new(options)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Delegate to AvaTax::Client
|
16
|
-
def self.method_missing(method, *args, &block)
|
17
|
-
return super unless client.respond_to?(method)
|
18
|
-
client.send(method, *args, &block)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Delegate to AvaTax::Client
|
22
|
-
def self.respond_to?(method, include_all=false)
|
23
|
-
return client.respond_to?(method, include_all) || super
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
1
|
+
require File.expand_path('../avatax/configuration', __FILE__)
|
2
|
+
require File.expand_path('../avatax/api', __FILE__)
|
3
|
+
require File.expand_path('../avatax/client', __FILE__)
|
4
|
+
|
5
|
+
module AvaTax
|
6
|
+
extend Configuration
|
7
|
+
|
8
|
+
# Alias for Avatax::Client.new
|
9
|
+
#
|
10
|
+
# @return [Avatax::Client]
|
11
|
+
def self.client(options={})
|
12
|
+
AvaTax::Client.new(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Delegate to AvaTax::Client
|
16
|
+
def self.method_missing(method, *args, &block)
|
17
|
+
return super unless client.respond_to?(method)
|
18
|
+
client.send(method, *args, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Delegate to AvaTax::Client
|
22
|
+
def self.respond_to?(method, include_all=false)
|
23
|
+
return client.respond_to?(method, include_all) || super
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe AvaTax::Client do
|
4
|
-
|
5
|
-
describe ".accounts" do
|
6
|
-
it "should return an array of accounts" do
|
7
|
-
accounts = @client.query_accounts
|
8
|
-
expect(accounts).to be_a Object
|
9
|
-
expect(accounts['value'].first['id']).to be_a Integer
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe AvaTax::Client do
|
4
|
+
|
5
|
+
describe ".accounts" do
|
6
|
+
it "should return an array of accounts" do
|
7
|
+
accounts = @client.query_accounts
|
8
|
+
expect(accounts).to be_a Object
|
9
|
+
expect(accounts['value'].first['id']).to be_a Integer
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -1,80 +1,80 @@
|
|
1
|
-
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe AvaTax::Client do
|
4
|
-
|
5
|
-
describe ".transactions" do
|
6
|
-
before do
|
7
|
-
@base_transaction = {
|
8
|
-
type: 'SalesInvoice',
|
9
|
-
companyCode: @company_code,
|
10
|
-
date: '2017-06-05',
|
11
|
-
customerCode: 'ABC',
|
12
|
-
addresses: {
|
13
|
-
ShipFrom: {
|
14
|
-
line1: "123 Main Street",
|
15
|
-
city: "Irvine",
|
16
|
-
region: "CA",
|
17
|
-
country: "US",
|
18
|
-
postalCode: "92615"
|
19
|
-
},
|
20
|
-
ShipTo: {
|
21
|
-
line1: "100 Market Street",
|
22
|
-
city: "San Francisco",
|
23
|
-
region: "CA",
|
24
|
-
country: "US",
|
25
|
-
postalCode: "94105"
|
26
|
-
}
|
27
|
-
},
|
28
|
-
lines: [{amount: 100}]
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should create a transaction" do
|
33
|
-
transaction = @client.create_transaction(@base_transaction)
|
34
|
-
expect(transaction).to be_a Object
|
35
|
-
expect(transaction["id"]).to be_a Integer
|
36
|
-
expect(transaction["status"]).to eq "Saved"
|
37
|
-
end
|
38
|
-
|
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
|
80
|
-
end
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe AvaTax::Client do
|
4
|
+
|
5
|
+
describe ".transactions" do
|
6
|
+
before do
|
7
|
+
@base_transaction = {
|
8
|
+
type: 'SalesInvoice',
|
9
|
+
companyCode: @company_code,
|
10
|
+
date: '2017-06-05',
|
11
|
+
customerCode: 'ABC',
|
12
|
+
addresses: {
|
13
|
+
ShipFrom: {
|
14
|
+
line1: "123 Main Street",
|
15
|
+
city: "Irvine",
|
16
|
+
region: "CA",
|
17
|
+
country: "US",
|
18
|
+
postalCode: "92615"
|
19
|
+
},
|
20
|
+
ShipTo: {
|
21
|
+
line1: "100 Market Street",
|
22
|
+
city: "San Francisco",
|
23
|
+
region: "CA",
|
24
|
+
country: "US",
|
25
|
+
postalCode: "94105"
|
26
|
+
}
|
27
|
+
},
|
28
|
+
lines: [{amount: 100}]
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should create a transaction" do
|
33
|
+
transaction = @client.create_transaction(@base_transaction)
|
34
|
+
expect(transaction).to be_a Object
|
35
|
+
expect(transaction["id"]).to be_a Integer
|
36
|
+
expect(transaction["status"]).to eq "Saved"
|
37
|
+
end
|
38
|
+
|
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
|
80
|
+
end
|
data/spec/avatax/request_spec.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe AvaTax::Request do
|
4
|
-
|
5
|
-
describe ".request" do
|
6
|
-
it "should default to a 1200 second timeout" do
|
7
|
-
@client.faraday_response = true
|
8
|
-
response = @client.request(:get, 'path', 'model')
|
9
|
-
expect(response.env.request['timeout']).to eq(1200)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should allow setting a custom timeout" do
|
13
|
-
@client.faraday_response = true
|
14
|
-
@client.connection_options = {
|
15
|
-
request: {
|
16
|
-
open_timeout: 5,
|
17
|
-
timeout: 10
|
18
|
-
}
|
19
|
-
}
|
20
|
-
response = @client.request(:get, 'path', 'model')
|
21
|
-
expect(response.env.request['open_timeout']).to eq(5)
|
22
|
-
expect(response.env.request['timeout']).to eq(10)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe AvaTax::Request do
|
4
|
+
|
5
|
+
describe ".request" do
|
6
|
+
it "should default to a 1200 second timeout" do
|
7
|
+
@client.faraday_response = true
|
8
|
+
response = @client.request(:get, 'path', 'model')
|
9
|
+
expect(response.env.request['timeout']).to eq(1200)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should allow setting a custom timeout" do
|
13
|
+
@client.faraday_response = true
|
14
|
+
@client.connection_options = {
|
15
|
+
request: {
|
16
|
+
open_timeout: 5,
|
17
|
+
timeout: 10
|
18
|
+
}
|
19
|
+
}
|
20
|
+
response = @client.request(:get, 'path', 'model')
|
21
|
+
expect(response.env.request['open_timeout']).to eq(5)
|
22
|
+
expect(response.env.request['timeout']).to eq(10)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/avatax_spec.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
if File.exist?(File.expand_path('../credentials.yaml', __FILE__))
|
3
|
-
credentials = YAML.load_file(File.expand_path('../credentials.yaml', __FILE__))
|
4
|
-
else
|
5
|
-
credentials = {
|
6
|
-
"endpoint" => 'https://sandbox-rest.avatax.com',
|
7
|
-
"username" => ENV['SANDBOX_USERNAME'],
|
8
|
-
"password" => ENV['SANDBOX_PASSWORD'],
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
describe AvaTax do
|
13
|
-
|
14
|
-
describe ".client" do
|
15
|
-
it "should be a AvaTax::Client" do
|
16
|
-
expect(AvaTax.client).to be_a AvaTax::Client
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ".endpoint" do
|
21
|
-
it "should return the default endpoint" do
|
22
|
-
expect(AvaTax.endpoint).to eq credentials['endpoint']
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe ".endpoint=" do
|
27
|
-
it "should set the endpoint" do
|
28
|
-
AvaTax.endpoint = 'https://sandbox-rest.avatax.com'
|
29
|
-
expect(AvaTax.endpoint).to eq 'https://sandbox-rest.avatax.com'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe ".configure" do
|
34
|
-
|
35
|
-
AvaTax::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
36
|
-
|
37
|
-
it "should set the #{key}" do
|
38
|
-
AvaTax.configure do |config|
|
39
|
-
config.send("#{key}=", key)
|
40
|
-
expect(AvaTax.send(key)).to eq key
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
if File.exist?(File.expand_path('../credentials.yaml', __FILE__))
|
3
|
+
credentials = YAML.load_file(File.expand_path('../credentials.yaml', __FILE__))
|
4
|
+
else
|
5
|
+
credentials = {
|
6
|
+
"endpoint" => 'https://sandbox-rest.avatax.com',
|
7
|
+
"username" => ENV['SANDBOX_USERNAME'],
|
8
|
+
"password" => ENV['SANDBOX_PASSWORD'],
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
describe AvaTax do
|
13
|
+
|
14
|
+
describe ".client" do
|
15
|
+
it "should be a AvaTax::Client" do
|
16
|
+
expect(AvaTax.client).to be_a AvaTax::Client
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".endpoint" do
|
21
|
+
it "should return the default endpoint" do
|
22
|
+
expect(AvaTax.endpoint).to eq credentials['endpoint']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".endpoint=" do
|
27
|
+
it "should set the endpoint" do
|
28
|
+
AvaTax.endpoint = 'https://sandbox-rest.avatax.com'
|
29
|
+
expect(AvaTax.endpoint).to eq 'https://sandbox-rest.avatax.com'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".configure" do
|
34
|
+
|
35
|
+
AvaTax::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
36
|
+
|
37
|
+
it "should set the #{key}" do
|
38
|
+
AvaTax.configure do |config|
|
39
|
+
config.send("#{key}=", key)
|
40
|
+
expect(AvaTax.send(key)).to eq key
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
---
|
2
|
-
endpoint: https://sandbox-rest.avatax.com
|
3
|
-
username: ---
|
4
|
-
password: ---
|
1
|
+
---
|
2
|
+
endpoint: https://sandbox-rest.avatax.com
|
3
|
+
username: ---
|
4
|
+
password: ---
|
data/spec/fixtures/accounts.json
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
{
|
2
|
-
"@recordsetCount": 1,
|
3
|
-
"value": [
|
4
|
-
{
|
5
|
-
"id": 200000251,
|
6
|
-
"name": "Avalara",
|
7
|
-
"effectiveDate": "2015-11-05T00:00:00",
|
8
|
-
"endDate": "2999-02-05T00:00:00",
|
9
|
-
"accountStatusId": "Active",
|
10
|
-
"createdDate": "2015-11-05T22:11:17.593",
|
11
|
-
"createdUserId": 46103,
|
12
|
-
"modifiedDate": "2017-01-10T18:55:36.193",
|
13
|
-
"modifiedUserId": 54057
|
14
|
-
}
|
15
|
-
]
|
1
|
+
{
|
2
|
+
"@recordsetCount": 1,
|
3
|
+
"value": [
|
4
|
+
{
|
5
|
+
"id": 200000251,
|
6
|
+
"name": "Avalara",
|
7
|
+
"effectiveDate": "2015-11-05T00:00:00",
|
8
|
+
"endDate": "2999-02-05T00:00:00",
|
9
|
+
"accountStatusId": "Active",
|
10
|
+
"createdDate": "2015-11-05T22:11:17.593",
|
11
|
+
"createdUserId": 46103,
|
12
|
+
"modifiedDate": "2017-01-10T18:55:36.193",
|
13
|
+
"modifiedUserId": 54057
|
14
|
+
}
|
15
|
+
]
|
16
16
|
}
|