Skip to content

Commit

Permalink
* Added Windows#Item::fetch_by_id
Browse files Browse the repository at this point in the history
  • Loading branch information
ruckus committed Jul 23, 2013
1 parent 31e8e43 commit 43305ff
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 2 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.14 (2013-07-22)

* Added Windows#Item::fetch_by_id

## 0.1.13 (2013-07-21)

* Removed UUIDTools gem in favor or Ruby stdlib SecureRandom to generate a "unique" ID.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ Customer | yes | yes | yes | no | yes |
Employee | no | no | yes | no | no |
Entitlement | n/a | n/a | n/a | n/a | n/a |
Invoice | yes | no | yes | no | no |
Item | yes | no | yes | no | no |
Item | yes | no | yes | yes | no |
Journal Entry | no | no | no | no | no |
Payment | yes | no | yes | no | yes |
Payment Method | no | no | yes | no | no |
Expand Down
2 changes: 1 addition & 1 deletion lib/quickeebooks/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Quickeebooks

VERSION = "0.1.13"
VERSION = "0.1.14"

end
5 changes: 5 additions & 0 deletions lib/quickeebooks/windows/service/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
fetch_collection(Quickeebooks::Windows::Model::Item, nil, filters, page, per_page, sort, options)
end

def fetch_by_id(id, idDomain = 'QB', options = {})
url = "#{url_for_resource(Quickeebooks::Windows::Model::Item::REST_RESOURCE)}/#{id}"
fetch_object(Quickeebooks::Windows::Model::Item, url, {:idDomain => idDomain})
end

def create(item)
# XML is a wrapped 'object' where the type is specified as an attribute
# <Object xsi:type="Item">
Expand Down
43 changes: 43 additions & 0 deletions spec/quickeebooks/windows/services/item_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
describe "Quickeebooks::Windows::Service::Item" do
before(:all) do
FakeWeb.allow_net_connect = false
qb_key = "key"
qb_secret = "secreet"

@realm_id = "9991111222"
@base_uri = "https://qbo.intuit.com/qbo36"
@oauth_consumer = OAuth::Consumer.new(qb_key, qb_key, {
:site => "https://oauth.intuit.com",
:request_token_path => "/oauth/v1/get_request_token",
:authorize_path => "/oauth/v1/get_access_token",
:access_token_path => "/oauth/v1/get_access_token"
})
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
end

it "can fetch a list of Items" do
xml = windowsFixture("items.xml")
model = Quickeebooks::Windows::Model::Item
service = Quickeebooks::Windows::Service::Item.new
service.access_token = @oauth
service.realm_id = @realm_id
FakeWeb.register_uri(:post, service.url_for_resource(model::REST_RESOURCE), :status => ["200", "OK"], :body => xml)
items = service.list
items.entries.count.should == 2
gruner = items.entries.first
gruner.name.should == "FGVS09"

end

it "can fetch an Item by ID" do
xml = windowsFixture("item.xml")
model = Quickeebooks::Windows::Model::Item
service = Quickeebooks::Windows::Service::Item.new
service.access_token = @oauth
service.realm_id = @realm_id
FakeWeb.register_uri(:get, "#{service.url_for_resource(model::REST_RESOURCE)}/407?idDomain=QB", :status => ["200", "OK"], :body => xml)
customer = service.fetch_by_id(407)
customer.name.should == "DWCSH11"
end

