vizjerai-avalara 0.2.0 → 0.3.0

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2Q5YTM1NDg2ODkxNjY5YWFmMjMxOTEzNjJhZTJlOGM4MTQzYjIyNQ==
4
+ MjViZjI3ZDgyMTdhMzJhZDEwNDAxNTZmODM5ZDhmZjRkY2VmNDBkOQ==
5
5
  data.tar.gz: !binary |-
6
- NzI0MGRhY2Y1M2FlNzA5NmVhNWRhYzQ5NTc5NzYwYzhiNDRhMjc5Mw==
6
+ MjQzN2NlOGE2ZmIzMzRmN2JmYzcyODk3MTA5NzZlNWQ0ODQ4ZWQ3Nw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjBiZjZlNThlYTk4YmZiZTM3NmY5NzU0MjQxMmViYzdjZGNkZTQ1OGJjN2Yx
10
- NzQ2MTA0MDkxZDUwYWRhNzUxYjRiMWE2ODU1YjE5MzQyMzk5MTA2YjdjMTdj
11
- N2YzNWQzMmU4ZWJiNGYxMzc4OTQwMDUxZDgwN2QzOTRhNGJhMzA=
9
+ MGVhY2Y4ZTA3ZmU3YzE0YmQ4ZDUxZDgzZWU4NWYyNWYxNjFkMDk2YTZkOTUw
10
+ MWUwYjU4M2IyNWM0N2M1MDRiYjA3Yjc4ZTM4NDRjNTFhZjJlYTdhOGZhYWE3
11
+ MjNkNmE1OWZmYWM1ODY1MjlhYjExZWJhM2QxYTNmZmExYTNkMjg=
12
12
  data.tar.gz: !binary |-
13
- MjBjZmQ0ODE3OTliNmE2ZjA3MTU3NzhlOGYzNDk2ZTEzNzU0Nzc5YTE4NzUw
14
- Njc5NDlhYzcwNGZlOWJkMmE3NzE1NWJmOGNkNDQwYmRhMTY5NDUyOTdkYjJi
15
- NDY1NmM0NmIyMGQwMmJiMWFiZDJmOWEyYjkzNzA2ZTAzZWI5ZjM=
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)}
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Avalara
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/avalara.rb CHANGED
@@ -27,6 +27,13 @@ module Avalara
27
27
  configuration(&block)
28
28
  end
29
29
 
30
+ def self.company_code
31
+ configuration.company_code
32
+ end
33
+ def self.company_code=(value)
34
+ configuration.company_code = value
35
+ end
36
+
30
37
  def self.endpoint
31
38
  configuration.endpoint
32
39
  end
@@ -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 }
@@ -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
@@ -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
- config.username = AVALARA_CONFIGURATION['username'] || abort("Avalara configuration file (#{path}) is missing the username value.")
12
- config.password = AVALARA_CONFIGURATION['password'] || abort("Avalara configuration file (#{path}) is missing the password value.")
13
- config.version = AVALARA_CONFIGURATION['version'] if AVALARA_CONFIGURATION.has_key?('version')
14
- config.endpoint = AVALARA_CONFIGURATION['endpoint'] if AVALARA_CONFIGURATION.has_key?('endpoint')
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(AVALARA_CONFIGURATION['username'])}:#{uri_encode(AVALARA_CONFIGURATION['password'])}"
15
+ "#{uri_encode(Avalara.username)}:#{uri_encode(Avalara.password)}"
16
16
  }
17
- config.filter_sensitive_data('API_ENDPOINT') { URI.parse(AVALARA_CONFIGURATION['endpoint']).host }
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.2.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-14 00:00:00.000000000 Z
12
+ date: 2013-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie