vizjerai-avalara 0.1.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.
Files changed (61) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +25 -0
  3. data/CHANGELOG.md +14 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README +5 -0
  7. data/Rakefile +10 -0
  8. data/lib/avalara/api.rb +26 -0
  9. data/lib/avalara/configuration.rb +31 -0
  10. data/lib/avalara/errors.rb +8 -0
  11. data/lib/avalara/request/address.rb +15 -0
  12. data/lib/avalara/request/cancel_tax.rb +18 -0
  13. data/lib/avalara/request/detail_level.rb +13 -0
  14. data/lib/avalara/request/invoice.rb +40 -0
  15. data/lib/avalara/request/invoice_address.rb +19 -0
  16. data/lib/avalara/request/line.rb +24 -0
  17. data/lib/avalara/request.rb +13 -0
  18. data/lib/avalara/response/address_validation.rb +24 -0
  19. data/lib/avalara/response/cancel_tax.rb +20 -0
  20. data/lib/avalara/response/cancel_tax_result.rb +20 -0
  21. data/lib/avalara/response/invoice.rb +38 -0
  22. data/lib/avalara/response/message.rb +13 -0
  23. data/lib/avalara/response/tax.rb +24 -0
  24. data/lib/avalara/response/tax_address.rb +16 -0
  25. data/lib/avalara/response/tax_detail.rb +16 -0
  26. data/lib/avalara/response/tax_line.rb +22 -0
  27. data/lib/avalara/response/validation_address.rb +46 -0
  28. data/lib/avalara/response.rb +16 -0
  29. data/lib/avalara/types/date.rb +10 -0
  30. data/lib/avalara/types/stash.rb +28 -0
  31. data/lib/avalara/types.rb +8 -0
  32. data/lib/avalara/version.rb +5 -0
  33. data/lib/avalara.rb +121 -0
  34. data/spec/avalara.yml.example +3 -0
  35. data/spec/factories/addresses.rb +11 -0
  36. data/spec/factories/cancel_taxs.rb +9 -0
  37. data/spec/factories/detail_levels.rb +9 -0
  38. data/spec/factories/invoice_addresses.rb +15 -0
  39. data/spec/factories/invoices.rb +18 -0
  40. data/spec/factories/lines.rb +16 -0
  41. data/spec/fixtures/net/Avalara/_cancel_tax/successful_response.yml +59 -0
  42. data/spec/fixtures/net/Avalara/_cancel_tax/with_missing_doc_code/unsuccessful_response.yml +75 -0
  43. data/spec/fixtures/net/Avalara/_geographical_tax/successful_response.yml +92 -0
  44. data/spec/fixtures/net/Avalara/_geographical_tax/with_incomplete_address/unsuccessful_response.yml +66 -0
  45. data/spec/fixtures/net/Avalara/_get_tax/successful_response.yml +151 -0
  46. data/spec/fixtures/net/Avalara/_get_tax/with_missing_required_field/unsuccessful_response.yml +73 -0
  47. data/spec/fixtures/net/Avalara/_validate_address/successful_response.yml +76 -0
  48. data/spec/fixtures/net/Avalara/_validate_address/with_missing_postal_code/unsuccessful_response.yml +68 -0
  49. data/spec/models/avalara/configuration_spec.rb +55 -0
  50. data/spec/models/avalara/request/address_spec.rb +20 -0
  51. data/spec/models/avalara/request/detail_level_spec.rb +18 -0
  52. data/spec/models/avalara/request/invoice_address_spec.rb +24 -0
  53. data/spec/models/avalara/request/invoice_spec.rb +32 -0
  54. data/spec/models/avalara/request/line_spec.rb +25 -0
  55. data/spec/models/avalara_spec.rb +300 -0
  56. data/spec/spec_helper.rb +19 -0
  57. data/spec/support/avalara.rb +38 -0
  58. data/spec/support/factory_girl.rb +20 -0
  59. data/spec/support/vcr.rb +18 -0
  60. data/vizjerai-avalara.gemspec +31 -0
  61. metadata +257 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTIyNGQ4OTYzZTE1ZDg0MmZlZDFkNTU5NTY1MWE5NmU4MThkZWM2MA==
