fishbowl 0.0.1 → 1.0.2

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.
Files changed (177) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.travis.yml +9 -4
  4. data/Gemfile +9 -2
  5. data/Guardfile +13 -0
  6. data/README.md +25 -5
  7. data/fishbowl.gemspec +5 -5
  8. data/lib/fishbowl/configuration.rb +9 -0
  9. data/lib/fishbowl/connection.rb +100 -0
  10. data/lib/fishbowl/errors.rb +18 -8
  11. data/lib/fishbowl/ext.rb +15 -0
  12. data/lib/fishbowl/objects/account.rb +8 -12
  13. data/lib/fishbowl/objects/address.rb +86 -0
  14. data/lib/fishbowl/objects/base_object.rb +42 -9
  15. data/lib/fishbowl/objects/carrier.rb +15 -0
  16. data/lib/fishbowl/objects/carton.rb +54 -0
  17. data/lib/fishbowl/objects/uom.rb +47 -0
  18. data/lib/fishbowl/objects/user.rb +15 -0
  19. data/lib/fishbowl/objects.rb +5 -0
  20. data/lib/fishbowl/requests/add_inventory.rb +34 -0
  21. data/lib/fishbowl/requests/add_sales_order_item.rb +42 -0
  22. data/lib/fishbowl/requests/adjust_inventory.rb +28 -0
  23. data/lib/fishbowl/requests/get_account_balance.rb +15 -0
  24. data/lib/fishbowl/requests/get_account_list.rb +13 -0
  25. data/lib/fishbowl/requests/get_carrier_list.rb +14 -0
  26. data/lib/fishbowl/requests/get_customer_list.rb +12 -0
  27. data/lib/fishbowl/requests/get_customer_name_list.rb +12 -0
  28. data/lib/fishbowl/requests/get_export_list.rb +12 -0
  29. data/lib/fishbowl/requests/get_import_list.rb +12 -0
  30. data/lib/fishbowl/requests/get_location_group_list.rb +12 -0
  31. data/lib/fishbowl/requests/get_location_list.rb +12 -0
  32. data/lib/fishbowl/requests/get_product.rb +18 -0
  33. data/lib/fishbowl/requests/get_product_price.rb +21 -0
  34. data/lib/fishbowl/requests/get_uom_list.rb +12 -0
  35. data/lib/fishbowl/requests/get_vendor_list.rb +12 -0
  36. data/lib/fishbowl/requests/get_vendor_name_list.rb +12 -0
  37. data/lib/fishbowl/requests/get_work_order_list.rb +12 -0
  38. data/lib/fishbowl/requests/inventory_quantity.rb +17 -0
  39. data/lib/fishbowl/requests/load_sales_order.rb +21 -0
  40. data/lib/fishbowl/requests/make_payment.rb +32 -0
  41. data/lib/fishbowl/requests/save_sales_order.rb +86 -0
  42. data/lib/fishbowl/requests/total_inventory.rb +18 -0
  43. data/lib/fishbowl/requests/void_sales_order.rb +18 -0
  44. data/lib/fishbowl/requests.rb +5 -0
  45. data/lib/fishbowl/version.rb +1 -1
  46. data/lib/fishbowl.rb +12 -95
  47. data/lib/status_codes.yml +183 -0
  48. data/spec/connection_spec.rb +99 -99
  49. data/spec/errors_spec.rb +11 -9
  50. data/spec/examples/account.xml +6 -0
  51. data/spec/examples/address.xml +30 -0
  52. data/spec/examples/carrier.xml +3 -0
  53. data/spec/examples/carton.xml +93 -0
  54. data/spec/examples/contact_information.xml +5 -0
  55. data/spec/examples/contacts.xml +7 -0
  56. data/spec/examples/credit_card.xml +10 -0
  57. data/spec/examples/customer.xml +54 -0
  58. data/spec/examples/location.xml +14 -0
  59. data/spec/examples/location_group.xml +5 -0
  60. data/spec/examples/location_group_string.xml +1 -0
  61. data/spec/examples/order_history.xml +8 -0
  62. data/spec/examples/part.xml +105 -0
  63. data/spec/examples/payment.xml +6 -0
  64. data/spec/examples/pick.xml +265 -0
  65. data/spec/examples/pick_item.xml +236 -0
  66. data/spec/examples/product.xml +159 -0
  67. data/spec/examples/purchase_order.xml +53 -0
  68. data/spec/examples/receipt.xml +146 -0
  69. data/spec/examples/report.xml +10 -0
  70. data/spec/examples/report_tree.xml +7 -0
  71. data/spec/examples/sales_order.xml +47 -0
  72. data/spec/examples/sales_order_item.xml +32 -0
  73. data/spec/examples/shipping.xml +127 -0
  74. data/spec/examples/tag.xml +28 -0
  75. data/spec/examples/tax_rate.xml +10 -0
  76. data/spec/examples/tracking.xml +14 -0
  77. data/spec/examples/tracking_item.xml +12 -0
  78. data/spec/examples/transfer_order.xml +257 -0
  79. data/spec/examples/transfer_order_item.xml +147 -0
  80. data/spec/examples/uom.xml +26 -0
  81. data/spec/examples/uom_conversion.xml +8 -0
  82. data/spec/examples/user.xml +8 -0
  83. data/spec/examples/vendor.xml +19 -0
  84. data/spec/examples/vendor_part_number.xml +3 -0
  85. data/spec/examples/work_order.xml +228 -0
  86. data/spec/examples/work_order_item.xml +172 -0
  87. data/spec/objects/account_spec.rb +33 -27
  88. data/spec/objects/address_information_spec.rb +18 -0
  89. data/spec/objects/address_spec.rb +36 -0
  90. data/spec/objects/base_object_spec.rb +67 -23
  91. data/spec/objects/carrier_spec.rb +15 -0
  92. data/spec/objects/carton_spec.rb +23 -0
  93. data/spec/objects/country_spec.rb +16 -0
  94. data/spec/objects/shipping_item_spec.rb +21 -0
  95. data/spec/objects/state_spec.rb +17 -0
  96. data/spec/objects/uom_conversion_spec.rb +20 -0
  97. data/spec/objects/uom_spec.rb +20 -0
  98. data/spec/objects/user_spec.rb +20 -0
  99. data/spec/requests/add_inventory_spec.rb +79 -0
  100. data/spec/requests/add_sales_order_item_spec.rb +85 -0
  101. data/spec/requests/adjust_inventory_spec.rb +62 -0
  102. data/spec/requests/calculate_sales_order_spec.rb +48 -0
  103. data/spec/requests/close_short_sales_order_spec.rb +45 -0
  104. data/spec/requests/cycle_count_spec.rb +49 -0
  105. data/spec/requests/delete_sales_order_spec.rb +45 -0
  106. data/spec/requests/export_spec.rb +45 -0
  107. data/spec/requests/get_account_balance_spec.rb +52 -0
  108. data/spec/requests/get_account_list_spec.rb +51 -0
  109. data/spec/requests/get_carrier_list_spec.rb +54 -0
  110. data/spec/requests/get_customer_list_spec.rb +51 -0
  111. data/spec/requests/get_customer_name_list_spec.rb +45 -0
  112. data/spec/requests/get_customer_spec.rb +45 -0
  113. data/spec/requests/get_export_list_spec.rb +45 -0
  114. data/spec/requests/get_import_list_spec.rb +45 -0
  115. data/spec/requests/get_inventory_quantity_spec.rb +65 -0
  116. data/spec/requests/get_light_part_list_spec.rb +51 -0
  117. data/spec/requests/get_location_group_list_spec.rb +45 -0
  118. data/spec/requests/get_location_list_spec.rb +45 -0
  119. data/spec/requests/get_next_number_spec.rb +45 -0
  120. data/spec/requests/get_part_cost_spec.rb +45 -0
  121. data/spec/requests/get_part_information_spec.rb +45 -0
  122. data/spec/requests/get_part_list_spec.rb +65 -0
  123. data/spec/requests/get_pick_spec.rb +45 -0
  124. data/spec/requests/get_product_information_spec.rb +46 -0
  125. data/spec/requests/get_purchase_order_list_spec.rb +45 -0
  126. data/spec/requests/get_receipt_spec.rb +49 -0
  127. data/spec/requests/get_receiving_list_spec.rb +49 -0
  128. data/spec/requests/get_sales_order_list_spec.rb +49 -0
  129. data/spec/requests/get_ship_list_spec.rb +49 -0
  130. data/spec/requests/get_ship_now_list_spec.rb +48 -0
  131. data/spec/requests/get_shipment_spec.rb +45 -0
  132. data/spec/requests/get_system_property_spec.rb +45 -0
  133. data/spec/requests/get_total_inventory_spec.rb +46 -0
  134. data/spec/requests/get_transfer_order_list_spec.rb +45 -0
  135. data/spec/requests/get_uom_list_spec.rb +45 -0
  136. data/spec/requests/get_user_property_spec.rb +45 -0
  137. data/spec/requests/get_vendor_list_spec.rb +45 -0
  138. data/spec/requests/get_vendor_name_list_spec.rb +45 -0
  139. data/spec/requests/get_vendor_spec.rb +48 -0
  140. data/spec/requests/get_work_order_list_spec.rb +45 -0
  141. data/spec/requests/get_work_order_spec.rb +45 -0
  142. data/spec/requests/import_spec.rb +49 -0
  143. data/spec/requests/issues_sales_order_spec.rb +45 -0
  144. data/spec/requests/load_sales_order_spec.rb +45 -0
  145. data/spec/requests/load_transfer_order_spec.rb +45 -0
  146. data/spec/requests/location_query_spec.rb +49 -0
  147. data/spec/requests/make_payment_spec.rb +50 -0
  148. data/spec/requests/move_spec.rb +49 -0
  149. data/spec/requests/part_query_spec.rb +46 -0
  150. data/spec/requests/pick_query_spec.rb +49 -0
  151. data/spec/requests/print_report_spec.rb +48 -0
  152. data/spec/requests/product_query_spec.rb +46 -0
  153. data/spec/requests/quick_ship_spec.rb +45 -0
  154. data/spec/requests/quickbooks_export_spec.rb +43 -0
  155. data/spec/requests/save_customer_spec.rb +48 -0
  156. data/spec/requests/save_discount_spec.rb +48 -0
  157. data/spec/requests/save_pick_spec.rb +48 -0
  158. data/spec/requests/save_purchase_order_spec.rb +48 -0
  159. data/spec/requests/save_receipt_spec.rb +48 -0
  160. data/spec/requests/save_report_spec.rb +49 -0
  161. data/spec/requests/save_sales_order_spec.rb +48 -0
  162. data/spec/requests/save_shipment_spec.rb +48 -0
  163. data/spec/requests/save_tax_rate_spec.rb +48 -0
  164. data/spec/requests/save_transfer_order_spec.rb +48 -0
  165. data/spec/requests/save_upc_spec.rb +48 -0
  166. data/spec/requests/save_vendor_spec.rb +48 -0
  167. data/spec/requests/save_work_order_spec.rb +48 -0
  168. data/spec/requests/set_default_part_location_spec.rb +48 -0
  169. data/spec/requests/set_system_property_spec.rb +48 -0
  170. data/spec/requests/set_user_property_spec.rb +48 -0
  171. data/spec/requests/ship_spec.rb +48 -0
  172. data/spec/requests/void_sales_order_spec.rb +43 -0
  173. data/spec/spec_helper.rb +48 -16
  174. data/spec/support/examples_loader.rb +5 -0
  175. data/spec/support/response_mocks.rb +27 -0
  176. metadata +304 -35
  177. data/spec/support/fake_login.rb +0 -15
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Objects::Carton do
4
+ describe "instances" do
5
+
6
+ let(:carton) {
7
+ doc = Nokogiri::XML.parse(example_file('carton.xml'))
8
+ Fishbowl::Objects::Carton.new(doc.xpath('//Carton'))
9
+ }
10
+
11
+ it "should properly initialize from example file" do
12
+ carton.db_id.should eq("64")
13
+ carton.ship_id.should eq("63")
14
+ carton.carton_num.should eq("1")
15
+ carton.tracking_num.should be_empty
16
+ carton.freight_weight.should eq("1.2")
17
+ carton.freight_amount.should eq("0")
18
+
19
+ carton.shipping_items.first.should be_a(Fishbowl::Objects::ShippingItem)
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Objects::Country do
4
+ describe "instances" do
5
+
6
+ let(:country) {
7
+ doc = Nokogiri::XML.parse(example_file('address.xml'))
8
+ Fishbowl::Objects::Country.new(doc.xpath('//Country'))
9
+ }
10
+
11
+ it "should properly initialize from example file" do
12
+ country.name.should eq("United States")
13
+ country.code.should eq("US")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Objects::Carton do
4
+ describe "instances" do
5
+
6
+ let(:shipping_item) {
7
+ doc = Nokogiri::XML.parse(example_file('carton.xml'))
8
+ Fishbowl::Objects::ShippingItem.new(doc.xpath('//ShippingItem'))
9
+ }
10
+
11
+ it "should properly initialize from example file" do
12
+ shipping_item.ship_item_id.should eq("169")
13
+ shipping_item.product_number.should eq("B201")
14
+
15
+ shipping_item.uom.should be_a(Fishbowl::Objects::UOM)
16
+ shipping_item.weight_uom.should be_a(Fishbowl::Objects::UOM)
17
+ shipping_item.display_weight_uom.should be_a(Fishbowl::Objects::UOM)
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Objects::State do
4
+ describe "instances" do
5
+
6
+ let(:state) {
7
+ doc = Nokogiri::XML.parse(example_file('address.xml'))
8
+ Fishbowl::Objects::State.new(doc.xpath('//State'))
9
+ }
10
+
11
+ it "should properly initialize from example file" do
12
+ state.name.should eq("Utah")
13
+ state.code.should eq("UT")
14
+ state.country_id.should eq("2")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Objects::UOMConversion do
4
+ describe "instances" do
5
+
6
+ let(:uom_conversion) {
7
+ doc = Nokogiri::XML.parse(example_file('uom_conversion.xml'))
8
+ Fishbowl::Objects::UOMConversion.new(doc.xpath('//UOMConversion'))
9
+ }
10
+
11
+ it "should properly initialize from example file" do
12
+ uom_conversion.main_uom_id.should eq("1")
13
+ uom_conversion.to_uom_id.should eq("17")
14
+ uom_conversion.to_uom_code.should eq("pr")
15
+ uom_conversion.conversion_multiply.should eq("1.0")
16
+ uom_conversion.conversion_factor.should eq("2.0")
17
+ uom_conversion.to_uom_is_integral.should eq("false")
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Objects::UOM do
4
+ describe "instances" do
5
+
6
+ let(:uom) {
7
+ doc = Nokogiri::XML.parse(example_file('uom.xml'))
8
+ Fishbowl::Objects::UOM.new(doc.xpath('//UOM'))
9
+ }
10
+
11
+ it "should properly initialize from example file" do
12
+ uom.uomid.should eq("1")
13
+ uom.name.should eq("Each")
14
+ uom.code.should eq("ea")
15
+
16
+ uom.uom_conversions.should be_a(Array)
17
+ uom.uom_conversions.first.should be_a(Fishbowl::Objects::UOMConversion)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Objects::User do
4
+ describe "instances" do
5
+
6
+ let(:user) {
7
+ doc = Nokogiri::XML.parse(example_file('user.xml'))
8
+ Fishbowl::Objects::User.new(doc.xpath('//User'))
9
+ }
10
+
11
+ it "should properly initialize from example file" do
12
+ user.db_id.should eq("1")
13
+ user.user_name.should eq("admin")
14
+ user.first_name.should eq("Administrator")
15
+ user.last_name.should eq("Administrator")
16
+ user.initials.should eq("ADM")
17
+ user.active.should eq("true")
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#add_inventory" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ let(:valid_options) {
15
+ {
16
+ part_number: "B103",
17
+ quantity: 6,
18
+ uom_id: 1,
19
+ cost: 33.01,
20
+ location_tag_number: 1,
21
+ tag_number: 1
22
+ }
23
+ }
24
+
25
+ it "requires valid options" do
26
+ lambda {
27
+ Fishbowl::Requests.add_inventory(valid_options)
28
+ }.should_not raise_error(ArgumentError)
29
+
30
+ valid_options.each do |excluded_key, excluded_value|
31
+ invalid_options = valid_options.keep_if {|k,v| k != excluded_key}
32
+
33
+ lambda {
34
+ Fishbowl::Requests.add_inventory(invalid_options)
35
+ }.should raise_error(ArgumentError)
36
+ end
37
+ end
38
+
39
+ it "sends proper request" do
40
+ mock_the_response('AddInventoryRs')
41
+ Fishbowl::Requests.add_inventory(valid_options)
42
+ connection.last_write.should be_equivalent_to(expected_request)
43
+ end
44
+
45
+ it "includes note option when supplied" do
46
+ additional_options = { note: 'This is a test' }
47
+
48
+ mock_the_response('AddInventoryRs')
49
+ Fishbowl::Requests.add_inventory(valid_options.merge(additional_options))
50
+ connection.last_write.should be_equivalent_to(expected_request(additional_options))
51
+ end
52
+
53
+ it "includes tracking option when supplied"
54
+
55
+ def expected_request(options = {})
56
+ options = valid_options.merge(options)
57
+
58
+ request = Nokogiri::XML::Builder.new do |xml|
59
+ xml.FbiXml {
60
+ xml.Ticket
61
+ xml.FbiMsgsRq {
62
+ xml.AddInventoryRq {
63
+ xml.PartNum options[:part_number]
64
+ xml.Quantity options[:quantity]
65
+ xml.UOMID options[:uom_id]
66
+ xml.Cost options[:cost]
67
+ xml.Note options[:note] unless options[:note].nil?
68
+ xml.Tracking options[:tracking] unless options[:tracking].nil?
69
+ xml.LocationTagNum valid_options[:location_tag_number]
70
+ xml.TagNum valid_options[:tag_number]
71
+ }
72
+ }
73
+ }
74
+ end
75
+
76
+ request.to_xml
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#add_sales_order_item" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ let(:valid_options) {
15
+ {
16
+ order_number: 1,
17
+ id: -1,
18
+ product_number: 'BTY100-Core',
19
+ sales_order_id: 94,
20
+ description: 'Battery Pack',
21
+ taxable: true,
22
+ quantity: 1,
23
+ product_price: 95.00,
24
+ total_price: 95.00,
25
+ uom_code: 'ea',
26
+ item_type: 20,
27
+ status: 10,
28
+ quickbooks_class_name: 'Salt Lake City',
29
+ new_item_flag: false
30
+ }
31
+ }
32
+
33
+ it "requires valid options" do
34
+ lambda {
35
+ Fishbowl::Requests.add_sales_order_item(valid_options)
36
+ }.should_not raise_error(ArgumentError)
37
+
38
+ valid_options.each do |excluded_key, excluded_value|
39
+ invalid_options = valid_options.keep_if {|k,v| k != excluded_key}
40
+
41
+ lambda {
42
+ Fishbowl::Requests.add_sales_order_item(invalid_options)
43
+ }.should raise_error(ArgumentError)
44
+ end
45
+ end
46
+
47
+ it "sends proper request" do
48
+ mock_the_response('AddSOItemRs')
49
+ Fishbowl::Requests.add_sales_order_item(valid_options)
50
+ connection.last_write.should be_equivalent_to(expected_request)
51
+ end
52
+
53
+ def expected_request(options = {})
54
+ options = valid_options.merge(options)
55
+
56
+ request = Nokogiri::XML::Builder.new do |xml|
57
+ xml.FbiXml {
58
+ xml.Ticket
59
+ xml.FbiMsgsRq {
60
+ xml.AddSOItemRq {
61
+ xml.OrderNum options[:order_number]
62
+ xml.SalesOrderItem {
63
+ xml.ID options[:id]
64
+ xml.ProductNumber options[:product_number]
65
+ xml.SOID options[:sales_order_id]
66
+ xml.Description options[:description]
67
+ xml.Taxable options[:taxable]
68
+ xml.Quantity options[:quantity]
69
+ xml.ProductPrice options[:product_price]
70
+ xml.TotalPrice options[:total_price]
71
+ xml.UOMCode options[:uom_code]
72
+ xml.ItemType options[:item_type]
73
+ xml.Status options[:status]
74
+ xml.QuickBooksClassName options[:quickbooks_class_name]
75
+ xml.NewItemFlag options[:new_item_flag]
76
+ }
77
+ }
78
+ }
79
+ }
80
+ end
81
+
82
+ request.to_xml
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#adjust_inventory" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ let(:valid_options) {
15
+ {
16
+ tag_number: 1,
17
+ quantity: 5
18
+ }
19
+ }
20
+
21
+ it "requires valid options" do
22
+ lambda {
23
+ Fishbowl::Requests.adjust_inventory(valid_options)
24
+ }.should_not raise_error(ArgumentError)
25
+
26
+ valid_options.each do |excluded_key, excluded_value|
27
+ invalid_options = valid_options.keep_if {|k,v| k != excluded_key}
28
+
29
+ lambda {
30
+ Fishbowl::Requests.adjust_inventory(invalid_options)
31
+ }.should raise_error(ArgumentError)
32
+ end
33
+ end
34
+
35
+ it "sends proper request" do
36
+ mock_the_response('AdjustInventoryRs')
37
+ Fishbowl::Requests.adjust_inventory(valid_options)
38
+ connection.last_write.should be_equivalent_to(expected_request)
39
+ end
40
+
41
+ it "includes tracking when provided"
42
+
43
+ def expected_request(options = {})
44
+ options = valid_options.merge(options)
45
+
46
+ request = Nokogiri::XML::Builder.new do |xml|
47
+ xml.FbiXml {
48
+ xml.Ticket
49
+ xml.FbiMsgsRq {
50
+ xml.AdjustInventoryRq {
51
+ xml.TagNum valid_options[:tag_number]
52
+ xml.Quantity valid_options[:quantity]
53
+ xml.Tracking options[:tracking] unless options[:tracking].nil?
54
+ }
55
+ }
56
+ }
57
+ end
58
+
59
+ request.to_xml
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#calculate_sales_order" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+ let(:mock_sales_order) {
14
+ #TODO mock a SalesOrder
15
+ }
16
+
17
+ it "sends proper request" do
18
+ mock_the_response(expected_response)
19
+ Fishbowl::Requests.calculate_sales_order(mock_sales_order)
20
+ connection.last_write.should be_equivalent_to(expected_request)
21
+ end
22
+
23
+ def expected_request
24
+ request = Nokogiri::XML::Builder.new do |xml|
25
+ xml.FbiXml {
26
+ xml.Ticket
27
+ xml.FbiMsgsRq {
28
+ xml.CalculateSORq {
29
+ #TODO mock a SalesOrder object
30
+ }
31
+ }
32
+ }
33
+ end
34
+
35
+ request.to_xml
36
+ end
37
+
38
+ def expected_response
39
+ Nokogiri::XML::Builder.new do |xml|
40
+ xml.response {
41
+ xml.CalculateSORs(statusCode: '1000', statusMessage: "Success!") {
42
+ #TODO figure out what goes here!
43
+ }
44
+ }
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#close_short_sales_order" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ it "sends proper request" do
15
+ mock_the_response(expected_response)
16
+ Fishbowl::Requests.close_short_sales_order(50069)
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ def expected_request
21
+ request = Nokogiri::XML::Builder.new do |xml|
22
+ xml.FbiXml {
23
+ xml.Ticket
24
+ xml.FbiMsgsRq {
25
+ xml.CloseShortSORq {
26
+ xml.SONumber 50069
27
+ }
28
+ }
29
+ }
30
+ end
31
+
32
+ request.to_xml
33
+ end
34
+
35
+ def expected_response
36
+ Nokogiri::XML::Builder.new do |xml|
37
+ xml.response {
38
+ xml.CloseShortSORs(statusCode: '1000', statusMessage: "Success!") {
39
+ #TODO figure out what goes here!
40
+ }
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#cycle_count" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ let(:valid_options) {
15
+ #TODO Identify valid options to supply
16
+ }
17
+
18
+ it "sends proper request" do
19
+ mock_the_response(expected_response)
20
+ Fishbowl::Requests.cycle_count(valid_options)
21
+ connection.last_write.should be_equivalent_to(expected_request)
22
+ end
23
+
24
+ def expected_request
25
+ request = Nokogiri::XML::Builder.new do |xml|
26
+ xml.FbiXml {
27
+ xml.Ticket
28
+ xml.FbiMsgsRq {
29
+ xml.CycleCountRq {
30
+ #TODO use valid options
31
+ }
32
+ }
33
+ }
34
+ end
35
+
36
+ request.to_xml
37
+ end
38
+
39
+ def expected_response
40
+ Nokogiri::XML::Builder.new do |xml|
41
+ xml.response {
42
+ xml.CycleCountRs(statusCode: '1000', statusMessage: "Success!") {
43
+ #TODO figure out what goes here!
44
+ }
45
+ }
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#delete_sales_order" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ it "sends proper request" do
15
+ mock_the_response(expected_response)
16
+ Fishbowl::Requests.delete_sales_order(50069)
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ def expected_request
21
+ request = Nokogiri::XML::Builder.new do |xml|
22
+ xml.FbiXml {
23
+ xml.Ticket
24
+ xml.FbiMsgsRq {
25
+ xml.DeleteSORq {
26
+ xml.SONumber 50069
27
+ }
28
+ }
29
+ }
30
+ end
31
+
32
+ request.to_xml
33
+ end
34
+
35
+ def expected_response
36
+ Nokogiri::XML::Builder.new do |xml|
37
+ xml.response {
38
+ xml.DeleteSORs(statusCode: '1000', statusMessage: "Success!") {
39
+ #TODO figure out what goes here!
40
+ }
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#export" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ it "sends proper request" do
15
+ mock_the_response(expected_response)
16
+ Fishbowl::Requests.export("ExportPartCost")
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ def expected_request
21
+ request = Nokogiri::XML::Builder.new do |xml|
22
+ xml.FbiXml {
23
+ xml.Ticket
24
+ xml.FbiMsgsRq {
25
+ xml.ExportRq {
26
+ xml.Type "ExportPartCost"
27
+ }
28
+ }
29
+ }
30
+ end
31
+
32
+ request.to_xml
33
+ end
34
+
35
+ def expected_response
36
+ Nokogiri::XML::Builder.new do |xml|
37
+ xml.response {
38
+ xml.ExportRs(statusCode: '1000', statusMessage: "Success!") {
39
+ #TODO figure out what goes here!
40
+ }
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#get_account_balance" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ it "sends proper request" do
15
+ mock_the_response(expected_response)
16
+ Fishbowl::Requests.get_account_balance("Accounts Payable")
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ it "returns the balance of the requested account"
21
+
22
+ def expected_request
23
+ request = Nokogiri::XML::Builder.new do |xml|
24
+ xml.FbiXml {
25
+ xml.Ticket
26
+ xml.FbiMsgsRq {
27
+ xml.GetAccountBalanceRq {
28
+ xml.Account "Accounts Payable"
29
+ }
30
+ }
31
+ }
32
+ end
33
+
34
+ request.to_xml
35
+ end
36
+
37
+ def expected_response
38
+ Nokogiri::XML::Builder.new do |xml|
39
+ xml.response {
40
+ xml.GetAccountBalanceRs(statusCode: '1000', statusMessage: "Success!") {
41
+ xml.Account {
42
+ xml.Name "Demo Account"
43
+ xml.AccountingID "DEMO"
44
+ xml.AccountType 9
45
+ xml.Balance "1200.00"
46
+ }
47
+ }
48
+ }
49
+ end
50
+ end
51
+ end
52
+ end