end
58 changes: 58 additions & 0 deletions spec/xml/windows/item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ../common/RestDataFilter.xsd">
<Items>
<Item>
<Id idDomain="QB">407</Id>
<SyncToken>1</SyncToken>
<MetaData>
<CreatedBy>app</CreatedBy>
<CreateTime>2013-05-07T21:04:22.0Z</CreateTime>
<LastModifiedBy>app</LastModifiedBy>
<LastUpdatedTime>2013-07-22T22:19:49.0Z</LastUpdatedTime>
</MetaData>
<ExternalKey idDomain="QB">407</ExternalKey>
<Synchronized>true</Synchronized>
<Name>DWCSH11</Name>
<Desc>2011 Deovlet Wines - Solomon Hills Chardonnay 12/750ML</Desc>
<Taxable>false</Taxable>
<Active>true</Active>
<UnitPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>0</Amount>
</UnitPrice>
<Type>Inventory</Type>
<UOMId idDomain="QB">1</UOMId>
<UOMAbbrv>By the Case - 12 pk</UOMAbbrv>
<IncomeAccountRef>
<AccountId idDomain="QB">8</AccountId>
<AccountName>Sales</AccountName>
<AccountType>Revenue</AccountType>
</IncomeAccountRef>
<PurchaseDesc>2011 Deovlet Wines - Solomon Hills Chardonnay 12/750ML</PurchaseDesc>
<PurchaseCost>
<CurrencyCode>USD</CurrencyCode>
<Amount>210</Amount>
</PurchaseCost>
<COGSAccountRef>
<AccountId idDomain="QB">44</AccountId>
<AccountName>Wine Cost</AccountName>
<AccountType>Expense</AccountType>
</COGSAccountRef>
<AssetAccountRef>
<AccountId idDomain="QB">42</AccountId>
<AccountName>Inventory Asset</AccountName>
<AccountType>Asset</AccountType>
</AssetAccountRef>
<PrefVendorRef>
<VendorId idDomain="QB">755</VendorId>
<VendorName>Deovlet Wines</VendorName>
</PrefVendorRef>
<AvgCost>
<CurrencyCode>USD</CurrencyCode>
<Amount>210</Amount>
</AvgCost>
<QtyOnHand>2.5</QtyOnHand>
<QtyOnPurchaseOrder>0</QtyOnPurchaseOrder>
<QtyOnSalesOrder>0</QtyOnSalesOrder>
</Item>
</Items>
</RestResponse>
134 changes: 134 additions & 0 deletions spec/xml/windows/items.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ../common/RestDataFilter.xsd">
<Items>
<Item>
<Id idDomain="QB">93</Id>
<SyncToken>1</SyncToken>
<MetaData>
<CreatedBy>app</CreatedBy>
<CreateTime>2012-04-25T13:20:06.0Z</CreateTime>
<LastModifiedBy>app</LastModifiedBy>
<LastUpdatedTime>2013-05-08T21:58:49.0Z</LastUpdatedTime>
</MetaData>
<ExternalKey idDomain="QB">93</ExternalKey>
<Synchronized>true</Synchronized>
<CustomField xsi:type="StringTypeCustomField">
<DefinitionId idDomain="QB">0</DefinitionId>
<Name>com.intuit.sb.qb.item.Producer</Name>
<Value>Forstreiter</Value>
</CustomField>
<CustomField xsi:type="StringTypeCustomField">
<DefinitionId idDomain="QB">1</DefinitionId>
<Name>com.intuit.sb.qb.item.Varietal</Name>
<Value>Veltliner</Value>
</CustomField>
<CustomField xsi:type="StringTypeCustomField">
<DefinitionId idDomain="QB">3</DefinitionId>
<Name>com.intuit.sb.qb.item.Vintage</Name>
<Value>2009</Value>
</CustomField>
<Name>FGVS09</Name>
<Desc>2009 Forstreiter - Gruner Veltliner Schiefer 12/750ML</Desc>
<Taxable>false</Taxable>
<Active>false</Active>
<UnitPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>276</Amount>
</UnitPrice>
<Type>Inventory</Type>
<UOMId idDomain="QB">1</UOMId>
<UOMAbbrv>By the Case - 12 pk</UOMAbbrv>
<IncomeAccountRef>
<AccountId idDomain="QB">8</AccountId>
<AccountName>Sales</AccountName>
<AccountType>Revenue</AccountType>
</IncomeAccountRef>
<PurchaseDesc>2009 Forstreiter - Gruner Veltliner Schiefer 12/750ML</PurchaseDesc>
<PurchaseCost>
<CurrencyCode>USD</CurrencyCode>
<Amount>154</Amount>
</PurchaseCost>
<COGSAccountRef>
<AccountId idDomain="QB">44</AccountId>
<AccountName>Wine Cost</AccountName>
<AccountType>Expense</AccountType>
</COGSAccountRef>
<AssetAccountRef>
<AccountId idDomain="QB">42</AccountId>
<AccountName>Inventory Asset</AccountName>
<AccountType>Asset</AccountType>
</AssetAccountRef>
<AvgCost>
<CurrencyCode>USD</CurrencyCode>
<Amount>154</Amount>
</AvgCost>
<QtyOnHand>0</QtyOnHand>
<QtyOnPurchaseOrder>0</QtyOnPurchaseOrder>
<QtyOnSalesOrder>0</QtyOnSalesOrder>
</Item>
<Item>
<Id idDomain="QB">92</Id>
<SyncToken>1</SyncToken>
<MetaData>
<CreatedBy>app</CreatedBy>
<CreateTime>2012-04-25T13:17:03.0Z</CreateTime>
<LastModifiedBy>app</LastModifiedBy>
<LastUpdatedTime>2013-04-12T17:27:20.0Z</LastUpdatedTime>
</MetaData>
<ExternalKey idDomain="QB">92</ExternalKey>
<Synchronized>true</Synchronized>
<CustomField xsi:type="StringTypeCustomField">
<DefinitionId idDomain="QB">0</DefinitionId>
<Name>com.intuit.sb.qb.item.Producer</Name>
<Value>Forstreiter</Value>
</CustomField>
<CustomField xsi:type="StringTypeCustomField">
<DefinitionId idDomain="QB">1</DefinitionId>
<Name>com.intuit.sb.qb.item.Varietal</Name>
<Value>Veltliner</Value>
</CustomField>
<CustomField xsi:type="StringTypeCustomField">
<DefinitionId idDomain="QB">3</DefinitionId>
<Name>com.intuit.sb.qb.item.Vintage</Name>
<Value>2010</Value>
</CustomField>
<Name>FGVK10</Name>
<Desc>2010 Forstreiter - Gruner Veltliner Kogl 12/750ML</Desc>
<Taxable>false</Taxable>
<Active>false</Active>
<UnitPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>180</Amount>
</UnitPrice>
<Type>Inventory</Type>
<UOMId idDomain="QB">1</UOMId>
<UOMAbbrv>By the Case - 12 pk</UOMAbbrv>
<IncomeAccountRef>
<AccountId idDomain="QB">8</AccountId>
<AccountName>Sales</AccountName>
<AccountType>Revenue</AccountType>
</IncomeAccountRef>
<PurchaseDesc>2010 Forstreiter - Gruner Veltliner Kogl 12/750ML</PurchaseDesc>
<PurchaseCost>
<CurrencyCode>USD</CurrencyCode>
<Amount>92</Amount>
</PurchaseCost>
<COGSAccountRef>
<AccountId idDomain="QB">44</AccountId>
<AccountName>Wine Cost</AccountName>
<AccountType>Expense</AccountType>
</COGSAccountRef>
<AssetAccountRef>
<AccountId idDomain="QB">42</AccountId>
<AccountName>Inventory Asset</AccountName>
<AccountType>Asset</AccountType>
</AssetAccountRef>
<AvgCost>
<CurrencyCode>USD</CurrencyCode>
<Amount>92.04</Amount>
</AvgCost>
<QtyOnHand>0</QtyOnHand>
<QtyOnPurchaseOrder>0</QtyOnPurchaseOrder>
<QtyOnSalesOrder>0</QtyOnSalesOrder>
</Item>
</Items>
</RestResponse>

0 comments on commit 43305ff

Please sign in to comment.