tax_cloud 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +30 -0
  3. data/.rubocop.yml +9 -25
  4. data/.rubocop_todo.yml +47 -0
  5. data/CHANGELOG.md +85 -0
  6. data/CONTRIBUTORS.txt +3 -0
  7. data/Gemfile +15 -5
  8. data/LICENSE.md +21 -0
  9. data/README.md +200 -0
  10. data/Rakefile +5 -19
  11. data/lib/config/locales/en.yml +2 -2
  12. data/lib/hash.rb +3 -4
  13. data/lib/tasks/tax_cloud.rake +4 -4
  14. data/lib/tasks/tax_code_groups.rake +11 -11
  15. data/lib/tasks/tax_codes.rake +12 -12
  16. data/lib/tax_cloud/address.rb +10 -5
  17. data/lib/tax_cloud/cart_item.rb +2 -0
  18. data/lib/tax_cloud/client.rb +13 -3
  19. data/lib/tax_cloud/configuration.rb +13 -2
  20. data/lib/tax_cloud/errors/api_error.rb +3 -3
  21. data/lib/tax_cloud/errors/missing_config_error.rb +2 -1
  22. data/lib/tax_cloud/errors/missing_config_option_error.rb +2 -1
  23. data/lib/tax_cloud/errors/soap_error.rb +6 -6
  24. data/lib/tax_cloud/errors/tax_cloud_error.rb +5 -4
  25. data/lib/tax_cloud/errors/unexpected_soap_response_error.rb +3 -3
  26. data/lib/tax_cloud/errors.rb +2 -0
  27. data/lib/tax_cloud/record.rb +2 -0
  28. data/lib/tax_cloud/responses/authorized.rb +3 -1
  29. data/lib/tax_cloud/responses/authorized_with_capture.rb +3 -1
  30. data/lib/tax_cloud/responses/base.rb +5 -4
  31. data/lib/tax_cloud/responses/captured.rb +3 -1
  32. data/lib/tax_cloud/responses/cart_item.rb +6 -2
  33. data/lib/tax_cloud/responses/generic.rb +2 -0
  34. data/lib/tax_cloud/responses/lookup.rb +10 -8
  35. data/lib/tax_cloud/responses/ping.rb +3 -1
  36. data/lib/tax_cloud/responses/returned.rb +3 -1
  37. data/lib/tax_cloud/responses/tax_code_groups.rb +3 -1
  38. data/lib/tax_cloud/responses/tax_codes.rb +3 -1
  39. data/lib/tax_cloud/responses/tax_codes_by_group.rb +3 -1
  40. data/lib/tax_cloud/responses/verify_address.rb +3 -1
  41. data/lib/tax_cloud/responses.rb +2 -0
  42. data/lib/tax_cloud/tax_code.rb +2 -0
  43. data/lib/tax_cloud/tax_code_constants.rb +262 -260
  44. data/lib/tax_cloud/tax_code_group.rb +3 -1
  45. data/lib/tax_cloud/tax_code_group_constants.rb +2 -0
  46. data/lib/tax_cloud/tax_code_groups.rb +3 -1
  47. data/lib/tax_cloud/tax_codes.rb +3 -1
  48. data/lib/tax_cloud/transaction.rb +2 -0
  49. data/lib/tax_cloud/version.rb +3 -1
  50. data/lib/tax_cloud.rb +8 -3
  51. data/tax_cloud.gemspec +17 -18
  52. data/test/cassettes/authorized.yml +6 -6
  53. data/test/cassettes/authorized_with_capture.yml +6 -6
  54. data/test/cassettes/authorized_with_localized_time.yml +6 -6
  55. data/test/cassettes/captured.yml +7 -7
  56. data/test/cassettes/get_tic_groups.yml +5 -5
  57. data/test/cassettes/get_tics.yml +5 -5
  58. data/test/cassettes/get_tics_by_group.yml +5 -5
  59. data/test/cassettes/invalid_soap_call.yml +5 -5
  60. data/test/cassettes/lookup.yml +5 -5
  61. data/test/cassettes/lookup_ny.yml +5 -5
  62. data/test/cassettes/ping.yml +5 -5
  63. data/test/cassettes/ping_with_invalid_credentials.yml +5 -5
  64. data/test/cassettes/ping_with_invalid_response.yml +5 -5
  65. data/test/cassettes/returned.yml +7 -7
  66. data/test/cassettes/verify_bad_address.yml +5 -5
  67. data/test/cassettes/verify_good_address.yml +5 -5
  68. data/test/helper.rb +3 -1
  69. data/test/test_address.rb +7 -5
  70. data/test/test_cart_item.rb +3 -1
  71. data/test/test_client.rb +4 -2
  72. data/test/test_configuration_optional_keys.rb +44 -0
  73. data/test/{test_configuration.rb → test_configuration_required_keys.rb} +6 -4
  74. data/test/test_lookup_response.rb +22 -0
  75. data/test/test_setup.rb +3 -1
  76. data/test/test_soap.rb +3 -1
  77. data/test/test_tax_code_groups.rb +4 -2
  78. data/test/test_tax_codes.rb +3 -1
  79. data/test/test_transaction.rb +3 -1
  80. data/test/test_transaction_ny.rb +3 -1
  81. data/test/vcr_setup.rb +2 -0
  82. metadata +37 -91
  83. data/.travis.yml +0 -6
  84. data/CHANGELOG.rdoc +0 -42
  85. data/LICENSE.rdoc +0 -22
  86. data/README.rdoc +0 -140
