fishbowl 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/Gemfile +1 -8
  4. data/fishbowl.gemspec +4 -4
  5. data/lib/fishbowl.rb +9 -90
  6. data/lib/fishbowl/configuration.rb +9 -0
  7. data/lib/fishbowl/connection.rb +99 -0
  8. data/lib/fishbowl/errors.rb +9 -2
  9. data/lib/fishbowl/objects/account.rb +0 -26
  10. data/lib/fishbowl/objects/base_object.rb +25 -8
  11. data/lib/fishbowl/requests.rb +3 -4
  12. data/lib/fishbowl/requests/get_account_balance.rb +15 -0
  13. data/lib/fishbowl/requests/get_account_list.rb +13 -0
  14. data/lib/fishbowl/requests/get_carrier_list.rb +3 -2
  15. data/lib/fishbowl/requests/get_customer_list.rb +12 -0
  16. data/lib/fishbowl/requests/get_customer_name_list.rb +12 -0
  17. data/lib/fishbowl/requests/get_export_list.rb +12 -0
  18. data/lib/fishbowl/requests/get_import_list.rb +12 -0
  19. data/lib/fishbowl/requests/get_location_group_list.rb +12 -0
  20. data/lib/fishbowl/requests/get_location_list.rb +12 -0
  21. data/lib/fishbowl/requests/get_uom_list.rb +12 -0
  22. data/lib/fishbowl/requests/get_vendor_list.rb +12 -0
  23. data/lib/fishbowl/requests/get_vendor_name_list.rb +12 -0
  24. data/lib/fishbowl/requests/get_work_order_list.rb +12 -0
  25. data/lib/fishbowl/requests/void_sales_order.rb +18 -0
  26. data/lib/fishbowl/version.rb +1 -1
  27. data/lib/status_codes.yml +183 -0
  28. data/spec/objects/account_spec.rb +0 -41
  29. data/spec/requests/calculate_sales_order_spec.rb +48 -0
  30. data/spec/requests/close_short_sales_order_spec.rb +45 -0
  31. data/spec/requests/cycle_count_spec.rb +49 -0
  32. data/spec/requests/delete_sales_order_spec.rb +45 -0
  33. data/spec/requests/export_spec.rb +45 -0
  34. data/spec/requests/get_account_balance_spec.rb +52 -0
  35. data/spec/requests/get_account_list_spec.rb +51 -0
  36. data/spec/requests/get_customer_list_spec.rb +51 -0
  37. data/spec/requests/get_customer_name_list_spec.rb +45 -0
  38. data/spec/requests/get_customer_spec.rb +45 -0
  39. data/spec/requests/get_export_list_spec.rb +45 -0
  40. data/spec/requests/get_import_list_spec.rb +45 -0
  41. data/spec/requests/get_inventory_quantity_spec.rb +65 -0
  42. data/spec/requests/get_light_part_list_spec.rb +51 -0
  43. data/spec/requests/get_location_group_list_spec.rb +45 -0
  44. data/spec/requests/get_location_list_spec.rb +45 -0
  45. data/spec/requests/get_next_number_spec.rb +45 -0
  46. data/spec/requests/get_part_cost_spec.rb +45 -0
  47. data/spec/requests/get_part_information_spec.rb +45 -0
  48. data/spec/requests/get_part_list_spec.rb +65 -0
  49. data/spec/requests/get_pick_spec.rb +45 -0
  50. data/spec/requests/get_product_information_spec.rb +46 -0
  51. data/spec/requests/get_purchase_order_list_spec.rb +45 -0
  52. data/spec/requests/get_receipt_spec.rb +49 -0
  53. data/spec/requests/get_receiving_list_spec.rb +49 -0
  54. data/spec/requests/get_sales_order_list_spec.rb +49 -0
  55. data/spec/requests/get_ship_list_spec.rb +49 -0
  56. data/spec/requests/get_ship_now_list_spec.rb +48 -0
  57. data/spec/requests/get_shipment_spec.rb +45 -0
  58. data/spec/requests/get_system_property_spec.rb +45 -0
  59. data/spec/requests/get_total_inventory_spec.rb +46 -0
  60. data/spec/requests/get_transfer_order_list_spec.rb +45 -0
  61. data/spec/requests/get_uom_list_spec.rb +45 -0
  62. data/spec/requests/get_user_property_spec.rb +45 -0
  63. data/spec/requests/get_vendor_list_spec.rb +45 -0
  64. data/spec/requests/get_vendor_name_list_spec.rb +45 -0
  65. data/spec/requests/get_vendor_spec.rb +48 -0
  66. data/spec/requests/get_work_order_list_spec.rb +45 -0
  67. data/spec/requests/get_work_order_spec.rb +45 -0
  68. data/spec/requests/import_spec.rb +49 -0
  69. data/spec/requests/issues_sales_order_spec.rb +45 -0
  70. data/spec/requests/load_sales_order_spec.rb +45 -0
  71. data/spec/requests/load_transfer_order_spec.rb +45 -0
  72. data/spec/requests/location_query_spec.rb +49 -0
  73. data/spec/requests/make_payment_spec.rb +50 -0
  74. data/spec/requests/move_spec.rb +49 -0
  75. data/spec/requests/part_query_spec.rb +46 -0
  76. data/spec/requests/pick_query_spec.rb +49 -0
  77. data/spec/requests/print_report_spec.rb +48 -0
  78. data/spec/requests/product_query_spec.rb +46 -0
  79. data/spec/requests/quick_ship_spec.rb +45 -0
  80. data/spec/requests/quickbooks_export_spec.rb +43 -0
  81. data/spec/requests/save_customer_spec.rb +48 -0
  82. data/spec/requests/save_discount_spec.rb +48 -0
  83. data/spec/requests/save_pick_spec.rb +48 -0
  84. data/spec/requests/save_purchase_order_spec.rb +48 -0
  85. data/spec/requests/save_receipt_spec.rb +48 -0
  86. data/spec/requests/save_report_spec.rb +49 -0
  87. data/spec/requests/save_sales_order_spec.rb +48 -0
  88. data/spec/requests/save_shipment_spec.rb +48 -0
  89. data/spec/requests/save_tax_rate_spec.rb +48 -0
  90. data/spec/requests/save_transfer_order_spec.rb +48 -0
  91. data/spec/requests/save_upc_spec.rb +48 -0
  92. data/spec/requests/save_vendor_spec.rb +48 -0
  93. data/spec/requests/save_work_order_spec.rb +48 -0
  94. data/spec/requests/set_default_part_location_spec.rb +48 -0
  95. data/spec/requests/set_system_property_spec.rb +48 -0
  96. data/spec/requests/set_user_property_spec.rb +48 -0
  97. data/spec/requests/ship_spec.rb +48 -0
  98. data/spec/requests/void_sales_order_spec.rb +43 -0
  99. metadata +167 -21
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#get_inventory_quantity" 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
16
+ }
17
+
18
+ it "requires valid options" do
19
+ lambda {
20
+ Fishbowl::Requests.get_inventory_quantity(valid_options)
21
+ }.should_not raise_error(ArgumentError)
22
+
23
+ valid_options.each do |excluded_key, excluded_value|
24
+ invalid_options = valid_options.keep_if {|k,v| k != excluded_key}
25
+
26
+ lambda {
27
+ Fishbowl::Requests.get_inventory_quantity(invalid_options)
28
+ }.should raise_error(ArgumentError)
29
+ end
30
+ end
31
+
32
+ it "sends proper request" do
33
+ mock_the_response(expected_response)
34
+ Fishbowl::Requests.get_inventory_quantity(valid_options)
35
+ connection.last_write.should be_equivalent_to(expected_request)
36
+ end
37
+
38
+ def expected_request(options = {})
39
+ options = valid_options.merge(options)
40
+
41
+ request = Nokogiri::XML::Builder.new do |xml|
42
+ xml.FbiXml {
43
+ xml.Ticket
44
+ xml.FbiMsgsRq {
45
+ xml.InventoryQuantityRq {
46
+ #TODO Figure out what goes here!
47
+ }
48
+ }
49
+ }
50
+ end
51
+
52
+ request.to_xml
53
+ end
54
+
55
+ def expected_response
56
+ Nokogiri::XML::Builder.new do |xml|
57
+ xml.response {
58
+ xml.InventoryQuantityRs(statusCode: '1000', statusMessage: "Success!") {
59
+ #TODO figure out what goes here!
60
+ }
61
+ }
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#get_light_part_list" 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_light_part_list
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ it "returns array of parts" do
21
+ mock_the_response(expected_response)
22
+ response = Fishbowl::Requests.get_light_part_list
23
+
24
+ response.should be_an(Array)
25
+ #TODO What else does it return?
26
+ end
27
+
28
+ def expected_request
29
+ request = Nokogiri::XML::Builder.new do |xml|
30
+ xml.FbiXml {
31
+ xml.Ticket
32
+ xml.FbiMsgsRq {
33
+ xml.LightPartListRq
34
+ }
35
+ }
36
+ end
37
+
38
+ request.to_xml
39
+ end
40
+
41
+ def expected_response
42
+ Nokogiri::XML::Builder.new do |xml|
43
+ xml.response {
44
+ xml.LightPartListRs(statusCode: '1000', statusMessage: "Success!") {
45
+ #TODO Mock an array of Accounts
46
+ }
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#get_location_group_list" 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_location_group_list
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ it "returns array of LocationGroups"
21
+
22
+ def expected_request
23
+ request = Nokogiri::XML::Builder.new do |xml|
24
+ xml.FbiXml {
25
+ xml.Ticket
26
+ xml.FbiMsgsRq {
27
+ xml.LocationGroupRq
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.LocationGroupRs(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 "#get_location_list" 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_location_list
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ it "returns an array of Locations"
21
+
22
+ def expected_request
23
+ request = Nokogiri::XML::Builder.new do |xml|
24
+ xml.FbiXml {
25
+ xml.Ticket
26
+ xml.FbiMsgsRq {
27
+ xml.LocationListRq
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.LocationListRs(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 "#get_next_number" 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_next_number("PO")
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.GetNextNumberRq {
26
+ xml.Type "PO"
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.GetNextNumberRs(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 "#get_part_cost" 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_part_cost("B203")
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ def expected_request(options = {})
21
+ request = Nokogiri::XML::Builder.new do |xml|
22
+ xml.FbiXml {
23
+ xml.Ticket
24
+ xml.FbiMsgsRq {
25
+ xml.PartCostRq {
26
+ xml.PartNum "B203"
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.PartCostRs(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 "#get_part_information" 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_part_information("B203")
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ def expected_request(options = {})
21
+ request = Nokogiri::XML::Builder.new do |xml|
22
+ xml.FbiXml {
23
+ xml.Ticket
24
+ xml.FbiMsgsRq {
25
+ xml.PartGetRq {
26
+ xml.PartNum "B203"
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.PartGetRs(statusCode: '1000', statusMessage: "Success!") {
39
+ #TODO figure out what goes here!
40
+ }
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#get_part_list" 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
16
+ }
17
+
18
+ it "requires valid options" do
19
+ lambda {
20
+ Fishbowl::Requests.get_part_list(valid_options)
21
+ }.should_not raise_error(ArgumentError)
22
+
23
+ valid_options.each do |excluded_key, excluded_value|
24
+ invalid_options = valid_options.keep_if {|k,v| k != excluded_key}
25
+
26
+ lambda {
27
+ Fishbowl::Requests.get_part_list(invalid_options)
28
+ }.should raise_error(ArgumentError)
29
+ end
30
+ end
31
+
32
+ it "sends proper request" do
33
+ mock_the_response(expected_response)
34
+ Fishbowl::Requests.get_part_list(valid_options)
35
+ connection.last_write.should be_equivalent_to(expected_request)
36
+ end
37
+
38
+ def expected_request(options = {})
39
+ options = valid_options.merge(options)
40
+
41
+ request = Nokogiri::XML::Builder.new do |xml|
42
+ xml.FbiXml {
43
+ xml.Ticket
44
+ xml.FbiMsgsRq {
45
+ xml.GetPartListRq {
46
+ #TODO Figure out what goes here!
47
+ }
48
+ }
49
+ }
50
+ end
51
+
52
+ request.to_xml
53
+ end
54
+
55
+ def expected_response
56
+ Nokogiri::XML::Builder.new do |xml|
57
+ xml.response {
58
+ xml.GetPartListRs(statusCode: '1000', statusMessage: "Success!") {
59
+ #TODO figure out what goes here!
60
+ }
61
+ }
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#get_pick" 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_pick("S50023-11")
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.GetPickRq {
26
+ xml.PickNum "S50023-11"
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.GetPickRs(statusCode: '1000', statusMessage: "Success!") {
39
+ #TODO figure out what goes here!
40
+ }
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end