avalara 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ avalara
@@ -0,0 +1 @@
1
+ ruby-1.9.3
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - 1.8.7
6
+ before_script:
7
+ - cp spec/avalara.yml.example spec/avalara.yml
8
+ notifications:
9
+ email: false
@@ -1,10 +1,15 @@
1
- = 0.0.2 - May 7, 2012 - Updated tests for test endpoint.
1
+ # 0.0.3 - October 4, 2013 - Updated multi_json gem
2
+
3
+ The multi_json gem was way out of date, but https://github.com/imajes
4
+ updated it. We also moved over to using Travis for builds.
5
+
6
+ # 0.0.2 - May 7, 2012 - Updated tests for test endpoint.
2
7
 
3
8
  Looks like the tests were initally run against the production database
4
9
  (whops). I re-ran them against test and they're still working.
5
10
  No code changes for this, other than documenting the test endpoint.
6
11
 
7
- = 0.0.1 - February 3, 2012 - Initial Release with get_tax call
12
+ # 0.0.1 - February 3, 2012 - Initial Release with get_tax call
8
13
 
9
14
  Not much in the way of features so far, but the rough draft of the get_tax call is in,
10
15
  as well as error and warning message handling. Still need to update the docs with it
data/Gemfile CHANGED
@@ -1,8 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
  gemspec
3
3
 
4
- gem "hashie", :git => "https://github.com/intridea/hashie.git"
5
-
6
4
  group :development, :test do
7
5
  gem 'rake'
8
- end
6
+ end
@@ -1,16 +1,10 @@
1
- GIT
2
- remote: https://github.com/intridea/hashie.git
3
- revision: 6728ed259b4e8e679901b1d64e1d791f28ec186a
4
- specs:
5
- hashie (2.0.0.beta)
6
-
7
1
  PATH
8
2
  remote: .
9
3
  specs:
10
- avalara (0.0.1)
4
+ avalara (0.0.3)
11
5
  hashie
12
6
  httparty
13
- multi_json (~> 1.0.4)
7
+ multi_json
14
8
 
15
9
  GEM
16
10
  remote: http://rubygems.org/
@@ -19,20 +13,17 @@ GEM
19
13
  i18n (~> 0.6)
20
14
  multi_json (~> 1.0)
21
15
  addressable (2.2.6)
22
- archive-tar-minitar (0.5.2)
23
- columnize (0.3.6)
24
16
  crack (0.3.1)
25
17
  diff-lcs (1.1.3)
26
18
  factory_girl (2.5.0)
27
19
  activesupport
28
- httparty (0.8.1)
29
- multi_json
30
- multi_xml
20
+ hashie (2.0.5)
21
+ httparty (0.11.0)
22
+ multi_json (~> 1.0)
23
+ multi_xml (>= 0.5.2)
31
24
  i18n (0.6.0)
32
- linecache19 (0.5.12)
33
- ruby_core_source (>= 0.1.4)
34
- multi_json (1.0.4)
35
- multi_xml (0.4.1)
25
+ multi_json (1.8.0)
26
+ multi_xml (0.5.5)
36
27
  rake (0.9.2.2)
37
28
  rspec (2.8.0)
38
29
  rspec-core (~> 2.8.0)
@@ -42,16 +33,6 @@ GEM
42
33
  rspec-expectations (2.8.0)
43
34
  diff-lcs (~> 1.1.2)
44
35
  rspec-mocks (2.8.0)
45
- ruby-debug-base19 (0.11.25)
46
- columnize (>= 0.3.1)
47
- linecache19 (>= 0.5.11)
48
- ruby_core_source (>= 0.1.4)
49
- ruby-debug19 (0.11.6)
50
- columnize (>= 0.3.1)
51
- linecache19 (>= 0.5.11)
52
- ruby-debug-base19 (>= 0.11.19)
53
- ruby_core_source (0.1.5)
54
- archive-tar-minitar (>= 0.5.2)
55
36
  vcr (1.11.3)
56
37
  webmock (1.7.10)
57
38
  addressable (~> 2.2, > 2.2.5)
@@ -63,9 +44,7 @@ PLATFORMS
63
44
  DEPENDENCIES
64
45
  avalara!
65
46
  factory_girl
66
- hashie!
67
47
  rake
68
48
  rspec
69
- ruby-debug19
70
49
  vcr
