Permalink
Browse files

always enable custom fields for Item

  • Loading branch information...
1 parent 585dcba commit ded25697d3cbd3b77639667753c8a5c23e7463d1 @ruckus committed Apr 3, 2012
View
2 lib/quickeebooks/windows/service/account.rb
@@ -7,7 +7,7 @@ module Service
class Account < Quickeebooks::Windows::Service::ServiceBase
def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
- fetch_collection("accounts", "Account", Quickeebooks::Windows::Model::Account, filters, page, per_page, sort, options)
+ fetch_collection("accounts", "Account", Quickeebooks::Windows::Model::Account, nil, filters, page, per_page, sort, options)
end
end
View
2 lib/quickeebooks/windows/service/customer.rb
@@ -7,7 +7,7 @@ module Service
class Customer < Quickeebooks::Windows::Service::ServiceBase
def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
- fetch_collection("customer", "Customer", Quickeebooks::Windows::Model::Customer, filters, page, per_page, sort, options)
+ fetch_collection("customer", "Customer", Quickeebooks::Windows::Model::Customer, nil, filters, page, per_page, sort, options)
end
end
View
2 lib/quickeebooks/windows/service/invoice.rb
@@ -18,7 +18,7 @@ class Invoice < Quickeebooks::Windows::Service::ServiceBase
# sort: +Sort+ object
# options: +Hash+ extra arguments
def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
- fetch_collection("invoices", "Invoice", Quickeebooks::Windows::Model::Invoice, filters, page, per_page, sort, options)
+ fetch_collection("invoices", "Invoice", Quickeebooks::Windows::Model::Invoice, nil, filters, page, per_page, sort, options)
end
end
View
3 lib/quickeebooks/windows/service/item.rb
@@ -7,7 +7,8 @@ module Service
class Item < Quickeebooks::Windows::Service::ServiceBase
def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
- fetch_collection("item", "Item", Quickeebooks::Windows::Model::Item, filters, page, per_page, sort, options)
+ custom_field_query = '<ItemQuery xmlns="http://www.intuit.com/sb/cdm/v2"><CustomFieldEnable>true</CustomFieldEnable></ItemQuery>'
+ fetch_collection("item", "Item", Quickeebooks::Windows::Model::Item, custom_field_query, filters, page, per_page, sort, options)
end
end
View
8 lib/quickeebooks/windows/service/service_base.rb
@@ -52,12 +52,16 @@ def valid_xml_document(xml)
%Q{<?xml version="1.0" encoding="utf-8"?>\n#{xml.strip}}
end
- def fetch_collection(resource, container, model, filters = [], page = 1, per_page = 20, sort = nil, options ={})
+ def fetch_collection(resource, container, model, custom_field_query = nil, filters = [], page = 1, per_page = 20, sort = nil, options ={})
raise ArgumentError, "missing resource to fetch" if resource.nil?
raise ArgumentError, "missing result container" if container.nil?
raise ArgumentError, "missing model to instantiate" if model.nil?
- response = do_http_get(url_for_resource(resource), {}, {'Content-Type' => 'text/html'})
+ if custom_field_query != nil
+ response = do_http_post(url_for_resource(resource), custom_field_query, {'Content-Type' => 'text/xml'})
+ else
+ response = do_http_get(url_for_resource(resource), {}, {'Content-Type' => 'text/html'})
+ end
if response
collection = Quickeebooks::Collection.new
xml = parse_xml(response.body)

0 comments on commit ded2569

Please sign in to comment.