avatax-ruby 0.0.2 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bcb3ffaacaeb247976527ec07b2f499cb91949c8
4
- data.tar.gz: 4ce1ff0d55b73959e697ad81a706f31b2d37bb61
2
+ SHA256:
3
+ metadata.gz: 1f90b02d8015d32707510258f79738ce9ceedb920e58c03081232103761d84ab
4
+ data.tar.gz: 7c07b5d7f237f7ac39c3f16528c8bb3fcd5392b071d9ca73bc610e0efa628947
5
5
  SHA512:
6
- metadata.gz: d141f70ce1dd1eec21a6ef62307c9555b04157f951fbc682b96f3a1102630229bd8f1f06d399a4903c58c155d7ca525e825a23ef5e8d4096b11569bc72c551c1
7
- data.tar.gz: f103ec5ce463743f21adae2d515a1932b4b04d83e1d998b10f4ee1f8207a5abd04bd413f1b4bdc0fcd22d1217afdb26ea2353073b39baa44e8e5949e1bfb8d49
6
+ metadata.gz: f09db180740224d767c14e9b2076df8c02ea531dcfb703bf979362e6f544359d0ffde8887b5b026f4c1915dc5ae654224f4a8313306dd580f0ac4b9b38dd2a88
7
+ data.tar.gz: 0a2190603770ff020c0e2414dcc0bfc28bf8427facd750bf23672d20d1de29e85410c27ee4114644e3253ac7709f39f8151962177c03c701d1211c1e254277f5
@@ -0,0 +1,18 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: circleci/ruby:2.3-jessie
6
+ steps:
7
+ - checkout
8
+ - run:
9
+ name: bundle install
10
+ command: bundle install
11
+ - run:
12
+ name: RSpec
13
+ command: bundle exec rspec
14
+ environment:
15
+ AVATAX_USERNAME: test
16
+ AVATAX_PASSWORD: test
17
+ AVATAX_ENV: sandbox
18
+
@@ -15,6 +15,9 @@ BlockLength:
15
15
  HttpPositionalArguments:
16
16
  Enabled: false
17
17
 
18
+ Naming/BinaryOperatorParameterName:
19
+ Enabled: false
20
+
18
21
  # We are going to use .html_safe for the time being
19
22
  Rails/OutputSafety:
20
23
  Enabled: false
@@ -60,9 +63,6 @@ Performance/Count:
60
63
  Style/RaiseArgs:
61
64
  Enabled: false
62
65
 
63
- Style/OpMethod:
64
- Enabled: false
65
-
66
66
  # We can use good judgement here
67
67
  Style/RegexpLiteral:
68
68
  Enabled: false
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.6.5
data/README.md CHANGED
@@ -9,13 +9,13 @@ See: http://developer.avalara.com/avatax/api-reference/tax/v2/
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'avatax-ruby', git: 'git@github.com:skukx/avatax.git', require: 'avatax'
12
+ gem 'avatax-ruby', git: 'git@github.com:skukx/avatax.git'
13
13
  ```
14
14
 
15
15
  Or
16
16
 
17
17
  ```ruby
18
- gem 'avatax-ruby', require: 'avatax'
18
+ gem 'avatax-ruby'
19
19
  ```
20
20
 
21
21
  And then execute:
@@ -29,6 +29,7 @@ And then execute:
29
29
  client = Avatax::Client.new(
30
30
  username: 'avatax_user',
31
31
  password: 'avatax_password',
32
+ logger: Logger.new(STDOUT),
32
33
  env: :sandbox
33
34
  )
34
35
  ```
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency 'faraday_middleware'
33
33
 
34
34
  spec.add_development_dependency "bundler", "~> 1.12"
35
- spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rake", "~> 12.3.3"
36
36
  spec.add_development_dependency 'rspec'
37
37
  spec.add_development_dependency 'rspec-its'
38
38
  spec.add_development_dependency 'vcr'
