corgibytes-tax_cloud 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +10 -10
- data/.rubocop_todo.yml +6 -17
- data/README.md +6 -3
- data/Rakefile +0 -2
- data/examples/lookup_example.rb +43 -30
- data/lib/savon_soap_xml.rb +5 -9
- data/lib/tax_cloud/client.rb +3 -8
- data/lib/tax_cloud/transaction.rb +9 -9
- data/lib/tax_cloud/version.rb +1 -1
- data/test/helper.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMjU2":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
5
|
-
|
4
|
+
MWQ3OGNlMWUzOTZkMGI0NjkwNzI3OTUyNTBmMDZlNjcyMWRmNTc1MjNmMTNm
|
5
|
+
OThkZjhkNjMyOTkyMDM4Nzg2Zg==
|
6
6
|
data.tar.gz: !binary |-
|
7
|
-
|
8
|
-
|
7
|
+
YjBlYmU1OGMxNGNlZDhjODE0ODM5MTRjZTA0YmU4ZjYyMTVmNjM4YjViYTg5
|
8
|
+
NzMwMzUyZjk4MDJlNWM4YzBjYw==
|
9
9
|
SHA512:
|
10
10
|
metadata.gz: !binary |-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
ZDU1MzIxMzMxNGUwMjZiY2JiZTNhNmJiOWMwMmM2MjliYTliYmQ2N2U2MTY4
|
12
|
+
N2UwN2I1ZTRiYWY1MjU0MzI4ZDIzNzQyNjk4ZmE5YjZjYjcyNzIzMjJmNGNk
|
13
|
+
MjQ1ZDkwNjk2N2VlZjM0MzIwNThjZWQ2NGI1YmUxZWMxOWNjYzE=
|
14
14
|
data.tar.gz: !binary |-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
NjA1NTA0NmYzMzA3Y2Y5YzUwZDA2NGI2ODdmZjU1ZTBiMDMyNzBlMDUyZmU4
|
16
|
+
ZDczYmE2MTFlMzJmNjhhZDQ1MWM4ZGQwYmNkY2Q2MzgwMDQwMmQ1MzNmZjA2
|
17
|
+
ZjAyMDg2ZWU5Y2NjZDM0NGJlNmEyMDMyNTllYjQ4MDhiZWVlNmE=
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2019-04-30 18:06:16 +0000 using RuboCop version 0.41.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -12,36 +12,25 @@ Lint/AmbiguousRegexpLiteral:
|
|
12
12
|
- 'lib/tasks/tax_code_groups.rake'
|
13
13
|
- 'lib/tasks/tax_codes.rake'
|
14
14
|
|
15
|
-
# Offense count:
|
16
|
-
Lint/RescueWithoutErrorClass:
|
17
|
-
Exclude:
|
18
|
-
- 'lib/tasks/tax_code_groups.rake'
|
19
|
-
- 'lib/tasks/tax_codes.rake'
|
20
|
-
|
21
|
-
# Offense count: 4
|
15
|
+
# Offense count: 5
|
22
16
|
Metrics/AbcSize:
|
23
17
|
Max: 23
|
24
18
|
|
25
|
-
# Offense count: 5
|
26
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
27
|
-
Metrics/BlockLength:
|
28
|
-
Max: 39
|
29
|
-
|
30
19
|
# Offense count: 1
|
31
20
|
# Configuration parameters: CountComments.
|
32
21
|
Metrics/ClassLength:
|
33
22
|
Max: 261
|
34
23
|
|
35
|
-
# Offense count:
|
36
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes
|
24
|
+
# Offense count: 239
|
25
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
37
26
|
# URISchemes: http, https
|
38
27
|
Metrics/LineLength:
|
39
28
|
Max: 235
|
40
29
|
|
41
|
-
# Offense count:
|
30
|
+
# Offense count: 4
|
42
31
|
# Configuration parameters: CountComments.
|
43
32
|
Metrics/MethodLength:
|
44
|
-
Max:
|
33
|
+
Max: 15
|
45
34
|
|
46
35
|
# Offense count: 1
|
47
36
|
Style/Documentation:
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# TaxCloud
|
2
2
|
|
3
|
-
[
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/corgibytes-tax_cloud.svg)](https://badge.fury.io/rb/corgibytes-tax_cloud)
|
4
|
+
[![CircleCI](https://circleci.com/gh/corgibytes/tax_cloud/tree/master.svg?style=shield)](https://circleci.com/gh/corgibytes/tax_cloud/tree/master)
|
5
|
+
|
6
|
+
[TaxCloud](http://www.taxcloud.com) is a free service to calculate sales tax and generate tax reports. The Corgibytes TaxCloud [gem](https://rubygems.org/gems/corgibytes-tax_cloud) allows you to easily integrate with TaxCloud's API.
|
4
7
|
|
5
8
|
[Forked](https://github.com/drewtempelmeyer/tax_cloud) to add support for running this Gem on Ruby 1.9.3. See issue [#39](https://github.com/drewtempelmeyer/tax_cloud/issues/39) on the original repo for more details.
|
6
9
|
|
@@ -13,9 +16,9 @@ Create a [TaxCloud](http://www.taxcloud.com) merchant account at http://www.taxc
|
|
13
16
|
3. Once you have registered for your Shipping Assistant account, you can find your USPS Shipping Assistant UserID in the "About" box, in parentheses to the right of the name of the registered user.
|
14
17
|
|
15
18
|
### Setup
|
16
|
-
Add the gem to your Gemfile.
|
19
|
+
Add the Corgibytes TaxCloud [gem](https://rubygems.org/gems/corgibytes-tax_cloud) to your Gemfile.
|
17
20
|
|
18
|
-
gem 'tax_cloud'
|
21
|
+
gem 'corgibytes-tax_cloud', require: 'tax_cloud'
|
19
22
|
|
20
23
|
Configure your environment. For example, create an initializer in Rails in <tt>config/initializers/tax_cloud.rb</tt>.
|
21
24
|
|
data/Rakefile
CHANGED
data/examples/lookup_example.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# bundle exec ruby lookup_example.rb
|
5
5
|
#
|
6
6
|
# Make sure you copy the .env.example to .env an update the
|
7
|
-
# values in it before running. I also recommend
|
7
|
+
# values in it before running. I also recommend not running
|
8
8
|
# this script against a live TaxCloud site. Run it only against
|
9
9
|
# test sites.
|
10
10
|
##
|
@@ -15,8 +15,7 @@ require 'securerandom'
|
|
15
15
|
require_relative '../lib/tax_cloud'
|
16
16
|
|
17
17
|
##
|
18
|
-
# Load the TaxCloud settings from the environment file
|
19
|
-
#
|
18
|
+
# Load the TaxCloud settings from the environment file.
|
20
19
|
def load_config
|
21
20
|
TaxCloud.configure do |config|
|
22
21
|
config.api_login_id = ENV['TAX_CLOUD_LOGIN_ID']
|
@@ -28,7 +27,6 @@ end
|
|
28
27
|
|
29
28
|
##
|
30
29
|
# Display the current TaxCloud settings.
|
31
|
-
#
|
32
30
|
def display_config
|
33
31
|
TaxCloud.configure do |config|
|
34
32
|
puts "API Login ID: #{config.api_login_id}"
|
@@ -38,6 +36,34 @@ def display_config
|
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
39
|
+
##
|
40
|
+
# Create a origin address for the lookup example.
|
41
|
+
#
|
42
|
+
# @return [TaxCloud::Address]
|
43
|
+
def create_test_origin
|
44
|
+
TaxCloud::Address.new(
|
45
|
+
address1: '162 East Avenue',
|
46
|
+
address2: 'Third Floor',
|
47
|
+
city: 'Norwalk',
|
48
|
+
state: 'CT',
|
49
|
+
zip5: '06851'
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Create a destination address for the lookup example.
|
55
|
+
#
|
56
|
+
# @return [TaxCloud::Address]
|
57
|
+
def create_test_destination
|
58
|
+
TaxCloud::Address.new(
|
59
|
+
address1: '3121 West Government Way',
|
60
|
+
address2: 'Suite 2B',
|
61
|
+
city: 'Seattle',
|
62
|
+
state: 'WA',
|
63
|
+
zip5: '98199'
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
41
67
|
##
|
42
68
|
# Create a test transaction with one cart item.
|
43
69
|
#
|
@@ -45,33 +71,22 @@ end
|
|
45
71
|
# the customer and cart IDs. This prevents collisions with
|
46
72
|
# existing customer/carts when running the script multiple times.
|
47
73
|
#
|
74
|
+
# @return [TaxCloud::Transaction]
|
48
75
|
def create_test_transaction
|
49
|
-
origin = TaxCloud::Address.new(
|
50
|
-
:address1 => '162 East Avenue',
|
51
|
-
:address2 => 'Third Floor',
|
52
|
-
:city => 'Norwalk',
|
53
|
-
:state => 'CT',
|
54
|
-
:zip5 => '06851')
|
55
|
-
|
56
|
-
destination = TaxCloud::Address.new(
|
57
|
-
:address1 => '3121 West Government Way',
|
58
|
-
:address2 => 'Suite 2B',
|
59
|
-
:city => 'Seattle',
|
60
|
-
:state => 'WA',
|
61
|
-
:zip5 => '98199')
|
62
|
-
|
63
76
|
transaction = TaxCloud::Transaction.new(
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
77
|
+
customer_id: SecureRandom.uuid,
|
78
|
+
cart_id: SecureRandom.uuid,
|
79
|
+
origin: create_test_origin,
|
80
|
+
destination: create_test_destination
|
81
|
+
)
|
68
82
|
|
69
83
|
transaction.cart_items << TaxCloud::CartItem.new(
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
84
|
+
index: 0,
|
85
|
+
item_id: 'SKU-100',
|
86
|
+
tic: TaxCloud::TaxCodes::GENERAL,
|
87
|
+
price: 10.00,
|
88
|
+
quantity: 1
|
89
|
+
)
|
75
90
|
|
76
91
|
transaction
|
77
92
|
end
|
@@ -86,7 +101,6 @@ end
|
|
86
101
|
# - Cart Items
|
87
102
|
#
|
88
103
|
# @param [TaxCloud::Transaction] transaction
|
89
|
-
#
|
90
104
|
def display_transaction(transaction)
|
91
105
|
puts "Customer ID: #{transaction.customer_id}"
|
92
106
|
puts "Cart ID: #{transaction.cart_id}"
|
@@ -107,7 +121,6 @@ def display_tax(lookup)
|
|
107
121
|
end
|
108
122
|
end
|
109
123
|
|
110
|
-
|
111
124
|
##
|
112
125
|
# Run an example lookup
|
113
126
|
##
|
@@ -136,4 +149,4 @@ puts
|
|
136
149
|
puts 'Tax lookup:'
|
137
150
|
lookup = transaction.lookup
|
138
151
|
display_tax(lookup)
|
139
|
-
puts
|
152
|
+
puts
|
data/lib/savon_soap_xml.rb
CHANGED
@@ -2,15 +2,12 @@
|
|
2
2
|
module Savon #:nodoc:
|
3
3
|
module SOAP #:nodoc:
|
4
4
|
class XML #:nodoc:
|
5
|
-
|
6
5
|
private
|
7
6
|
|
8
|
-
old_add_namespaces_to_body = self.instance_method(:add_namespaces_to_body)
|
9
|
-
|
10
7
|
def add_namespaces_to_body(hash, path = [input[1].to_s])
|
11
8
|
return unless hash
|
12
|
-
return hash if hash.
|
13
|
-
return hash.to_s unless hash.
|
9
|
+
return hash if hash.is_a? Array
|
10
|
+
return hash.to_s unless hash.is_a? Hash
|
14
11
|
|
15
12
|
hash.inject({}) do |newhash, (key, value)|
|
16
13
|
camelcased_key = Gyoku::XMLKey.create(key)
|
@@ -18,15 +15,14 @@ module Savon #:nodoc:
|
|
18
15
|
|
19
16
|
if used_namespaces[newpath]
|
20
17
|
newhash.merge(
|
21
|
-
|
22
|
-
|
18
|
+
"#{used_namespaces[newpath]}:#{camelcased_key}" =>
|
19
|
+
add_namespaces_to_body(value, types[newpath] ? [types[newpath]] : newpath)
|
23
20
|
)
|
24
21
|
else
|
25
22
|
newhash.merge(key => value)
|
26
23
|
end
|
27
24
|
end
|
28
25
|
end
|
29
|
-
|
30
26
|
end
|
31
27
|
end
|
32
|
-
end
|
28
|
+
end
|
data/lib/tax_cloud/client.rb
CHANGED
@@ -5,13 +5,8 @@ module TaxCloud #:nodoc:
|
|
5
5
|
def initialize
|
6
6
|
super TaxCloud::WSDL_URL
|
7
7
|
|
8
|
-
if client_params.key?(:read_timeout)
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
if client_params.key?(:open_timeout)
|
13
|
-
http.open_timeout = client_params[:open_timeout]
|
14
|
-
end
|
8
|
+
http.read_timeout = client_params[:read_timeout] if client_params.key?(:read_timeout)
|
9
|
+
http.open_timeout = client_params[:open_timeout] if client_params.key?(:open_timeout)
|
15
10
|
end
|
16
11
|
|
17
12
|
# Make a safe SOAP call.
|
@@ -22,7 +17,7 @@ module TaxCloud #:nodoc:
|
|
22
17
|
# [body] Body content.
|
23
18
|
def request(method, body = {})
|
24
19
|
safe do
|
25
|
-
super method, :
|
20
|
+
super method, body: body.merge(auth_params)
|
26
21
|
end
|
27
22
|
end
|
28
23
|
|
@@ -42,9 +42,9 @@ module TaxCloud #:nodoc:
|
|
42
42
|
# Once a purchase has been made and payment has been authorized, this method must be called. A matching Lookup call must have been made before this is called.
|
43
43
|
#
|
44
44
|
# === Options
|
45
|
-
#
|
45
|
+
# [date_authorized] - The date the transaction was authorized. Default is today respecting timezone.
|
46
46
|
def authorized(options = {})
|
47
|
-
options = { date_authorized: Date.
|
47
|
+
options = { date_authorized: Date.current }.merge(options)
|
48
48
|
|
49
49
|
request_params = {
|
50
50
|
'customerID' => customer_id,
|
@@ -60,9 +60,9 @@ module TaxCloud #:nodoc:
|
|
60
60
|
# Complete the transaction. The <tt>order_id</tt> passed into <tt>captured</tt> must match the <tt>order_id</tt> that was passed into <tt>authorized</tt>.
|
61
61
|
#
|
62
62
|
# === Options
|
63
|
-
# [date_captured] The time the transaction was captured. Default is today.
|
63
|
+
# [date_captured] The time the transaction was captured. Default is today respecting timezone.
|
64
64
|
def captured(options = {})
|
65
|
-
options = { date_captured: Date.
|
65
|
+
options = { date_captured: Date.current }.merge(options)
|
66
66
|
request_params = {
|
67
67
|
'customerID' => customer_id,
|
68
68
|
'cartID' => cart_id,
|
@@ -77,10 +77,10 @@ module TaxCloud #:nodoc:
|
|
77
77
|
# Combines the <tt>authorized</tt> and <tt>captured</tt> methods into a single call
|
78
78
|
#
|
79
79
|
# === Options
|
80
|
-
# [date_authorized] The date the transaction was authorized. Default is today.
|
81
|
-
# [date_captured] - The date the transaction was captured. Default is today.
|
80
|
+
# [date_authorized] The date the transaction was authorized. Default is today respecting timezone.
|
81
|
+
# [date_captured] - The date the transaction was captured. Default is today respecting timezone.
|
82
82
|
def authorized_with_capture(options = {})
|
83
|
-
options = { date_authorized: Date.
|
83
|
+
options = { date_authorized: Date.current, date_captured: Date.current }.merge(options)
|
84
84
|
request_params = {
|
85
85
|
'customerID' => customer_id,
|
86
86
|
'cartID' => cart_id,
|
@@ -96,9 +96,9 @@ module TaxCloud #:nodoc:
|
|
96
96
|
# Marks any included cart items as returned.
|
97
97
|
#
|
98
98
|
# === Options
|
99
|
-
# [returned_date] The date the return occured. Default is today.
|
99
|
+
# [returned_date] The date the return occured. Default is today respecting timezone.
|
100
100
|
def returned(options = {})
|
101
|
-
options = { returned_date: Date.
|
101
|
+
options = { returned_date: Date.current }.merge(options)
|
102
102
|
request_params = {
|
103
103
|
'orderID' => order_id,
|
104
104
|
'cartItems' => { 'CartItem' => cart_items.map(&:to_hash) },
|
data/lib/tax_cloud/version.rb
CHANGED
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: corgibytes-tax_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corgibytes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|