data/LICENSE.rdoc DELETED
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2011-2012 Drew Tempelmeyer & Contributors
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.rdoc DELETED
@@ -1,140 +0,0 @@
1
- = TaxCloud
2
-
3
- {<img src="https://travis-ci.org/drewtempelmeyer/tax_cloud.png" />}[https://travis-ci.org/drewtempelmeyer/tax_cloud]
4
-
5
- TaxCloud[http://www.taxcloud.com] is a free service to calculate sales tax and generate tax reports. The <tt>tax_cloud</tt> gem allows you to easily integrate with TaxCloud's API.
6
-
7
- === Getting Started
8
- Create a TaxCloud[http://www.taxcloud.com] merchant account at http://www.taxcloud.net. Add a website to your account under Locations[https://taxcloud.net/account/locations]. This will generate an API ID and API Key that you will need to use the service.
9
-
10
- TaxCloud[http://www.taxcloud.com] also offers an optional address verification API. To use it, you need a USPS (United States Postal Service) Address API UserID. To obtain your USPS UserID:
11
- 1. Download and Install the USPS Shipping Assistant from http://www.usps.com/shippingassistant.
12
- 2. Launch the USPS Shipping Assistant and go through the Shipping Assistant registration process.
13
- 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
-
15
- === Setup
16
- Add the gem to your Gemfile.
17
-
18
- gem 'tax_cloud'
19
-
20
- Configure your environment. For example, create an initializer in Rails in <tt>config/initializers/tax_cloud.rb</tt>.
21
-
22
- TaxCloud.configure do |config|
23
- config.api_login_id = 'your_tax_cloud_api_login_id'
24
- config.api_key = 'your_tax_cloud_api_key'
25
- config.usps_username = 'your_usps_username'
26
- end
27
-
28
- === Using TaxCloud
29
- Define the destination and origin addresses using <tt>TaxCloud::Address</tt>.
30
-
31
- origin = TaxCloud::Address.new(
32
- :address1 => '162 East Avenue',
33
- :address2 => 'Third Floor',
34
- :city => 'Norwalk',
35
- :state => 'CT',
36
- :zip5 => '06851')
37
- destination = TaxCloud::Address.new(
38
- :address1 => '3121 West Government Way',
39
- :address2 => 'Suite 2B',
40
- :city => 'Seattle',
41
- :state => 'WA',
42
- :zip5 => '98199')
43
-
44
- Create your Transaction and set up your cart items
45
-
46
- transaction = TaxCloud::Transaction.new(
47
- :customer_id => '1',
48
- :cart_id => '1',
49
- :origin => origin,
50
- :destination => destination)
51
- transaction.cart_items << TaxCloud::CartItem.new(
52
- :index => 0,
53
- :item_id => 'SKU-100',
54
- :tic => TaxCloud::TaxCodes::GENERAL,
55
- :price => 10.00,
56
- :quantity => 1)
57
- lookup = transaction.lookup # this will return a TaxCloud::Responses::Lookup instance
58
- lookup.tax_amount # total tax amount
59
- lookup.cart_items.each do |cart_item|
60
- cart_item.tax_amount # tax for a single item
61
- end
62
-
63
- After you've authorized and captured the transaction via your merchant account, you should do the same with TaxCloud for maintaining accurate tax information.
64
-
65
- transaction.order_id = 100
66
- transaction.authorized_with_capture # returns "OK" or raises an error
67
-
68
- Later, you may need to mark some cart items as returned. TaxCloud will ignore any cart items that you don't include.
69
-
70
- transaction.order_id = 100
71
- transaction.cart_items << TaxCloud::CartItem.new(
72
- :index => 0,
73
- :item_id => 'SKU-100',
74
- :tic => TaxCloud::TaxCodes::GENERAL,
75
- :price => 10.00,
76
- :quantity => 1)
77
- transaction.returned # returns "OK" or raises an error
78
-
79
- === Verifying Addresses
80
-
81
- TaxCloud[http://www.taxcloud.com] optionally integrates with the USPS Address API. An address can be verified, which can also yield a 9-digit zip code that helps determine a more accurate tax rate.
82
-
83
- address = TaxCloud::Address.new({
84
- :address1 => '888 6th Ave',
85
- :city => 'New York',
86
- :state => 'New York',
87
- :zip5 => '10001'
88
- })
89
-
90
- verified_address = address.verify
91
- verified_address.zip5 # 10001
92
- verified_address.zip4 # 3502
93
- verified_address.zip # 10001-3502
94
-
95
- === Tax Codes
96
- TaxCloud[http://www.taxcloud.com] maintains a list of all Taxability Information Codes or TICs, which can be found at https://taxcloud.net/tic.
97
-
98
- You can obtain all tax codes as well as lookup a tax code by ID.
99
-
100
- TaxCloud::TaxCodes.all # a hash of all codes
101
- tax_code = TaxCloud::TaxCodes[TaxCloud::TaxCodes::DIRECT_MAIL_RELATED]
102
- tax_code.ticid # 11000 or TaxCloud::TaxCodes::DIRECT_MAIL_RELATED
103
- tax_code.description # "Direct-mail related"
104
-
105
- Tax codes are organized in groups.
106
-
107
- TaxCloud::TaxCode::Groups.all # a hash of all groups
108
- tax_code_group = TaxCloud::TaxCode::Groups[TaxCloud::TaxCode::Groups::SCHOOL_RELATED_PRODUCTS]
109
- tax_code_group.group_id # 3 or TaxCloud::TaxCode::Groups::SCHOOL_RELATED_PRODUCTS
110
- tax_code_group.description # School Related Products
111
- tax_code_group.tax_codes # a hash of all codes in this group
112
-
113
- Tax code constants are defined in <tt>tax_code_constants.rb</tt> and tax code group constants in <tt>tax_code_group_constants.rb</tt>. These files can be generated by running the following rake tasks.
114
-
115
- TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... tax_cloud:tax_codes
116
- TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... tax_cloud:tax_code_groups
117
-
118
- === Tax States
119
- TaxCloud manages a list of states in which you can calculate sales tax. The default setup will only have SSUTA (Streamlined Sales and Use Tax Agreement) states enabled. All other states will return $0 for tax values. To enable other states, go to https://taxcloud.net/account/states. You can find more information about SSUTA here[http://www.streamlinedsalestax.org/index.php?page=About-Us].
120
-
121
- === Running Tests
122
- * VCR and WebMock are used to replay requests and avoid hitting the API each time. To refresh the mocks, simply delete the <tt>test/cassettes</tt> directory.
123
- * Run tests.
124
- rake test
125
- * If you need to record new requests against TaxCloud, set your keys first.
126
- TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... rake test
127
- The mocks will filter out your configuration details.
128
-
129
- === Bugs, fixes, etc
130
- * Fork.
131
- * Write test(s).
132
- * Fix.
133
- * Commit.
134
- * Submit pull request.
135
-
136
- === License
137
-
138
- Copyright Drew Tempelmeyer and contributors, 2011-2014.
139
-
140
- This gem is licensed under the MIT license.