@@ -19,6 +19,7 @@ require 'avatax/api/nexus'
19
19
  require 'avatax/api/settings'
20
20
  require 'avatax/api/subscriptions'
21
21
  require 'avatax/api/tax_codes'
22
+ require 'avatax/api/tax_content'
22
23
  require 'avatax/api/tax_rates'
23
24
  require 'avatax/api/tax_rules'
24
25
  require 'avatax/api/transactions'
@@ -0,0 +1,31 @@
1
+ module Avatax
2
+ module Api
3
+ class TaxContent < Base
4
+ ##
5
+ # Download taxrates by zipcode
6
+ # @param date [Date] The date to get taxrates for
7
+ # @param args [Hash] The query to send along
8
+ # @options args [String] :region - The two character abbreviation for region
9
+ # @param on_data [Proc] - A lambda to run when data is received (For Streaming)
10
+ # See: https://lostisland.github.io/faraday/usage/streaming
11
+ #
12
+ def download_tax_rates_by_zipcode(date, args = {}, on_data = nil)
13
+ response = connection.get do |request|
14
+ request.url "/api/v2/taxratesbyzipcode/download/#{date}"
15
+ request.params = args
16
+ request.options.on_data = on_data if on_data
17
+ end
18
+
19
+ return if on_data
20
+
21
+ handle_response(response)
22
+ end
23
+
24
+ private
25
+
26
+ def format_date(date)
27
+ date.strftime('%Y-%m-%d')
28
+ end
29
+ end
30
+ end
31
+ end
@@ -89,7 +89,7 @@ module Avatax
89
89
  # @return [Avatax::Response]
90
90
  #
91
91
  def commit(company_code, transaction_code, args = {})
92
- args.reverse_merge(commit: true)
92
+ args.reverse_merge!(commit: true)
93
93
  post_for(:commit, company_code, transaction_code, args)
94
94
  end
95
95
 
@@ -133,6 +133,19 @@ module Avatax
133
133
  post_for(:void, company_code, transaction_code, args)
134
134
  end
135
135
 
136
+ ##
137
+ # Refund a transaction
138
+ # @see https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/RefundTransaction/
139
+ #
140
+ # @param company_code [String] The company_code in avatax.
141
+ # @param transaction_code [String] The current avatax transaction code.
142
+ # @param args [Hash] Arguments for avatax.
143
+ # @return [Avatax::Response]
144
+ #
145
+ def refund(company_code, transaction_code, args = {})
146
+ post_for(:refund, company_code, transaction_code, args)
147
+ end
148
+
136
149
  ##
137
150
  # Create a transaction
138
151
  # @see https://developer.avalara.com/avatax/api-reference/tax/v2/Transactions/#ApiV2TransactionsCreatePost
@@ -157,6 +170,20 @@ module Avatax
157
170
  handle_response(resp)
158
171
  end
159
172
 
173
+ ##
174
+ # Lock a transaction
175
+ # @see https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/LockTransaction
176
+ #
177
+ # @param company_code [String] The company_code in avatax.
178
+ # @param transaction_code [String] The avatax transaction code.
179
+ # @param args [Hash] Arguments for avatax.
180
+ # @return [Avatax::Response]
181
+ #
182
+ def lock(company_code, transaction_code, args = {})
183
+ args.reverse_merge!(isLocked: true)
184
+ post_for(:lock, company_code, transaction_code, args)
185
+ end
186
+
160
187
  private
161
188
 
162
189
  def post_for(endpoint, company_code, transaction_code, args)
@@ -36,6 +36,8 @@ module Avatax
36
36
 
37
37
  namespace :tax_codes
38
38
 
39
+ namespace :tax_content
40
+
39
41
  namespace :tax_rates
40
42
 
41
43
  namespace :tax_rules
@@ -50,8 +52,23 @@ module Avatax
50
52
 
51
53
  def initialize(args = {})
