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,12 @@
1
+ module Fishbowl::Requests
2
+ def self.get_customer_name_list
3
+ _, _, response = Fishbowl::Objects::BaseObject.new.send_request('CustomerNameListRq', 'CustomerNameListRs')
4
+
5
+ results = []
6
+ response.xpath("//Customer/Name").each do |customer_xml|
7
+ results << customer_xml.inner_text
8
+ end
9
+
10
+ results
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fishbowl::Requests
2
+ def self.get_export_list
3
+ _, _, response = Fishbowl::Objects::BaseObject.new.send_request('ExportListRq', 'ExportListRs')
4
+
5
+ results = []
6
+ #response.xpath("//Customer/Name").each do |customer_xml|
7
+ # results << customer_xml.inner_text
8
+ #end
9
+
10
+ results
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fishbowl::Requests
2
+ def self.get_import_list
3
+ _, _, response = Fishbowl::Objects::BaseObject.new.send_request('ImportListRq', 'ImportListRs')
4
+
5
+ results = []
6
+ #response.xpath("//Customer/Name").each do |customer_xml|
7
+ # results << customer_xml.inner_text
8
+ #end
9
+
10
+ results
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fishbowl::Requests
2
+ def self.get_location_group_list
3
+ _, _, response = Fishbowl::Objects::BaseObject.new.send_request('LocationGroupRq', 'LocationGroupRs')
4
+
5
+ results = []
6
+ #response.xpath("//Customer/Name").each do |customer_xml|
7
+ # results << customer_xml.inner_text
8
+ #end
9
+
10
+ results
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fishbowl::Requests
2
+ def self.get_location_list
3
+ _, _, response = Fishbowl::Objects::BaseObject.new.send_request('LocationListRq', 'LocationListRs')
4
+
5
+ results = []
6
+ #response.xpath("//Customer/Name").each do |customer_xml|
7
+ # results << customer_xml.inner_text
8
+ #end
9
+
10
+ results
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fishbowl::Requests
2
+ def self.get_uom_list
3
+ _, _, response = Fishbowl::Objects::BaseObject.new.send_request('UOMRq', 'UOMRs')
4
+
5
+ results = []
6
+ response.xpath("//UOM").each do |uom_xml|
7
+ results << Fishbowl::Objects::UOM.new(uom_xml)
8
+ end
9
+
10
+ results
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fishbowl::Requests
2
+ def self.get_location_group_list
3
+ _, _, response = Fishbowl::Objects::BaseObject.new.send_request('VendorListRq', 'VendorListRs')
4
+
5
+ results = []
6
+ response.xpath("//Vendor").each do |vendor_xml|
7
+ results << Fishbowl::Objects::Vendor.new(vendor_xml)
8
+ end
9
+
10
+ results
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fishbowl::Requests
2
+ def self.get_location_group_list
3
+ _, _, response = Fishbowl::Objects::BaseObject.new.send_request('VendorNameListRq', 'VendorNameListRs')
4
+
5
+ results = []
6
+ #response.xpath("//Customer/Name").each do |customer_xml|
7
+ # results << customer_xml.inner_text
8
+ #end
9
+
10
+ results
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fishbowl::Requests
2
+ def self.get_work_order_list
3
+ _, _, response = Fishbowl::Objects::BaseObject.new.send_request('WorkOrderListRq', 'WorkOrderListRs')
4
+
5
+ results = []
6
+ response.xpath("//WO").each do |work_order_xml|
7
+ results << Fishbowl::Objects::WorkOrder.new(work_order_xml)
8
+ end
9
+
10
+ results
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ module Fishbowl::Requests
2
+ def self.void_sales_order(number)
3
+ request = format_add_sales_order_item_request(number.to_s)
4
+ Fishbowl::Objects::BaseObject.new.send_request(request, 'VoidSORs')
5
+ end
6
+
7
+ private
8
+
9
+ def self.format_add_sales_order_item_request(number)
10
+ Nokogiri::XML::Builder.new do |xml|
11
+ xml.request {
12
+ xml.VoidSORq {
13
+ xml.SONumber number
14
+ }
15
+ }
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Fishbowl # :nodoc:
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,183 @@
1
+ ---
2
+ # Fishbowl Inventory Api Status Codes
3
+ codes:
4
+ 1000:
5
+ code: 1000
6
+ message: Success!
7
+ 1001:
8
+ code: 1001
9
+ message: Unknown Message Received
10
+ 1002:
11
+ code: 1002
12
+ message: Connection to Fishbowl Server was lost
13
+ 1003:
14
+ code: 1003
15
+ message: Some Requests had errors -- now isn't that helpful...
16
+ 1004:
17
+ code: 1004
18
+ message: There was an error with the database.
19
+ 1009:
20
+ code: 1009
21
+ message: Fishbowl Server has been shut down.
22
+ 1010:
23
+ code: 1010
24
+ message: You have been logged off the server by an administrator.
25
+ 1012:
26
+ code: 1012
27
+ message: Unknown request function.
28
+ 1100:
29
+ code: 1100
30
+ message: Unknown login error occurred.
31
+ 1110:
32
+ code: 1110
33
+ message: A new Integrated Application has been added to Fishbowl Inventory. Please contact your Fishbowl Inventory Administrator to approve this Integrated Application."
34
+ 1111:
35
+ code: 1111
36
+ message: This Integrated Application registration key does not match."
37
+ 1112:
38
+ code: 1112
39
+ message: This Integrated Application has not been approved by the Fishbowl Inventory Administrator."
40
+ 1120:
41
+ code: 1120
42
+ message: Invalid Username or Password."
43
+ 1130:
44
+ code: 1130
45
+ message: Invalid Ticket passed to Fishbowl Inventory Server."
46
+ 1131:
47
+ code: 1131
48
+ message: Invalid Key value."
49
+ 1140:
50
+ code: 1140
51
+ message: Initialization token is not correct type."
52
+ 1150:
53
+ code: 1150
54
+ message: Request was invalid"
55
+ 1160:
56
+ code: 1160
57
+ message: Response was invalid."
58
+ 1162:
59
+ code: 1162
60
+ message: The login limit has been reached for the server's key."
61
+ 1200:
62
+ code: 1200
63
+ message: Custom Field is invalid."
64
+ 1500:
65
+ code: 1500
66
+ message: The import was not properly formed."
67
+ 1501:
68
+ code: 1501
69
+ message: That import type is not supported"
70
+ 1502:
71
+ code: 1502
72
+ message: File not found."
73
+ 1503:
74
+ code: 1503
75
+ message: That export type is not supported."
76
+ 1504:
77
+ code: 1504
78
+ message: File could not be written to."
79
+ 1505:
80
+ code: 1505
81
+ message: The import data was of the wrong type."
82
+ 2000:
83
+ code: 2000
84
+ message: Was not able to find the Part {0}."
85
+ 2001:
86
+ code: 2001
87
+ message: The part was invalid."
88
+ 2100:
89
+ code: 2100
90
+ message: Was not able to find the Product {0}."
91
+ 2101:
92
+ code: 2101
93
+ message: The product was invalid."
94
+ 2200:
95
+ code: 2200
96
+ message: The yield failed."
97
+ 2201:
98
+ code: 2201
99
+ message: Commit failed."
100
+ 2202:
101
+ code: 2202
102
+ message: Add initial inventory failed."
103
+ 2203:
104
+ code: 2203
105
+ message: Can not adjust committed inventory."
106
+ 2300:
107
+ code: 2300
108
+ message: Was not able to find the Tag number {0}."
109
+ 2301:
110
+ code: 2301
111
+ message: The tag is invalid."
112
+ 2302:
113
+ code: 2302
114
+ message: The tag move failed."
115
+ 2303:
116
+ code: 2303
117
+ message: Was not able to save Tag number {0}."
118
+ 2304:
119
+ code: 2304
120
+ message: Not enough available inventory in Tagnumber {0}."
121
+ 2305:
122
+ code: 2305
123
+ message: Tag number {0} is a location."
124
+ 2400:
125
+ code: 2400
126
+ message: Invalid UOM."
127
+ 2401:
128
+ code: 2401
129
+ message: UOM {0} not found."
130
+ 2402:
131
+ code: 2402
132
+ message: Integer UOM {0} cannot have non-integer quantity."
133
+ 2500:
134
+ code: 2500
135
+ message: The Tracking is not valid."
136
+ 2510:
137
+ code: 2510
138
+ message: Serial number is missing."
139
+ 2511:
140
+ code: 2511
141
+ message: Serial number is null."
142
+ 2512:
143
+ code: 2512
144
+ message: Serial number is duplicate."
145
+ 2513:
146
+ code: 2513
147
+ message: Serial number is not valid."
148
+ 2600:
149
+ code: 2600
150
+ message: Location not found."
151
+ 2601:
152
+ code: 2601
153
+ message: Invalid location."
154
+ 2602:
155
+ code: 2602
156
+ message: Location Group {0} not found."
157
+ 3000:
158
+ code: 3000
159
+ message: Customer {0} not found."
160
+ 3001:
161
+ code: 3001
162
+ message: Customer is invalid."
163
+ 3100:
164
+ code: 3100
165
+ message: Vendor {0} not found."
166
+ 3101:
167
+ code: 3101
168
+ message: Vendor is invalid."
169
+ 4000:
170
+ code: 4000
171
+ message: There was an error load PO {0}."
172
+ 4001:
173
+ code: 4001
174
+ message: Unknow status {0}."
175
+ 4002:
176
+ code: 4002
177
+ message: Unknown carrier {0}."
178
+ 4003:
179
+ code: 4003
180
+ message: Unknown QuickBooks class {0}."
181
+ 4004:
182
+ code: 4004
183
+ message: PO does not have a PO number. Please turn on the auto-assign PO number option in the purchase order module options."
@@ -69,45 +69,4 @@ describe Fishbowl::Objects::Account do
69
69
  Fishbowl::Objects::Account.get_list.should be_an(Array)