5
+ data.tar.gz: !binary |-
6
+ NmE4M2RhMTRjZmVmM2NjODhjZTNiZGY0ZDZiNWFhOWVmMDFiY2NkNg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZjE3NjE2Njk1OWFhMGI5NzMxMzY3ZmFiZmI0MTgxYmJiNjc0YWE0MDdmMDE0
10
+ ZDBhNjg5ZWQ2ZWY3Zjg0MTg5YzQyZjMwZmUzZmVkNzVhNDhlMDBkZDJhYzJm
11
+ OTAyZTQ2NjlhZjkzN2I0YjY0OTljYzM5NmQ1YmY4NDM3NjMyMDk=
12
+ data.tar.gz: !binary |-
13
+ N2UzMGIzOWQzMjIxYjhlN2IxOTNjYmJiNTVmZDQwNjczYjE0ZDIyNTg5ZGYz
14
+ ZGEzODI0MzgzY2U0ZjE5MTk5MTljMDA4NTdiMjQ5NWU5NGQxYWRiNzMwNDY0
15
+ ZTczZjVkMzk1NzBlNDRlY2Q5NTIyMjlkNmQ1MzNhNDk3NDk0YTE=
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ *.tmproj
5
+ *~
6
+ .DS_Store
7
+ .\#*
8
+ .bundle
9
+ .config
10
+ .yardoc
11
+ Gemfile.lock
12
+ InstalledFiles
13
+ \#*
14
+ _yardoc
15
+ coverage
16
+ doc/
17
+ lib/bundler/man
18
+ pkg
19
+ rdoc
20
+ spec/reports
21
+ test/tmp
22
+ test/version_tmp
23
+ tmp
24
+ tmtags
25
+ spec/avalara.yml
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ ## 0.1.0 - June 13, 2013
2
+ - Updated tests and gems
3
+ - Added missing specs for geographical_tax
4
+ - Added validate address
5
+ - Added cancel tax
6
+
7
+ ## 0.0.2 - May 7, 2012 - Updated tests for test endpoint.
8
+
9
+ - Looks like the tests were initally run against the production database (whops). I re-ran them against test and they're still working.
10
+ - No code changes for this, other than documenting the test endpoint.
11
+
12
+ ## 0.0.1 - February 3, 2012 - Initial Release with get_tax call
13
+
14
+ - Not much in the way of features so far, but the rough draft of the get_tax call is in, as well as error and warning message handling. Still need to update the docs with it once an API to the gem is finalized.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in avalvara.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Andrew Assarattanakul
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,5 @@
1
+ Avalara
2
+ =====
3
+
4
+ This API provides access to the [Avalara](http://www.avalara.com/) AvaTax API.
5
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ require 'bundler/gem_tasks'
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:test) do |t|
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ t.verbose = false
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,26 @@
1
+ # encoding: UTF-8
2
+ require 'httparty'
3
+
4
+ module Avalara
5
+ class API
6
+ include HTTParty
7
+ headers 'Accept' => 'application/json', 'Content-Type' => 'text/json'
8
+ format :json
9
+
10
+ def self.headers_for(content_length = 0)
11
+ {
12
+ 'Accept' => 'application/json',
13
+ 'Content-Type' => 'text/json',
14
+ 'Date' => Time.now.httpdate(),
15
+ 'User-Agent' => user_agent_string,
16
+ "Content-Length" => content_length.to_s
17
+ }
18
+ end
19
+
20
+ private
21
+
22
+ def self.user_agent_string
23
+ "avalara/#{Avalara::VERSION} (Rubygems; Ruby #{RUBY_VERSION} #{RUBY_PLATFORM})"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: UTF-8
2
+
3
+ class Avalara::Configuration
4
+
5
+ attr_writer :endpoint
6
+ attr_accessor :password
7
+ attr_accessor :username
8
+ attr_writer :version
9
+
10
+ ##
11
+ # Public: Get the API endpoint used by the configuration. Unless explicitly
12
+ # set, the endpoint will default to the official production endpoint at
13
+ # 'https://rest.avalara.net'.
14
+ #
15
+ # If you want to set this to the test endpoint, use 'https://development.avalara.net'
16
+ #
17
+ # Returns the String for the API endpoint.
18
+ #
19
+ def endpoint
20
+ @endpoint ||= 'https://rest.avalara.net'
21
+ end
22
+
23
+ ##
24
+ # Public: Get the API version. Defaults to 1.0.
25
+ #
26
+ # Returns the String for the API version.
27
+ #
28
+ def version
29
+ @version ||= '1.0'
30
+ end
31
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ class Error < StandardError ; end
5
+ class TimeoutError < Error ; end
6
+ class NotImplementedError < Error ; end
7
+ class ApiError < Error ; end
8
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Request
5
+ class Address < Avalara::Types::Stash
6
+ property :Line1, :from => :line_1
7
+ property :Line2, :from => :line_2
8
+ property :Line3, :from => :line_3
9
+ property :City, :from => :city
10
+ property :Region, :from => :region
11
+ property :Country, :from => :country
12
+ property :PostalCode, :from => :postal_code
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: UTF-8
2
+ require 'multi_json'
3
+
4
+ module Avalara
5
+ module Request
6
+ class CancelTax < Avalara::Types::Stash
7
+ property :CompanyCode, :from => :company_code
8
+ property :DocType, :from => :doc_type
9
+ property :DocCode, :from => :doc_code
10
+ property :CancelCode, :from => :cancel_code
11
+ property :DocId, :from => :doc_id
12
+
13
+ def to_json
14
+ MultiJson.encode(self.to_hash, :pretty => true)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Request
5
+ class DetailLevel < Avalara::Types::Stash
6
+ property :Line, :from => :line
7
+ property :Summary, :from => :summary
8
+ property :Document, :from => :document
9
+ property :Tax, :from => :tax
10
+ property :Diagnostic, :from => :diagnostic
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: UTF-8
2
+ require 'multi_json'
3
+
4
+ module Avalara
5
+ module Request
6
+ # Same as GetTaxRequest
7
+ class Invoice < Avalara::Types::Stash
8
+ coerce_key :DocDate, Avalara::Types::Date
9
+
10
+ # Set outgoing
11
+ property :CustomerCode, :from => :customer_code
12
+ property :DocDate, :from => :doc_date
13
+ property :CompanyCode, :from => :company_code
14
+ property :Commit, :from => :commit
15
+ property :CustomerUsageType, :from => :customer_usage_type
16
+ property :Discount, :from => :discount
17
+ property :DocCode, :from => :doc_code
18
+ property :PurchaseOrderNo, :from => :purchase_order_no
19
+ property :ExemptionNo, :from => :exemption_no
20
+ property :DetailLevel, :from => :detail_level
21
+ property :DocType, :from => :doc_type
22
+ property :Lines, :from => :lines
23
+ property :Addresses, :from => :addresses
24
+ property :ReferenceCode, :from => :reference_code
25
+
26
+ # Shipping Addresses
27
+ def addresses=(addresses)
28
+ self.Addresses = addresses.map {|address| InvoiceAddress.new(address)}
29
+ end
30
+
31
+ def lines=(lines)
32
+ self.Lines = lines.map {|line| Line.new(line)}
33
+ end
34
+
35
+ def to_json
36
+ MultiJson.encode(self.to_hash, :pretty => true)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Request
5
+ class InvoiceAddress < Avalara::Types::Stash
6
+ property :AddressCode, :from => :address_code, :required => true
7
+ property :Line1, :from => :line_1
8
+ property :Line2, :from => :line_2
9
+ property :Line3, :from => :line_3
10
+ property :City, :from => :city
11
+ property :Region, :from => :region
12
+ property :Country, :from => :country
13
+ property :PostalCode, :from => :postal_code
14
+ property :Latitude, :from => :latitude
15
+ property :Longitude, :from => :longitude
16
+ property :TaxRegionId, :from => :tax_region_id
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Request
5
+ class Line < Avalara::Types::Stash
6
+ property :LineNo, :from => :line_no, :required => true
7
+ property :DestinationCode, :from => :destination_code, :required => true
8
+ property :OriginCode, :from => :origin_code, :required => true
9
+ property :ItemCode, :from => :item_code
10
+ property :TaxCode, :from => :tax_code
11
+ property :CustomerUsageType, :from => :customer_usage_type
12
+ property :Description, :from => :description
13
+ property :Qty, :from => :qty, :required => true
14
+
15
+ # Amount: (decimal)
16
+ # - in dollars as a decimal. AvaTax will round to 2 decimal places
17
+ property :Amount, :from => :amount, :required => true
18
+ property :Discounted, :from => :discounted
19
+ property :TaxIncluded, :from => :tax_included
20
+ property :Ref1, :from => :ref_1
21
+ property :Ref2, :from => :ref_2
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Request
5
+ autoload :Address, 'avalara/request/address'
6
+ autoload :CancelTax, 'avalara/request/cancel_tax'
7
+ autoload :DetailLevel, 'avalara/request/detail_level'
8
+ autoload :Invoice, 'avalara/request/invoice'
9
+ autoload :InvoiceAddress, 'avalara/request/invoice_address'
10
+ autoload :Line, 'avalara/request/line'
11
+ autoload :Message, 'avalara/request/message'
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ class AddressValidation < Avalara::Types::Stash
6
+ property :address, :from => :Address
7
+
8
+ property :result_code, :from => :ResultCode
9
+ property :messages, :from => :Messages
10
+
11
+ def success?
12
+ result_code == 'Success'
13
+ end
14
+
15
+ def Address=(address)
16
+ self.address = ValidationAddress.new(address)
17
+ end
18
+
19
+ def Messages=(new_messages)
20
+ self.messages = new_messages.map {|message| Message.new(message)}
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ class CancelTax < Avalara::Types::Stash
6
+ property :cancel_tax_result, :from => :CancelTaxResult
7
+
8
+ delegate :success?, :to => :cancel_tax_result
9
+
10
+ delegate :transaction_id, :to => :cancel_tax_result
11
+ delegate :result_code, :to => :cancel_tax_result
12
+ delegate :doc_id, :to => :cancel_tax_result
13
+ delegate :messages, :to => :cancel_tax_result
14
+
15
+ def CancelTaxResult=(result)
16
+ self.cancel_tax_result = CancelTaxResult.new(result)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ class CancelTaxResult < Avalara::Types::Stash
6
+ property :transaction_id, :from => :TransactionId
7
+ property :result_code, :from => :ResultCode
8
+ property :doc_id, :from => :DocId
9
+ property :messages, :from => :Messages
10
+
11
+ def success?
12
+ result_code == 'Success'
13
+ end
14
+
15
+ def Messages=(new_messages)
16
+ self.messages = new_messages.map {|message| Message.new(message)}
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ class Invoice < Avalara::Types::Stash
6
+ property :doc_code, :from => :DocCode
7
+ property :doc_date, :from => :DocDate
8
+ property :timestamp, :from => :Timestamp
9
+ property :total_amount, :from => :TotalAmount
10
+ property :total_discount, :from => :TotalDiscount
11
+ property :total_exemption, :from => :TotalExemption
12
+ property :total_taxable, :from => :TotalTaxable
13
+ property :total_tax, :from => :TotalTax
14
+ property :total_tax_calculated, :from => :TotalTaxCalculated
15
+ property :tax_date, :from => :TaxDate
16
+ property :tax_lines, :from => :TaxLines
17
+ property :tax_addresses, :from => :TaxAddresses
18
+ property :result_code, :from => :ResultCode
19
+ property :messages, :from => :Messages
20
+
21
+ def success?
22
+ result_code == 'Success'
23
+ end
24
+
25
+ def Messages=(new_messages)
26
+ self.messages = new_messages.map {|message| Message.new(message)}
27
+ end
28
+
29
+ def TaxLines=(lines)
30
+ self.tax_lines = lines.map {|line| TaxLine.new(line)}
31
+ end
32
+
33
+ def TaxAddresses=(addresses)
34
+ self.tax_addresses = addresses.map {|address| TaxAddress.new(address)}
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ class Message < Avalara::Types::Stash
6
+ property :summary, :from => :Summary
7
+ property :details, :from => :Details
8
+ property :refers_to, :from => :RefersTo
9
+ property :severity, :from => :Severity
10
+ property :source, :from => :Source
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ module Avalara
2
+ module Response
3
+ class Tax < Avalara::Types::Stash
4
+ property :rate, :from => :Rate
5
+ property :tax, :from => :Tax
6
+ property :tax_details, :from => :TaxDetails
7
+
8
+ property :result_code, :from => :ResultCode
9
+ property :messages, :from => :Messages
10
+
11
+ def success?
12
+ result_code != 'Error'
13
+ end
14
+
15
+ def Messages=(new_messages)
16
+ self.messages = new_messages.map {|message| Message.new(message)}
17
+ end
18
+
19
+ def TaxDetails=(details)
20
+ self.tax_details = details.map {|tax_detail| TaxDetail.new(tax_detail)}
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ class TaxAddress < Avalara::Types::Stash
6
+ property :address, :from => :Address
7
+ property :address_code, :from => :AddressCode
8
+ property :city, :from => :City
9
+ property :country, :from => :Country
10
+ property :postal_code, :from => :PostalCode
11
+ property :region, :from => :Region
12
+ property :tax_region_id, :from => :TaxRegionId
13
+ property :juris_code, :from => :JurisCode
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ class TaxDetail < Avalara::Types::Stash
6
+ property :taxable, :from => :Taxable
7
+ property :rate, :from => :Rate
8
+ property :tax, :from => :Tax
9
+ property :region, :from => :Region
10
+ property :country, :from => :Country
11
+ property :juris_type, :from => :JurisType
12
+ property :juris_name, :from => :JurisName
13
+ property :tax_name, :from => :TaxName
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ class TaxLine < Avalara::Types::Stash
6
+ property :line_no, :from => :LineNo
7
+ property :tax_code, :from => :TaxCode
8
+ property :taxability, :from => :Taxability
9
+ property :taxable, :from => :Taxable
10
+ property :rate, :from => :Rate
11
+ property :tax, :from => :Tax
12
+ property :tax_details, :from => :TaxDetails
13
+ property :discount, :from => :Discount
14
+ property :tax_calculated, :from => :TaxCalculated
15
+ property :exemption, :from => :Exemption
16
+
17
+ def TaxDetails=(tax_details)
18
+ self.tax_details = tax_details.map {|tax_detail| TaxDetail.new(tax_detail)}
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,46 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ class ValidationAddress < Avalara::Types::Stash
6
+ ADDRESS_TYPE_NAME = {
7
+ 'F' => 'Firm or company address',
8
+ 'G' => 'General Delivery address',
9
+ 'H' => 'High-rise or business complex',
10
+ 'P' => 'PO Box address',
11
+ 'R' => 'Rural route address',
12
+ 'S' => 'Street or residential address'
13
+ }
14
+ CARRIER_TYPE = {
15
+ 'B' => 'PO Box',
16
+ 'C' => 'City delivery',
17
+ 'G' => 'General delivery',
18
+ 'H' => 'Highway contract',
19
+ 'R' => 'Rural route'
20
+ }
21
+
22
+ property :line_1, :from => :Line1
23
+ property :line_2, :from => :Line2
24
+ property :line_3, :from => :Line3
25
+ property :city, :from => :City
26
+ property :region, :from => :Region
27
+ property :country, :from => :Country
28
+ property :address_type, :from => :AddressType
29
+ property :postal_code, :from => :PostalCode
30
+ property :county, :from => :County
31
+ property :fips_code, :from => :FipsCode
32
+ property :carrier_route, :from => :CarrierRoute
33
+ property :tax_region_id, :from => :TaxRegionId
34
+ property :post_net, :from => :PostNet
35
+
36
+ def address_type_name
37
+ ADDRESS_TYPE_NAME[address_type]
38
+ end
39
+
40
+ def carrier_route_name
41
+ return carrier_route if carrier_route.nil? || carrier_route.empty?
42
+ CARRIER_TYPE[carrier_route[0]]
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Response
5
+ autoload :AddressValidation, 'avalara/response/address_validation'
6
+ autoload :CancelTax, 'avalara/response/cancel_tax'
7
+ autoload :CancelTaxResult, 'avalara/response/cancel_tax_result'
8
+ autoload :Invoice, 'avalara/response/invoice'
9
+ autoload :Message, 'avalara/response/message'
10
+ autoload :TaxLine, 'avalara/response/tax_line'
11
+ autoload :TaxDetail, 'avalara/response/tax_detail'
12
+ autoload :TaxAddress, 'avalara/response/tax_address'
13
+ autoload :Tax, 'avalara/response/tax'
14
+ autoload :ValidationAddress, 'avalara/response/validation_address'
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ module Avalara
2
+ module Types
3
+ class Date
4
+ def self.coerce(object)
5
+ return object unless object.respond_to?(:strftime)
6
+ return object.strftime("%Y-%m-%d")
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'hashie/trash'
4
+ require 'hashie/extensions/coercion'
5
+
6
+ module Avalara
7
+ module Types
8
+ ##
9
+ # A Stash is a 'suppressing' Hashie::Trash where keys that are not defined
10
+ # are simply ignored and unavailable to the local object.
11
+ #
12
+ # A Stash is useful when you need to read data from another application,
13
+ # but you only want a predefined subset of the returned data to become
14
+ # available, locally.
15
+ #
16
+ class Stash < ::Hashie::Trash
17
+ include Hashie::Extensions::Coercion
18
+
19
+
20
+ private
21
+
22
+
23
+ def property_exists?(property)
24
+ self.class.property?(property.to_sym)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ module Types
5
+ autoload :Date, 'avalara/types/date'
6
+ autoload :Stash, 'avalara/types/stash'
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+
3
+ module Avalara
4
+ VERSION = '0.1.0'
5
+ end