52
54
  @configuration = Avatax::Configuration.new(args)
55
+ @connection = args[:connection] || build_default_connection
56
+
57
+ create_instances
58
+ end
59
+
60
+ private
61
+
62
+ def create_instances
63
+ namespaces = self.class.instance_variable_get(:@namespaces)
64
+ namespaces.each do |klass|
65
+ reader = klass.to_s.split('::').last.underscore
66
+ self.class.send(:define_method, reader.to_sym) { klass.new @connection }
67
+ end
68
+ end
53
69
 
54
- @connection = Faraday.new(url: @configuration.base_url) do |conn|
70
+ def build_default_connection
71
+ Faraday.new(url: @configuration.base_url) do |conn|
55
72
  conn.request :json
56
73
  conn.request(
57
74
  :basic_auth,
@@ -61,23 +78,11 @@ module Avatax
61
78
 
62
79
  conn.headers = @configuration.headers
63
80
 
64
- conn.response :json
65
- conn.response :logger
81
+ conn.response :json, content_type: /\bjson$/
82
+ conn.response :logger, @configuration.logger
66
83
 
67
84
  conn.adapter Faraday.default_adapter
68
85
  end
69
-
70
- create_instances
71
- end
72
-
73
- private
74
-
75
- def create_instances
76
- namespaces = self.class.instance_variable_get(:@namespaces)
77
- namespaces.each do |klass|
78
- reader = klass.to_s.split('::').last.underscore
79
- self.class.send(:define_method, reader.to_sym) { klass.new @connection }
80
- end
81
86
  end
82
87
  end
83
88
  end
@@ -1,6 +1,7 @@
1
1
  module Avatax
2
2
  class Configuration
3
- attr_reader :sandbox, :base_url, :env, :username, :password, :headers
3
+ attr_reader :sandbox, :base_url, :env, :username, :password, :headers,
4
+ :logger
4
5
 
5
6
  REST_URLS = {
6
7
  sandbox: 'https://sandbox-rest.avatax.com',
@@ -21,6 +22,8 @@ module Avatax
21
22
 
22
23
  @username = args[:username]
23
24
  @password = args[:password]
25
+
26
+ @logger = args[:logger] || Logger.new(STDOUT)
24
27
  end
25
28
 
26
29
  private
@@ -1,3 +1,3 @@
1
1
  module Avatax
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avatax-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Scott
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-31 00:00:00.000000000 Z
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: 12.3.3
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: 12.3.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -171,6 +171,7 @@ executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
+ - ".circleci/config.yml"
174
175
  - ".gitignore"
175
176
  - ".rubocop.yml"
176
177
  - ".ruby-gemset"
@@ -182,7 +183,6 @@ files:
182
183
  - avatax.gemspec
183
184
  - bin/console
184
185
  - bin/setup
185
- - circle.yml
186
186
  - lib/avatax.rb
187
187
  - lib/avatax/api/accounts.rb
188
188
  - lib/avatax/api/addresses.rb
@@ -197,6 +197,7 @@ files:
197
197
  - lib/avatax/api/settings.rb
198
198
  - lib/avatax/api/subscriptions.rb
199
199
  - lib/avatax/api/tax_codes.rb
200
+ - lib/avatax/api/tax_content.rb
200
201
  - lib/avatax/api/tax_rates.rb
201
202
  - lib/avatax/api/tax_rules.rb
202
203
  - lib/avatax/api/transactions.rb
@@ -228,8 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
229
  - !ruby/object:Gem::Version
229
230
  version: '0'
230
231
  requirements: []
231
- rubyforge_project:
232
- rubygems_version: 2.5.1
232
+ rubygems_version: 3.0.8
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: Ruby client for Avatax
data/circle.yml DELETED
@@ -1,6 +0,0 @@
1
- dependencies:
2
- pre:
3
- - gem install bundler
4
- test:
5
- pre:
6
- - bundle exec rubocop