70
70
  end
71
71
  end
72
-
73
- describe ".get_balance" do
74
- let(:proper_request) do
75
- Nokogiri::XML::Builder.new do |xml|
76
- xml.FbiXml {
77
- xml.Ticket
78
- xml.FbiMsgsRq {
79
- xml.GetAccountBalanceRq {
80
- xml.Account "General Account"
81
- }
82
- }
83
- }
84
- end
85
- end
86
-
87
- before :each do
88
- canned_response = Nokogiri::XML::Builder.new do |xml|
89
- xml.response {
90
- xml.GetAccountBalanceRs(statusCode: '1000', statusMessage: "Success!") {
91
- xml.Account {
92
- xml.Name "Demo Account"
93
- xml.AccountingID "DEMO"
94
- xml.AccountType 9
95
- xml.Balance "1200.00"
96
- }
97
- }
98
- }
99
- end
100
-
101
- mock_the_response(canned_response)
102
- end
103
-
104
- it "should properly format the request" do
105
- Fishbowl::Objects::Account.get_balance("General Account")
106
- connection.last_write.should be_equivalent_to(proper_request.to_xml)
107
- end
108
-
109
- it "should return the balance for the requested Account" do
110
- Fishbowl::Objects::Account.get_balance("General Account").should be_a(String)
111
- end
112
- end
113
72
  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