vizjerai-avalara 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +4 -0
- data/lib/avalara/configuration.rb +5 -0
- data/lib/avalara/request/cancel_tax.rb +6 -0
- data/lib/avalara/request/invoice.rb +6 -0
- data/lib/avalara/version.rb +1 -1
- data/lib/avalara.rb +7 -0
- data/spec/models/avalara/configuration_spec.rb +12 -0
- data/spec/models/avalara/request/invoice_spec.rb +32 -0
- data/spec/models/avalara_spec.rb +11 -0
- data/spec/support/avalara.rb +8 -4
- data/spec/support/vcr.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjViZjI3ZDgyMTdhMzJhZDEwNDAxNTZmODM5ZDhmZjRkY2VmNDBkOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjQzN2NlOGE2ZmIzMzRmN2JmYzcyODk3MTA5NzZlNWQ0ODQ4ZWQ3Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGVhY2Y4ZTA3ZmU3YzE0YmQ4ZDUxZDgzZWU4NWYyNWYxNjFkMDk2YTZkOTUw
|
10
|
+
MWUwYjU4M2IyNWM0N2M1MDRiYjA3Yjc4ZTM4NDRjNTFhZjJlYTdhOGZhYWE3
|
11
|
+
MjNkNmE1OWZmYWM1ODY1MjlhYjExZWJhM2QxYTNmZmExYTNkMjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTJhMTU3ODE0YWZjYTA3MTdlM2RjYzk4MDZiYTY3MDc1Y2RjYTA2YzRjZDU4
|
14
|
+
ZDk5NTkzYzU1MWQyODRiZmY0MzMxZjBmZjdlNGI3OGI2YmU3NjU4YmFmZjVm
|
15
|
+
YmEzMzMyNTQ1NWMxOTZlNzk3NmQ1YWIyNjQ4MGFhZmZmOGZmOTA=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.3.0 - June 24, 2013
|
2
|
+
|
3
|
+
- Added company_code to Avalara::Configuration to be used as a default for request invoice and request cancel_tax
|
4
|
+
|
1
5
|
## 0.2.0 - June 14, 2013
|
2
6
|
|
3
7
|
- Added test to configuration for better usability. Specifying an endpoint will override this setting.
|
@@ -7,6 +7,11 @@ class Avalara::Configuration
|
|
7
7
|
attr_accessor :username
|
8
8
|
attr_writer :version
|
9
9
|
|
10
|
+
# Public: Sets the default company code to be sent if one is not supplied
|
11
|
+
# Default: nil
|
12
|
+
#
|
13
|
+
attr_accessor :company_code
|
14
|
+
|
10
15
|
# Public: Changes the default endpoint between production and test.
|
11
16
|
# Default: nil
|
12
17
|
#
|
@@ -10,6 +10,12 @@ module Avalara
|
|
10
10
|
property :CancelCode, :from => :cancel_code
|
11
11
|
property :DocId, :from => :doc_id
|
12
12
|
|
13
|
+
# CompanyCode defaults to Avalara's configuration.company_code
|
14
|
+
def initialize(*args)
|
15
|
+
self.CompanyCode = Avalara.configuration.company_code if Avalara.configuration.company_code
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
13
19
|
def to_json
|
14
20
|
MultiJson.encode(self.to_hash, :pretty => true)
|
15
21
|
end
|
@@ -23,6 +23,12 @@ module Avalara
|
|
23
23
|
property :Addresses, :from => :addresses
|
24
24
|
property :ReferenceCode, :from => :reference_code
|
25
25
|
|
26
|
+
# CompanyCode defaults to Avalara's configuration.company_code
|
27
|
+
def initialize(*args)
|
28
|
+
self.CompanyCode = Avalara.configuration.company_code if Avalara.configuration.company_code
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
26
32
|
# Shipping Addresses
|
27
33
|
def addresses=(addresses)
|
28
34
|
self.Addresses = addresses.map {|address| InvoiceAddress.new(address)}
|
data/lib/avalara/version.rb
CHANGED
data/lib/avalara.rb
CHANGED
@@ -5,6 +5,18 @@ require 'spec_helper'
|
|
5
5
|
describe Avalara::Configuration do
|
6
6
|
let(:configuration) { Avalara::Configuration.new }
|
7
7
|
|
8
|
+
context '#company_code' do
|
9
|
+
it 'defaults to nil' do
|
10
|
+
expect(configuration.company_code).to be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'may be overridden' do
|
14
|
+
expect {
|
15
|
+
configuration.company_code = 'TEST'
|
16
|
+
}.to change(configuration, :company_code).to('TEST')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
8
20
|
context '#endpoint' do
|
9
21
|
it 'defaults to https://rest.avalara.net' do
|
10
22
|
expect(configuration.endpoint).to eq 'https://rest.avalara.net'
|
@@ -25,6 +25,38 @@ describe Avalara::Request::Invoice do
|
|
25
25
|
its(:ReferenceCode) { should == params[:reference_code] }
|
26
26
|
end
|
27
27
|
|
28
|
+
describe '#CompanyCode' do
|
29
|
+
let(:invoice) { Avalara::Request::Invoice.new }
|
30
|
+
|
31
|
+
it 'returns nil' do
|
32
|
+
expect(invoice.CompanyCode).to eq Avalara.company_code
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with invoice company code' do
|
36
|
+
let(:invoice) { Avalara::Request::Invoice.new :company_code => 'InvoiceInvoiceCode' }
|
37
|
+
|
38
|
+
it 'returns invoice company code' do
|
39
|
+
expect(invoice.CompanyCode).to eq 'InvoiceInvoiceCode'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with configuration company code' do
|
44
|
+
let(:invoice) { Avalara::Request::Invoice.new }
|
45
|
+
before { Avalara.configuration.company_code = 'TEST' }
|
46
|
+
|
47
|
+
it 'returns configuration company code' do
|
48
|
+
expect(invoice.CompanyCode).to eq 'TEST'
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with invoice company code' do
|
52
|
+
let(:invoice) { Avalara::Request::Invoice.new :company_code => 'InvoiceInvoiceCode' }
|
53
|
+
it 'allow overriding configuration company code' do
|
54
|
+
expect(invoice.CompanyCode).to eq 'InvoiceInvoiceCode'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
28
60
|
context 'converts nested objects to json' do
|
29
61
|
subject { invoice.to_json }
|
30
62
|
it { should_not be_nil }
|
data/spec/models/avalara_spec.rb
CHANGED
@@ -42,6 +42,17 @@ describe Avalara do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
describe '.company_code' do
|
46
|
+
it 'returns the configuration company code' do
|
47
|
+
expect(Avalara.company_code).to eq configuration.company_code
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'overrides the configuration company code' do
|
51
|
+
Avalara.company_code = 'TEST'
|
52
|
+
expect(Avalara.configuration.company_code).to eq 'TEST'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
45
56
|
describe '.endpoint' do
|
46
57
|
it 'returns the configuration endpoint' do
|
47
58
|
Avalara.endpoint.should == configuration.endpoint
|
data/spec/support/avalara.rb
CHANGED
@@ -8,10 +8,14 @@ if path.exist?
|
|
8
8
|
begin
|
9
9
|
AVALARA_CONFIGURATION = YAML.load_file(path)
|
10
10
|
Avalara.configure do |config|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
['username','password'].each do |attr|
|
12
|
+
config.send("#{attr}=", AVALARA_CONFIGURATION[attr])
|
13
|
+
abort("Avalara configuration file (#{path}) is missing the #{attr} value.") if config.send(attr).nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
['version','endpoint','company_code'].each do |attr|
|
17
|
+
config.send("#{attr}=", AVALARA_CONFIGURATION[attr]) if AVALARA_CONFIGURATION[attr]
|
18
|
+
end
|
15
19
|
end
|
16
20
|
rescue NoMethodError
|
17
21
|
abort "Avalara configuration file (#{path}) is malformatted or unreadable."
|
data/spec/support/vcr.rb
CHANGED
@@ -12,7 +12,7 @@ VCR.configure do |config|
|
|
12
12
|
config.configure_rspec_metadata!
|
13
13
|
|
14
14
|
config.filter_sensitive_data('API_BASIC_AUTH') {
|
15
|
-
"#{uri_encode(
|
15
|
+
"#{uri_encode(Avalara.username)}:#{uri_encode(Avalara.password)}"
|
16
16
|
}
|
17
|
-
config.filter_sensitive_data('API_ENDPOINT') { URI.parse(
|
17
|
+
config.filter_sensitive_data('API_ENDPOINT') { URI.parse(Avalara.endpoint).host }
|
18
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vizjerai-avalara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Fortuna
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|