minimul / qbo_api

Ruby JSON-only client for QuickBooks Online API v3. Built on top of the Faraday gem.
MIT License
85 stars 46 forks source link

Purchase objects returned without root key? #93

Closed joshk6 closed 4 years ago

joshk6 commented 6 years ago

When I execute a api.get("PurchaseOrder", 167) I get a json result that looks like:

{"PurchaseOrder=> {"ShipAddr"=> {"id"="99", [...] } }

i.e. everything is under root key "PurchaseOrder"

When I execute a get for a purchase, api.get("Purchase", 157). I get a json result without a root, instead I get a hash that starts as below, with no root key "Purchase"=>, instead just a collection of elements.

{ "AccountRef"=>{"value"=>152, "name"="Some Account}, "PaymentType"=>"Check", [...] }

Is that by design? When you run read requests in the API explorer both purchase and purchaseorder return a root key. Wondering why QboApi only does sometime and if there some way to know when it will and when it won't?

minimul commented 6 years ago

Yeah, I see what you mean, however, .get( :purchase_order, 99) does work as expected (no root).

Moral of the story, just use snaked_case symbols or strings.

I'll leave this open and add something to the README around this. Related: https://github.com/minimul/qbo_api/issues/63

joshk6 commented 6 years ago

Ok thanks. Same comment should likely go in api.all which returns unusually structured result when you use :PurchaseOrder instead of :purchase_order