TaxCloud 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.gitignore +8 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +79 -0
  4. data/README +93 -0
  5. data/config.ru +2 -0
  6. data/doc/Gemfile.html +143 -0
  7. data/doc/Helper.html +249 -0
  8. data/doc/Object.html +193 -0
  9. data/doc/README.html +245 -0
  10. data/doc/TaxCloud.html +244 -0
  11. data/doc/TaxCloud/Address.html +356 -0
  12. data/doc/TaxCloud/AuthorizedResponse.html +226 -0
  13. data/doc/TaxCloud/AuthorizedService.html +304 -0
  14. data/doc/TaxCloud/AuthorizedWithCaptureResponse.html +246 -0
  15. data/doc/TaxCloud/BaseService.html +243 -0
  16. data/doc/TaxCloud/CapturedResponse.html +226 -0
  17. data/doc/TaxCloud/CartItem.html +341 -0
  18. data/doc/TaxCloud/CartItemResponse.html +256 -0
  19. data/doc/TaxCloud/CartItemsResponse.html +286 -0
  20. data/doc/TaxCloud/GetTICsResponse.html +284 -0
  21. data/doc/TaxCloud/LookupResponse.html +259 -0
  22. data/doc/TaxCloud/LookupService.html +230 -0
  23. data/doc/TaxCloud/MessageType.html +205 -0
  24. data/doc/TaxCloud/ResponseBase.html +214 -0
  25. data/doc/TaxCloud/ResponseMessage.html +212 -0
  26. data/doc/TaxCloud/ResponseType.html +212 -0
  27. data/doc/TaxCloud/ReturnedResponse.html +226 -0
  28. data/doc/TaxCloud/ReturnedService.html +231 -0
  29. data/doc/TaxCloud/TIC.html +272 -0
  30. data/doc/TaxCloud/TICService.html +292 -0
  31. data/doc/TaxCloud/VerifyAddressResult.html +361 -0
  32. data/doc/TaxCloud/VerifyAddressService.html +236 -0
  33. data/doc/created.rid +33 -0
  34. data/doc/images/add.png +0 -0
  35. data/doc/images/brick.png +0 -0
  36. data/doc/images/brick_link.png +0 -0
  37. data/doc/images/bug.png +0 -0
  38. data/doc/images/bullet_black.png +0 -0
  39. data/doc/images/bullet_toggle_minus.png +0 -0
  40. data/doc/images/bullet_toggle_plus.png +0 -0
  41. data/doc/images/date.png +0 -0
  42. data/doc/images/delete.png +0 -0
  43. data/doc/images/find.png +0 -0
  44. data/doc/images/loadingAnimation.gif +0 -0
  45. data/doc/images/macFFBgHack.png +0 -0
  46. data/doc/images/package.png +0 -0
  47. data/doc/images/page_green.png +0 -0
  48. data/doc/images/page_white_text.png +0 -0
  49. data/doc/images/page_white_width.png +0 -0
  50. data/doc/images/plugin.png +0 -0
  51. data/doc/images/ruby.png +0 -0
  52. data/doc/images/tag_blue.png +0 -0
  53. data/doc/images/tag_green.png +0 -0
  54. data/doc/images/transparent.png +0 -0
  55. data/doc/images/wrench.png +0 -0
  56. data/doc/images/wrench_orange.png +0 -0
  57. data/doc/images/zoom.png +0 -0
  58. data/doc/index.html +130 -0
  59. data/doc/js/darkfish.js +153 -0
  60. data/doc/js/jquery.js +18 -0
  61. data/doc/js/navigation.js +142 -0
  62. data/doc/js/search.js +94 -0
  63. data/doc/js/search_index.js +1 -0
  64. data/doc/js/searcher.js +228 -0
  65. data/doc/rdoc.css +543 -0
  66. data/doc/table_of_contents.html +200 -0
  67. data/lib/address.rb +27 -0
  68. data/lib/cartitem.rb +28 -0
  69. data/lib/response/authorized_response.rb +15 -0
  70. data/lib/response/authorized_with_capture_response.rb +16 -0
  71. data/lib/response/captured_response.rb +15 -0
  72. data/lib/response/cart_item_response.rb +11 -0
  73. data/lib/response/cart_items_response.rb +22 -0
  74. data/lib/response/get_ti_cs_response.rb +18 -0
  75. data/lib/response/lookup_response.rb +24 -0
  76. data/lib/response/message_type.rb +12 -0
  77. data/lib/response/response_base.rb +10 -0
  78. data/lib/response/response_message.rb +9 -0
  79. data/lib/response/response_type.rb +9 -0
  80. data/lib/response/returned_response.rb +15 -0
  81. data/lib/response/verify_address_result.rb +21 -0
  82. data/lib/service/authorized_service.rb +40 -0
  83. data/lib/service/base_service.rb +13 -0
  84. data/lib/service/lookup_service.rb +20 -0
  85. data/lib/service/returned_service.rb +19 -0
  86. data/lib/service/tic_service.rb +26 -0
  87. data/lib/service/verify_address_service.rb +26 -0
  88. data/lib/tic.rb +14 -0
  89. data/spec/helper.rb +38 -0
  90. data/spec/service/authorized_service_spec.rb +66 -0
  91. data/spec/service/lookup_service_spec.rb +45 -0
  92. data/spec/service/returned_service_spec.rb +36 -0
  93. data/spec/service/tic_serivce_spec.rb +47 -0
  94. data/spec/service/verify_address_service_spec.rb +24 -0
  95. data/spec/spec_helper.rb +12 -0
  96. data/taxcloud.gemspec +18 -0
  97. metadata +117 -3
