Module: Fishbowl::Requests
- Defined in:
- lib/fishbowl/requests.rb,
lib/fishbowl/requests/get_product.rb,
lib/fishbowl/requests/get_uom_list.rb,
lib/fishbowl/requests/make_payment.rb,
lib/fishbowl/requests/add_inventory.rb,
lib/fishbowl/requests/get_export_list.rb,
lib/fishbowl/requests/get_import_list.rb,
lib/fishbowl/requests/get_vendor_list.rb,
lib/fishbowl/requests/total_inventory.rb,
lib/fishbowl/requests/adjust_inventory.rb,
lib/fishbowl/requests/get_account_list.rb,
lib/fishbowl/requests/get_carrier_list.rb,
lib/fishbowl/requests/load_sales_order.rb,
lib/fishbowl/requests/save_sales_order.rb,
lib/fishbowl/requests/void_sales_order.rb,
lib/fishbowl/requests/get_customer_list.rb,
lib/fishbowl/requests/get_location_list.rb,
lib/fishbowl/requests/get_product_price.rb,
lib/fishbowl/requests/inventory_quantity.rb,
lib/fishbowl/requests/get_account_balance.rb,
lib/fishbowl/requests/get_work_order_list.rb,
lib/fishbowl/requests/add_sales_order_item.rb,
lib/fishbowl/requests/get_vendor_name_list.rb,
lib/fishbowl/requests/get_customer_name_list.rb,
lib/fishbowl/requests/get_location_group_list.rb
Class Method Summary collapse
- .add_inventory(options = {}) ⇒ Object
- .add_sales_order_item(options = {}) ⇒ Object
- .adjust_inventory(options = {}) ⇒ Object
- .get_account_balance(account_name) ⇒ Object
- .get_account_list ⇒ Object
- .get_carrier_list ⇒ Object
- .get_customer_list ⇒ Object
- .get_customer_name_list ⇒ Object
- .get_export_list ⇒ Object
- .get_import_list ⇒ Object
- .get_location_group_list ⇒ Object
- .get_location_list ⇒ Object
- .get_product(product_number) ⇒ Object
- .get_product_price(options) ⇒ Object
- .get_uom_list ⇒ Object
- .get_work_order_list ⇒ Object
- .inventory_quantity(part_num) ⇒ Object
- .load_sales_order(order_number) ⇒ Object
- .make_payment(options) ⇒ Object
- .save_sales_order(options) ⇒ Object
- .total_inventory(part_num, location_group) ⇒ Object
- .void_sales_order(number) ⇒ Object
Class Method Details
.add_inventory(options = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/fishbowl/requests/add_inventory.rb', line 2 def self.add_inventory( = {}) = .symbolize_keys %w{part_number quantity uom_id cost location_tag_number tag_number}.each do |required_field| raise ArgumentError if [required_field.to_sym].nil? end raise ArgumentError unless [:tracking].nil? || [:tracking].is_a?(Fishbowl::Object::Tracking) request = format_add_inventory_request() Fishbowl::Objects::BaseObject.new.send_request(request, 'AddInventoryRs') end |
.add_sales_order_item(options = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/fishbowl/requests/add_sales_order_item.rb', line 2 def self.add_sales_order_item( = {}) = .symbolize_keys %w{order_number id product_number sales_order_id description taxable quantity product_price total_price uom_code item_type status quickbooks_class_name new_item_flag}.each do |required_field| raise ArgumentError if [required_field.to_sym].nil? end request = format_add_sales_order_item_request() Fishbowl::Objects::BaseObject.new.send_request(request, 'AddSOItemRs') end |
.adjust_inventory(options = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/fishbowl/requests/adjust_inventory.rb', line 2 def self.adjust_inventory( = {}) = .symbolize_keys %w{tag_number quantity}.each do |required_field| raise ArgumentError if [required_field.to_sym].nil? end raise ArgumentError unless [:tracking].nil? || [:tracking].is_a?(Fishbowl::Object::Tracking) request = format_adjust_inventory_request() Fishbowl::Objects::BaseObject.new.send_request(request, 'AdjustInventoryRs') end |
.get_account_balance(account_name) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/fishbowl/requests/get_account_balance.rb', line 2 def self.get_account_balance(account_name) builder = Nokogiri::XML::Builder.new do |xml| xml.request { xml.GetAccountBalanceRq { xml.Account (account.is_a?(Account) ? account.name : account) } } end _, _, response = Fishbowl::Objects::BaseObject.new.send_request(builder, "GetAccountBalanceRs") response.xpath("//Account/Balance").first.inner_text end |
.get_account_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/fishbowl/requests/get_account_list.rb', line 2 def self.get_account_list _, _, response = Fishbowl::Objects::BaseObject.new.send_request('GetAccountListRq', 'GetAccountListRs') results = [] response.xpath("//Account").each do |account_xml| results << Account.new(account_xml) end results end |
.get_carrier_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/fishbowl/requests/get_carrier_list.rb', line 2 def self.get_carrier_list puts "getting carriers" code, response = Fishbowl::Objects::BaseObject.new.send_request('CarrierListRq', 'FbiMsgsRs/CarrierListRs') results = [] response.xpath("//Carriers/Name").each do |carrier_xml| results << Fishbowl::Objects::Carrier.new(carrier_xml) end results end |
.get_customer_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/fishbowl/requests/get_customer_list.rb', line 2 def self.get_customer_list _, _, response = Fishbowl::Objects::BaseObject.new.send_request('CustomerListRq', 'CustomerListRs') results = [] response.xpath("//Customer").each do |customer_xml| results << Fishbowl::Objects::Customer.new(customer_xml) end results end |
.get_customer_name_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/fishbowl/requests/get_customer_name_list.rb', line 2 def self.get_customer_name_list _, _, response = Fishbowl::Objects::BaseObject.new.send_request('CustomerNameListRq', 'CustomerNameListRs') results = [] response.xpath("//Customer/Name").each do |customer_xml| results << customer_xml.inner_text end results end |
.get_export_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/fishbowl/requests/get_export_list.rb', line 2 def self.get_export_list _, _, response = Fishbowl::Objects::BaseObject.new.send_request('ExportListRq', 'ExportListRs') results = [] #response.xpath("//Customer/Name").each do |customer_xml| # results << customer_xml.inner_text #end results end |
.get_import_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/fishbowl/requests/get_import_list.rb', line 2 def self.get_import_list _, _, response = Fishbowl::Objects::BaseObject.new.send_request('ImportListRq', 'ImportListRs') results = [] #response.xpath("//Customer/Name").each do |customer_xml| # results << customer_xml.inner_text #end results end |
.get_location_group_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/fishbowl/requests/get_vendor_list.rb', line 2 def self.get_location_group_list _, _, response = Fishbowl::Objects::BaseObject.new.send_request('VendorListRq', 'VendorListRs') results = [] response.xpath("//Vendor").each do |vendor_xml| results << Fishbowl::Objects::Vendor.new(vendor_xml) end results end |
.get_location_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/fishbowl/requests/get_location_list.rb', line 2 def self.get_location_list _, _, response = Fishbowl::Objects::BaseObject.new.send_request('LocationListRq', 'LocationListRs') results = [] #response.xpath("//Customer/Name").each do |customer_xml| # results << customer_xml.inner_text #end results end |
.get_product(product_number) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fishbowl/requests/get_product.rb', line 2 def self.get_product(product_number) raise ArgumentError if product_number.nil? builder = Nokogiri::XML::Builder.new do |xml| xml.request { xml.ProductGetRq { xml.Number product_number xml.GetImage false } } end code, response = Fishbowl::Objects::BaseObject.new.send_request(builder, "ProductGetRs") response.xpath("//FbiXml/FbiMsgsRs/ProductGetRs/Product") end |
.get_product_price(options) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fishbowl/requests/get_product_price.rb', line 2 def self.get_product_price() .symbolize_keys %w{product_number customer_name qauntity date}.each do |required_field| raise ArgumentError if [required_field.to_sym].nil? end builder = Nokogiri::XML::Builder.new do |xml| xml.request { xml.ProductPriceRq { xml.ProductNumber } } end _, _, response = Fishbowl::Objects::BaseObject.new.send_request(builder, "GetAccountBalanceRs") response.xpath("//Account/Balance").first.inner_text end |
.get_uom_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/fishbowl/requests/get_uom_list.rb', line 2 def self.get_uom_list _, _, response = Fishbowl::Objects::BaseObject.new.send_request('UOMRq', 'UOMRs') results = [] response.xpath("//UOM").each do |uom_xml| results << Fishbowl::Objects::UOM.new(uom_xml) end results end |
.get_work_order_list ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/fishbowl/requests/get_work_order_list.rb', line 2 def self.get_work_order_list _, _, response = Fishbowl::Objects::BaseObject.new.send_request('WorkOrderListRq', 'WorkOrderListRs') results = [] response.xpath("//WO").each do |work_order_xml| results << Fishbowl::Objects::WorkOrder.new(work_order_xml) end results end |
.inventory_quantity(part_num) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fishbowl/requests/inventory_quantity.rb', line 2 def self.inventory_quantity(part_num) raise ArgumentError if part_num.nil? builder = Nokogiri::XML::Builder.new do |xml| xml.request { xml.InvQtyRq { xml.PartNum part_num } } end code, response = Fishbowl::Objects::BaseObject.new.send_request(builder, "InvQtyRs") response.xpath("//FbiXml/FbiMsgsRs/InvQtyRs") end |
.load_sales_order(order_number) ⇒ Object
2 3 4 5 6 |
# File 'lib/fishbowl/requests/load_sales_order.rb', line 2 def self.load_sales_order(order_number) raise Fishbowl::Errors.ArgumentError if order_number.nil? request = load_order_request(order_number) Fishbowl::Objects::BaseObject.new.send_request(request, 'LoadSORs') end |
.make_payment(options) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/fishbowl/requests/make_payment.rb', line 2 def self.make_payment() # options = options.symbolize_keys # %w{amount so_number payment_method}.each do |required_field| raise ArgumentError if [required_field.to_sym].nil? end request = format_payment() Fishbowl::Objects::BaseObject.new.send_request(request, 'MakePaymentRs') end |
.save_sales_order(options) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/fishbowl/requests/save_sales_order.rb', line 2 def self.save_sales_order() # options = options.symbolize_keys # # %w{number salesman customer_name status # items}.each do |required_field| # raise ArgumentError if options[required_field.to_sym].nil? # end request = format_sales_order() Fishbowl::Objects::BaseObject.new.send_request(request, 'SaveSORs') end |
.total_inventory(part_num, location_group) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fishbowl/requests/total_inventory.rb', line 2 def self.total_inventory(part_num, location_group) raise ArgumentError if part_num.nil? builder = Nokogiri::XML::Builder.new do |xml| xml.request { xml.GetTotalInventoryRq { xml.PartNumber part_num xml.LocationGroup location_group } } end code, response = Fishbowl::Objects::BaseObject.new.send_request(builder, "GetTotalInventoryRs") response.xpath("//FbiXml/FbiMsgsRs/GetTotalInventoryRs") end |
.void_sales_order(number) ⇒ Object
2 3 4 5 |
# File 'lib/fishbowl/requests/void_sales_order.rb', line 2 def self.void_sales_order(number) request = format_add_sales_order_item_request(number.to_s) Fishbowl::Objects::BaseObject.new.send_request(request, 'VoidSORs') end |