71
50
  webmock
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => [:spec]
4
+ desc 'run Rspec specs'
5
+ task :spec do
6
+ sh 'rspec spec'
7
+ end
@@ -0,0 +1,104 @@
1
+ # Avalara gem
2
+
3
+ This API provides access to the [Avalara](http://www.avalara.com/) AvaTax API.
4
+
5
+ [![Build Status](https://travis-ci.org/adamfortuna/avalara.png)](https://travis-ci.org/adamfortuna/avalara)
6
+
7
+ ## Setup
8
+
9
+ Add the gem to your `Gemfile`.
10
+
11
+ ```
12
+ gem 'avalara'
13
+ ```
14
+
15
+ Setup your Avalara credentials, either in a yml file, or as environment variables. If you want to add a yml file, it'll just need `username` and `password`:
16
+
17
+ ```
18
+ username: 'testaccount'
19
+ password: 'testkey'
20
+ ```
21
+
22
+ You can also specify a different endpoint for development mode:
23
+
24
+ ```
25
+ https://development.avalara.net
26
+ ```
27
+
28
+ Setup the gem in an initializer (if using Rails), or wherever if you're not. You can load in your username/password however you want, but here's a sample way to do this:
29
+
30
+ ```
31
+ file = File.new(File.join(Rails.root, 'config', 'avalara.yml'))
32
+
33
+ if file.exist?
34
+ begin
35
+ AVALARA_CONFIGURATION = YAML.load_file(path)
36
+ Avalara.configure do |config|
37
+ config.username = AVALARA_CONFIGURATION['username'] || abort("Avalara configuration file (#{path}) is missing the username value.")
38
+ config.password = AVALARA_CONFIGURATION['password'] || abort("Avalara configuration file (#{path}) is missing the password value.")
39
+ config.version = AVALARA_CONFIGURATION['version'] if AVALARA_CONFIGURATION.has_key?('version')
40
+ config.endpoint = AVALARA_CONFIGURATION['endpoint'] if AVALARA_CONFIGURATION.has_key?('endpoint')
41
+ end'
42
+ end
43
+ else
44
+ abort "Avalara configuration not found."
45
+ end
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ After that you should be able to use a few endpoints to Avalaras tax service. If you need a new endpoint, feel free to fork this gem, add support for it, add specs and do a pull request back.
51
+
52
+ ### Geographical Tax
53
+
54
+ ```
55
+ result = Avalara.geographical_tax('47.627935', '-122.51702', 100)
56
+
57
+ # Access the details of the result, which is a Avalara::Response::Tax object
58
+ result.rate
59
+ result.tax
60
+ result.tax_details
61
+ ```
62
+
63
+ ### Get Tax
64
+
65
+ ```
66
+ line = Avalara::Request::Line.new({
67
+ line_no: "1",
68
+ destination_code: "1",
69
+ origin_code: "1",
70
+ qty: "1",
71
+ amount: 10
72
+ })
73
+
74
+ address = Avalara::Request::Address.new({
75
+ address_code: 1,
76
+ line_1: "435 Ericksen Avenue Northeast",
77
+ line_2: "#250",
78
+ postal_code: "98110"
79
+ })
80
+
81
+ invoice = Avalara::Request::Invoice.new({
82
+ doc_date: Time.now,
83
+ company_code: 1,
84
+ lines: [line],
85
+ addresses: [address]
86
+ })
87
+
88
+ # You'll get back a Response::Invoice object
89
+ result = Avalara.get_tax(invoice)
90
+
91
+ result.result_code
92
+ result.total_amount
93
+ result.total_tax
94
+ result.total_tax_calculated
95
+ ```
96
+
97
+
98
+ ## Contributing
99
+
100
+ If you want to contribute, please fork this repo and make a pull request back. If you add some specs and everything still passes, we can get your contribution in! Thanks to everyone who has contributed:
101
+
102
+ * [Adam Fortuna](http://github.com/adamfortuna)
103
+ * [James Cox](http://github.com/adamfortuna)
104
+ * [Dan Sosedoff](http://github.com/sosedoff)
@@ -18,11 +18,10 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_dependency 'hashie'
20
20
  s.add_dependency 'httparty'
21
- s.add_dependency 'multi_json', '~> 1.0.4'
21
+ s.add_dependency 'multi_json'
22
22
 
23
23
  s.add_development_dependency 'vcr'
24
24
  s.add_development_dependency 'webmock'
25
25
  s.add_development_dependency 'rspec'
26
26
  s.add_development_dependency 'factory_girl'
27
- s.add_development_dependency 'ruby-debug19'
28
- end
27
+ end
@@ -56,13 +56,21 @@ module Avalara
56
56
  end
57
57
 
58
58
  def self.geographical_tax(latitude, longitude, sales_amount)
59
- raise NotImplementedError
60
- uri = [configuration.endpoint, configuration.version, "tax", "#{latitude},#{longitude}", "get"].join["/"]
61
-
59
+ uri = [
60
+ configuration.endpoint,
61
+ configuration.version,
62
+ "tax",
63
+ "#{latitude},#{longitude}",
64
+ "get"
65
+ ].join("/")
66
+
62
67
  response = API.get(uri,
63
- :headers => API.headers_for('0'),
64
- :query => { :saleamount => sales_amount }
68
+ :headers => API.headers_for('0'),
69
+ :query => {:saleamount => sales_amount},
70
+ :basic_auth => authentication
65
71
  )
72
+
73
+ Avalara::Response::Tax.new(response)
66
74
  rescue Timeout::Error
67
75
  puts "Timed out"
68
76
  raise TimeoutError
@@ -2,10 +2,11 @@
2
2
 
3
3
  module Avalara
4
4
  module Response
5
- autoload :Invoice, 'avalara/response/invoice'
6
- autoload :Message, 'avalara/response/message'
7
- autoload :TaxLine, 'avalara/response/tax_line'
8
- autoload :TaxDetail, 'avalara/response/tax_detail'
5
+ autoload :Invoice, 'avalara/response/invoice'
6
+ autoload :Message, 'avalara/response/message'
7
+ autoload :TaxLine, 'avalara/response/tax_line'
8
+ autoload :TaxDetail, 'avalara/response/tax_detail'
9
9
  autoload :TaxAddress, 'avalara/response/tax_address'
10
+ autoload :Tax, 'avalara/response/tax'
10
11
  end
11
12
  end
@@ -0,0 +1,13 @@
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
+ def TaxDetails=(details)
9
+ self.tax_details = details.map { |d| Avalara::Response::TaxDetail.new(d) }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Avalara
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
metadata CHANGED
@@ -1,122 +1,145 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: avalara
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
4
5
  prerelease:
5
- version: 0.0.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Adam Fortuna
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-05-07 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-10-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: hashie
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: httparty
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
30
25
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: httparty
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
35
38
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: multi_json
39
39
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.0.4
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: multi_json
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
46
54
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: vcr
50
55
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: vcr
64
+ requirement: !ruby/object:Gem::Requirement
52
65
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
57
70
  type: :development
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: webmock
61
71
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: webmock
80
+ requirement: !ruby/object:Gem::Requirement
63
81
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
68
86
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: rspec
72
87
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
74
97
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
79
102
  type: :development
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: factory_girl
83
103
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
85
105
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: factory_girl
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
90
118
  type: :development
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
- name: ruby-debug19
94
119
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
120
+ version_requirements: !ruby/object:Gem::Requirement
96
121
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "0"
101
- type: :development
102
- version_requirements: *id008
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
103
126
  description: This library provides Ruby calls to interact with the Avalara Tax API
104
- email:
127
+ email:
105
128
  - adam@envylabs.com
106
129
  executables: []
107
-
108
130
  extensions: []
109
-
110
131
  extra_rdoc_files: []
111
-
112
- files:
132
+ files:
113
133
  - .gitignore
114
- - .rvmrc
115
- - CHANGELOG
134
+ - .ruby-gemset
135
+ - .ruby-version
136
+ - .travis.yml
137
+ - Changelog.md
116
138
  - Gemfile
117
139
  - Gemfile.lock
118
140
  - LICENSE
119
- - README
141
+ - Rakefile
142
+ - Readme.md
120
143
  - avalara.gemspec
121
144
  - lib/avalara.rb
122
145
  - lib/avalara/api.rb
@@ -131,6 +154,7 @@ files:
131
154
  - lib/avalara/response.rb
132
155
  - lib/avalara/response/invoice.rb
133
156
  - lib/avalara/response/message.rb
157
+ - lib/avalara/response/tax.rb
134
158
  - lib/avalara/response/tax_address.rb
135
159
  - lib/avalara/response/tax_detail.rb
136
160
  - lib/avalara/response/tax_line.rb
@@ -157,32 +181,29 @@ files:
157
181
  - spec/support/vcr.rb
158
182
  homepage: https://github.com/adamfortuna/avalara
159
183
  licenses: []
160
-
161
184
  post_install_message:
162
185
  rdoc_options: []
163
-
164
- require_paths:
186
+ require_paths:
165
187
  - lib
166
- required_ruby_version: !ruby/object:Gem::Requirement
188
+ required_ruby_version: !ruby/object:Gem::Requirement
167
189
  none: false
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- version: "0"
172
- required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ! '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
195
  none: false
174
- requirements:
175
- - - ">="
176
- - !ruby/object:Gem::Version
177
- version: "0"
196
+ requirements:
197
+ - - ! '>='
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
178
200
  requirements: []
179
-
180
201
  rubyforge_project:
181
- rubygems_version: 1.8.15
202
+ rubygems_version: 1.8.23
182
203
  signing_key:
183
204
  specification_version: 3
184
205
  summary: A Ruby interface to the Avalara Tax API
185
- test_files:
206
+ test_files:
186
207
  - spec/avalara.yml.example
187
208
  - spec/factories/addresses.rb
188
209
  - spec/factories/detail_levels.rb
@@ -200,3 +221,4 @@ test_files:
200
221
  - spec/support/avalara.rb
201
222
  - spec/support/factory_girl.rb
202
223
  - spec/support/vcr.rb
224
+ has_rdoc:
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.2-p290@avalara
data/README DELETED
@@ -1,5 +0,0 @@
1
- Avalara
2
- =====
3
-
4
- This API provides access to the [Avalara](http://www.avalara.com/) AvaTax API.
5
-