@@ -0,0 +1,21 @@
1
+ module TaxCloud
2
+
3
+ class VerifyAddressResult
4
+
5
+ attr_accessor :address1, :address2, :city, :state, :zip5, :zip4, :err_number
6
+
7
+ def initialize(attrs = {})
8
+ attrs.each do |sym, val|
9
+ self.send "#{sym}=", val
10
+ end
11
+ end
12
+
13
+ def get_address
14
+ address = TaxCloud::Address.new(:address1 => @address1, :address2 => @address2, :city => @city, :state => @state, :zip5 => @zip5, :zip4 => @zip4)
15
+ end
16
+
17
+
18
+ end
19
+
20
+ end
21
+
@@ -0,0 +1,40 @@
1
+ module TaxCloud
2
+ require "service/base_service"
3
+ require "response/authorized_response"
4
+ require "response/authorized_with_capture_response"
5
+ require "response/captured_response"
6
+
7
+ class AuthorizedService < BaseService
8
+
9
+ def authorized_with_capture(api_id, api_key, customer_id, cart_id, order_id, date_authorized, date_captured)
10
+ response = client.request :authorized_with_capture do
11
+ soap.body = {:apiLoginID => api_id, :apiKey => api_key,
12
+ 'customerID' => customer_id, 'cartID' => cart_id, 'orderID' => order_id, 'dateAuthorized' => date_authorized, 'dateCaptured' => date_captured}
13
+
14
+ end
15
+
16
+ authorized_with_capture_rsp = TaxCloud::AuthorizedWithCaptureResponse.new(response.to_hash[:authorized_with_capture_response][:authorized_with_capture_result])
17
+ end
18
+
19
+ def authorized(api_id, api_key, customer_id, cart_id, order_id, date_authorized)
20
+ response = client.request :authorized do
21
+ soap.body = {:apiLoginID => api_id, :apiKey => api_key,
22
+ 'customerID' => customer_id, 'cartID' => cart_id, 'orderID' => order_id, 'dateAuthorized' => date_authorized}
23
+
24
+ end
25
+
26
+ authorized_response = TaxCloud::AuthorizedResponse.new(response.to_hash[:authorized_response][:authorized_result])
27
+
28
+ end
29
+
30
+ def captured(api_id, api_key, order_id)
31
+ response = client.request :captured do
32
+ soap.body = {:apiLoginID => api_id, :apiKey => api_key, 'orderID' => order_id}
33
+ end
34
+
35
+ captured_response = TaxCloud::CapturedResponse.new(response.to_hash[:captured_response][:captured_result])
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,13 @@
1
+ module TaxCloud
2
+
3
+ class BaseService
4
+
5
+ attr_accessor :client
6
+
7
+ def initialize(client)
8
+ self.client = client
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,20 @@
1
+ module TaxCloud
2
+ require "service/base_service"
3
+ require "response/lookup_response"
4
+
5
+ class LookupService < BaseService
6
+
7
+ def lookup(api_id, api_key, customer_id, cart_id, origin, destination, cart_items)
8
+
9
+ response = client.request :lookup do
10
+ soap.body = {:apiLoginID => api_id, :apiKey => api_key,
11
+ 'customerID' => customer_id, 'cartID' => cart_id, 'cartItems' => {'CartItem' => cart_items.map(&:to_hash)}, 'origin' => origin.to_hash, 'destination' => destination.to_hash}
12
+ end
13
+
14
+ lookupResponse = TaxCloud::LookupResponse.new(response.to_hash[:lookup_response][:lookup_result])
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,19 @@
1
+ module TaxCloud
2
+
3
+ require 'response/returned_response'
4
+
5
+ # If you have previously completed an order you can return one or more of the items in the order
6
+ class ReturnedService < BaseService
7
+
8
+ def returned(api_id, api_key, order_id, cart_items, returned_date)
9
+ response = client.request :returned do
10
+ soap.body = {:apiLoginID => api_id, :apiKey => api_key,
11
+ 'orderID' => order_id, 'cartItems' => {'CartItem' => cart_items.map(&:to_hash)}, 'returnedDate' => returned_date}
12
+ end
13
+
14
+ returned_response = TaxCloud::ReturnedResponse.new(response.to_hash[:returned_response][:returned_result])
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,26 @@
1
+ module TaxCloud
2
+ require "service/base_service"
3
+ require 'response/get_ti_cs_response'
4
+
5
+ class TICService < BaseService
6
+
7
+ def get_tics(api_id, api_key)
8
+
9
+ response = client.request :get_ti_cs do
10
+ soap.body = {:apiLoginID => api_id, :apiKey => api_key}
11
+ end
12
+
13
+ get_tics_response = TaxCloud::GetTICsResponse.new(response.to_hash[:get_ti_cs_response][:get_ti_cs_result])
14
+ end
15
+
16
+ def get_tic_groups(api_id, api_key)
17
+ #get_tic_groups
18
+ end
19
+
20
+ def get_tics_by_group(api_id, api_key, group_id)
21
+ #get_ti_cs_by_group
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,26 @@
1
+ module TaxCloud
2
+
3
+ require "service/base_service"
4
+
5
+ class VerifyAddressService < BaseService
6
+
7
+ def verify_address(api_id, api_key, usps_id, address)
8
+ request_params = {
9
+ 'apiLoginId' => api_id,
10
+ 'apiKey' => api_key,
11
+ 'uspsUserID' => usps_id,
12
+ 'address1' => address.address1,
13
+ 'address2' => address.address2,
14
+ 'city' => address.city,
15
+ 'state' => address.state,
16
+ 'zip5' => address.zip5,
17
+ 'zip4' => address.zip4
18
+ }
19
+ response = client.request :verify_address, :body => request_params
20
+
21
+ verifyAddressResult = TaxCloud::VerifyAddressResult.new(response.to_hash[:verify_address_response][:verify_address_result])
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,14 @@
1
+ module TaxCloud
2
+ class TIC
3
+ attr_accessor :tic, :tic_id, :description
4
+
5
+ def initialize(tic)
6
+ puts 'initialize: ' + tic.to_s
7
+ self.tic = tic
8
+ self.tic_id = tic['ticid']
9
+ self.description = tic['description']
10
+ end
11
+
12
+
13
+ end
14
+ end
@@ -0,0 +1,38 @@
1
+ module Helper
2
+
3
+ def variable_init
4
+ @client = Savon::Client.new do
5
+ wsdl.document = "https://api.taxcloud.net/1.0/TaxCloud.asmx?wsdl"
6
+ end
7
+ cart_item = TaxCloud::CartItem.new(:index => 0, :item_id => 0, :tic => '00000', :price => '19.99', :quantity => 1)
8
+ cart_item1 = TaxCloud::CartItem.new(:index => 1, :item_id => 1, :tic => '20010', :price => '9.99', :quantity => 1)
9
+
10
+ # Add a cart item for shipping charges, if applicable
11
+ cart_item2 = TaxCloud::CartItem.new(:index => 2, :item_id => 99999, :tic => '11010', :price => '19.99', :quantity => 1)
12
+
13
+ @cart_items = Array.new
14
+ @cart_items << cart_item
15
+ @cart_items << cart_item1
16
+ @cart_items << cart_item2
17
+
18
+ @origin = TaxCloud::Address.new(:address1 => '162 East Avenue', :address2 => 'Third Floor', :city => 'Norwalk', :state => 'CT', :zip5 => '06851')
19
+
20
+ #origin = verify_address(client, origin)
21
+
22
+ @destination = TaxCloud::Address.new(:address1 => '3121 West Government Way', :address2 => 'Suite 2B', :city => 'Seattle', :state => 'WA', :zip5 => '98199')
23
+
24
+ #destination = verify_address(client, destination)
25
+ @customer_id = 1
26
+ @cart_id = nil
27
+ @order_id = 1
28
+
29
+ # You will have to populate these values from your TaxCloud merchant account
30
+ @api_id = ""
31
+ @api_key = ""
32
+ @usps_id = ""
33
+
34
+ @date_authorized = Date.today
35
+ @date_captured = Date.today
36
+ @returned_date = Date.today
37
+ end
38
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper.rb'
2
+ require 'helper.rb'
3
+ require "service/authorized_service"
4
+ require "service/lookup_service"
5
+
6
+
7
+ RSpec.configure do |c|
8
+ c.include Helper
9
+ end
10
+
11
+ describe "complete transaction by calling AuthorizeAndCapture" do
12
+
13
+ before (:all) do
14
+ variable_init
15
+ end
16
+
17
+
18
+ it "should complete the transaction using authorized_with_capture" do
19
+
20
+ # We need to to a lookup first to create the start of the transaction
21
+ lookup_service = TaxCloud::LookupService.new(@client)
22
+ lookup_response = lookup_service.lookup(@api_id, @api_key, @customer_id, @cart_id, @origin, @destination, @cart_items)
23
+
24
+ # Here we are letting the service create a cart ID for us
25
+ @cart_id = lookup_response.cart_id
26
+
27
+ # And now for the actual test
28
+
29
+ authorized_service = TaxCloud::AuthorizedService.new(@client)
30
+
31
+ authorized_response = authorized_service.authorized_with_capture(@api_id, @api_key, @customer_id, @cart_id, @order_id, @date_authorized, @date_captured)
32
+
33
+ puts 'authorizedRsp: ' + authorized_response.response_type.to_s
34
+
35
+ response_type = authorized_response.response_type
36
+
37
+ response_type.should eql 'OK'
38
+
39
+
40
+ end
41
+
42
+ it "should complete the transaction using separate authorized and capture calls" do
43
+ # We need to to a lookup first to create the start of the transaction
44
+ lookup_service = TaxCloud::LookupService.new(@client)
45
+ lookup_response = lookup_service.lookup(@api_id, @api_key, @customer_id, @cart_id, @origin, @destination, @cart_items)
46
+
47
+ # Here we are letting the service create a cart ID for us
48
+ @cart_id = lookup_response.cart_id
49
+
50
+ # And now for the actual test
51
+
52
+ authorized_service = TaxCloud::AuthorizedService.new(@client)
53
+
54
+ authorized_response = authorized_service.authorized(@api_id, @api_key, @customer_id, @cart_id, @order_id, @date_authorized)
55
+
56
+ puts 'response type: ' + authorized_response.response_type.to_s
57
+ authorized_response.response_type.should eql 'OK'
58
+
59
+ # Now capture the transaction
60
+ captured_response = authorized_service.captured(@api_id, @api_key, @order_id)
61
+
62
+ captured_response.response_type.should eql 'OK'
63
+
64
+
65
+ end
66
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper.rb'
2
+ require 'helper.rb'
3
+
4
+ require "service/lookup_service"
5
+
6
+ RSpec.configure do |c|
7
+ c.include Helper
8
+ end
9
+
10
+ describe "Perform Lookup" do
11
+
12
+ before(:all) do
13
+ variable_init
14
+ end
15
+
16
+ it "should not allow unauthorized access" do
17
+ api_id = "12345"
18
+ api_key = "67890"
19
+
20
+ lookup_service = TaxCloud::LookupService.new(@client)
21
+
22
+ lookup_response = lookup_service.lookup(api_id, api_key, @customer_id, @cart_id, @origin, @destination, @cart_items)
23
+
24
+ lookup_response.response_type.to_s.should.eql?("Error")
25
+ lookup_response.messages[:message].should.eql?("Invalid apiLoginID and/or apiKey")
26
+ end
27
+
28
+ it "should return tax amounts" do
29
+
30
+ lookup_service = TaxCloud::LookupService.new(@client)
31
+
32
+ lookup_response = lookup_service.lookup(@api_id, @api_key, @customer_id, @cart_id, @origin, @destination, @cart_items)
33
+
34
+ lookup_response.response_type.to_s.should.eql?("OK")
35
+
36
+ # Note, these amounts are just meant to represent a successful transaction.
37
+ # The amounts may change as the states adjust their rates. In that case you would have to update this test.
38
+ lookup_response.cart_items_response.get_taxes(0).should eql("1.89905")
39
+ lookup_response.cart_items_response.get_taxes(1).should eql("0.94905")
40
+ lookup_response.cart_items_response.get_taxes(2).should eql("1.89905")
41
+
42
+ end
43
+
44
+
45
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper.rb'
2
+ require 'helper.rb'
3
+ require 'service/lookup_service'
4
+ require 'service/authorized_service'
5
+ require 'service/returned_service'
6
+
7
+ RSpec.configure do |c|
8
+ c.include Helper
9
+ end
10
+
11
+ describe "Returned Service" do
12
+
13
+ before(:all) do
14
+ variable_init
15
+ end
16
+
17
+ it "should allow an item to be returned" do
18
+
19
+ # An order needs to be completed before an item can be returned
20
+ lookup_service = TaxCloud::LookupService.new(@client)
21
+ lookup_response = lookup_service.lookup(@api_id, @api_key, @customer_id, @cart_id, @origin, @destination, @cart_items)
22
+
23
+ # Here we are letting the service create a cart ID for us
24
+ @cart_id = lookup_response.cart_id
25
+
26
+ authorized_service = TaxCloud::AuthorizedService.new(@client)
27
+
28
+ authorized_response = authorized_service.authorized_with_capture(@api_id, @api_key, @customer_id, @cart_id, @order_id, @date_authorized, @date_captured)
29
+
30
+ # And now for the actual test
31
+ returned_service = TaxCloud::ReturnedService.new(@client)
32
+ returned_response = returned_service.returned(@api_id, @api_key, @order_id, @cart_items, @returned_date)
33
+ returned_response.response_type.to_s.should eql 'OK'
34
+
35
+ end
36
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper.rb'
2
+ require 'helper.rb'
3
+
4
+ require 'service/tic_service'
5
+
6
+ RSpec.configure do |c|
7
+ c.include Helper
8
+ end
9
+
10
+ describe "TIC Service" do
11
+
12
+ before(:all) do
13
+ variable_init
14
+ end
15
+
16
+ specify "should return a list of TICs" do
17
+
18
+ tic_service = TaxCloud::TICService.new(@client)
19
+
20
+ get_tics_response = tic_service.get_tics(@api_id, @api_key)
21
+
22
+ get_tics_response.response_type.to_s.should eql 'OK'
23
+
24
+ get_tics_response.ti_cs.should_not be nil
25
+
26
+ puts 'id: ' + get_tics_response.get_tic(0).tic_id.to_s
27
+ end
28
+
29
+ specify "should return a list of TIC groups" do
30
+
31
+ tic_service = TaxCloud::TICService.new(@client)
32
+
33
+ get_tic_groups_response = tic_service.get_tic_groups(@api_id, @api_key)
34
+
35
+
36
+ end
37
+
38
+ specify "should return a list of TICs per group" do
39
+
40
+ tic_service = TaxCloud::TICService.new(@client)
41
+
42
+ group_id = 1
43
+ get_tics_by_group_response = tic_service.get_tics_by_group(@api_id, @api_key, group_id)
44
+
45
+ # get_tics_by_group_response.to_s.should eql 'OK'
46
+ end
47
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper.rb'
2
+ require 'helper.rb'
3
+ require 'service/verify_address_service'
4
+
5
+ RSpec.configure do |c|
6
+ c.include Helper
7
+ end
8
+
9
+ describe "Verify Address Service" do
10
+
11
+ before(:all) do
12
+ variable_init
13
+ end
14
+
15
+ specify "should return a verified address" do
16
+
17
+ verify_address_service = TaxCloud::VerifyAddressService.new(@client)
18
+ verify_address_response = verify_address_service.verify_address(@api_id, @api_key, @usps_id, @origin)
19
+
20
+ verify_address_response.address1.to_s.should eql '162 EAST AVE'
21
+ verify_address_response.zip4.to_s.should eql '5715'
22
+
23
+ end
24
+ end