Permalink
Browse files

docs update and fixed a bug where the sort field was not being proper…

…ly specified in the request
  • Loading branch information...
1 parent a7e980f commit df3f708a23fea57338e34994d8f8b81728243067 @ruckus committed Feb 19, 2012
Showing with 29 additions and 4 deletions.
  1. +28 −3 README.md
  2. +1 −1 lib/quickeebooks/service/service_base.rb
View
@@ -37,9 +37,12 @@ Now we can initialize any of the `Service` clients:
```ruby
customer_service = Quickeebooks::Service::Customer.new(oauth_client, realm_id)
customer_service.list
-=> [ #<Quickeebooks::Model::Customer:0x007f8e29259770>, #<Quickeebooks::Model::Customer:0x0078768202020>, ... ]
+
+# returns a `Collection` object
```
+See *Retrieving Objects* for the complete docs on fetching collections.
+
Quickbooks API requires that all HTTP operations are performed against a client-specific "Base URL", as discussed here:
https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0400_QuickBooks_Online/0100_Calling_Data_Services/0010_Getting_the_Base_URL
@@ -71,6 +74,8 @@ customer_service = Quickeebooks::Service::Customer.new(oauth_client, realm_id,)
customers = customer_service.list
```
+Return result: a `Collection` instance with properties: `entries`, `current_page`, `count` which should be self-explanatory.
+
### Filtering
All filters in the Intuit documentation are supported: text, datetime, boolean.
@@ -116,8 +121,7 @@ Specify a type of `:boolean` and your desired `:field` and a `:value` with eithe
```ruby
# find all customers and exclude jobs
-datetime = Time.mktime(2011, 2, 15)
-Quickeebooks::Service::Filter.new(:datetime, :field => 'IncludeJobs', :value => false)
+Quickeebooks::Service::Filter.new(:boolean, :field => 'IncludeJobs', :value => false)
```
Once you have created all of your `Filters` than just pass an array of them to any services `list` method and they will all be applied.
@@ -144,6 +148,27 @@ Example
sorter = Quickeebooks::Service::Sort.new('FamilyName', 'AtoZ')
```
+## Bringing it all together
+
+Goal: fetch all customers with a last name of Smith starting at the first page with a per page size of 30, created between May and August of 2011 and sort by last name from A-to-Z.
+
+```ruby
+filters = []
+filters << Quickeebooks::Service::Filter.new(:text, :field => 'FamilyName', :value => 'Smith')
+
+d1 = Time.mktime(2011, 5, 1)
+d2 = Time.mktime(2011, 8, 1)
+filters << Quickeebooks::Service::Filter.new(:datetime, :field => 'CreateTime', :after => d1, :before => d2)
+
+sorter = Quickeebooks::Service::Sort.new('FamilyName', 'AtoZ')
+
+customer_service = Quickeebooks::Service::Customer.new(oauth_client, realm_id)
+customers = customer_service.list(filters, 1, 30, sort)
+=>
+customers.count = 67
+customers.current_page = 1
+customers.entries = [ #<Quickeebooks::Model::Customer:0x007f8e29259770>, #<Quickeebooks::Model::Customer:0x0078768202020>, ... ]
+```
## Author
@@ -90,7 +90,7 @@ def fetch_collection(resource, container, model, filters = [], page = 1, per_pag
post_body_lines << "ResultsPerPage=#{per_page}"
if sort
- post_body_lines << CGI.escape("Sort=#{sort.to_s}")
+ post_body_lines << "Sort=#{CGI.escape(sort.to_s)}"
end
body = post_body_lines.join("&")

0 comments on commit df3f708

Please sign in to comment.