I want to create invoice in my Quickbooks account through API from my rails application, but it requires to add customer and item before creating invoice. But I can't get the idea how to add customer and items through API. Can you suggest me???
Thanks.
Start here:
https://developer.intuit.com/
Follow the docs (https://developer.intuit.com/docs/0100_accounting) and implement OAuth to connect to QuickBooks Online.
Create customers by HTTP POSTing a JSON request to QuickBooks Online:
https://developer.intuit.com/docs/api/accounting/Customer
The JSON request will look something like this:
{
"BillAddr": {
"Line1": "123 Main Street",
"City": "Mountain View",
"Country": "USA",
"CountrySubDivisionCode": "CA",
"PostalCode": "94042"
},
"Notes": "Here are other details.",
"Title": "Mr",
"GivenName": "James",
"MiddleName": "B",
"FamilyName": "King",
"Suffix": "Jr",
"FullyQualifiedName": "King Groceries",
"CompanyName": "King Groceries",
"DisplayName": "King's Groceries",
"PrimaryPhone": {
"FreeFormNumber": "(555) 555-5555"
},
"PrimaryEmailAddr": {
"Address": "jdrew#myemail.com"
}
}
You'll get back something like this:
{
"Customer": {
"Taxable": true,
"BillAddr": {
"Id": "112",
"Line1": "123 Main Street",
"City": "Mountain View",
"Country": "USA",
"CountrySubDivisionCode": "CA",
"PostalCode": "94042"
},
"Notes": "Here are other details.",
"Job": false,
"BillWithParent": false,
"Balance": 0,
"BalanceWithJobs": 0,
"CurrencyRef": {
"value": "USD",
"name": "United States Dollar"
},
"PreferredDeliveryMethod": "Print",
"domain": "QBO",
"sparse": false,
"Id": "67",
"SyncToken": "0",
"MetaData": {
"CreateTime": "2015-07-23T10:58:12-07:00",
"LastUpdatedTime": "2015-07-23T10:58:12-07:00"
},
"Title": "Mr",
"GivenName": "James",
"MiddleName": "B",
"FamilyName": "King",
"Suffix": "Jr",
"FullyQualifiedName": "King's Groceries",
"CompanyName": "King Groceries",
"DisplayName": "King's Groceries",
"PrintOnCheckName": "King Groceries",
"Active": true,
"PrimaryPhone": {
"FreeFormNumber": "(555) 555-5555"
},
"PrimaryEmailAddr": {
"Address": "jdrew#myemail.com"
},
"DefaultTaxCodeRef": {
"value": "2"
}
},
"time": "2015-07-23T10:58:12.099-07:00"
}
Make sure you save that Id attribute, you'll need that later.
The process for creating Items is similar. Docs:
https://developer.intuit.com/docs/api/accounting/Item
Everything is just standard OAuth requests. Go grab an OAuth library for Rails and you should be all set.
Related
I am using QuickBooks Online API.
Documentation for the Account Object is here: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account
Sample Request URL:
GET /v3/company/<clientID>/query?query=<selectStatement>&minorversion=59
Content type:text/plain
Production Base URL:https://quickbooks.api.intuit.com
Sandbox Base URL:https://sandbox-quickbooks.api.intuit.com
Sample Query:
select * from Account where Metadata.CreateTime > '2014-12-31'
Sample Return:
{
"QueryResponse": {
"startPosition": 1,
"Account": [
{
"FullyQualifiedName": "Canadian Accounts Receivable",
"domain": "QBO",
"Name": "Canadian Accounts Receivable",
"Classification": "Asset",
"AccountSubType": "AccountsReceivable",
"CurrencyRef": {
"name": "United States Dollar",
"value": "USD"
},
"CurrentBalanceWithSubAccounts": 0,
"sparse": false,
"MetaData": {
"CreateTime": "2015-06-23T09:38:18-07:00",
"LastUpdatedTime": "2015-06-23T09:38:18-07:00"
},
"AccountType": "Accounts Receivable",
"CurrentBalance": 0,
"Active": true,
"SyncToken": "0",
"Id": "92",
"SubAccount": false
},
{
"FullyQualifiedName": "MyClients",
"domain": "QBO",
"Name": "MyClients",
"Classification": "Asset",
"AccountSubType": "AccountsReceivable",
"CurrencyRef": {
"name": "United States Dollar",
"value": "USD"
},
"CurrentBalanceWithSubAccounts": 0,
"sparse": false,
"MetaData": {
"CreateTime": "2015-07-13T12:34:47-07:00",
"LastUpdatedTime": "2015-07-13T12:34:47-07:00"
},
"AccountType": "Accounts Receivable",
"CurrentBalance": 0,
"Active": true,
"SyncToken": "0",
"Id": "93",
"SubAccount": false
},
{
"FullyQualifiedName": "MyJobs",
"domain": "QBO",
"Name": "MyJobs",
"Classification": "Asset",
"AccountSubType": "AccountsReceivable",
"CurrencyRef": {
"name": "United States Dollar",
"value": "USD"
},
"CurrentBalanceWithSubAccounts": 0,
"sparse": false,
"MetaData": {
"CreateTime": "2015-01-13T10:29:27-08:00",
"LastUpdatedTime": "2015-01-13T10:29:27-08:00"
},
"AccountType": "Accounts Receivable",
"CurrentBalance": 0,
"Active": true,
"SyncToken": "0",
"Id": "91",
"SubAccount": false
}
],
"maxResults": 3
},
"time": "2015-07-13T12:35:57.651-07:00"
}
In the Sample Request URL, I need to determine what to type into the "selectStatement".
I have found additional documentation here:
https://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries
You have an example of what to put for selectStatement in your post:
select * from Account where Metadata.CreateTime > '2014-12-31'
e.g.:
/v3/company/<clientID>/query?query=select * from Account where Metadata.CreateTime > '2014-12-31'&minorversion=59
I'm doing an integration of mobile app with the Office 365 Calendar. I want to show room capacity and location on the screen. I trying to find an API to get meeting room info (this info is available on website when selecting room as user).
I tried both Outlook REST API (version 2.0) and Microsoft Graph but found nothing in the docs on how to get such info.
Where I can find such API if it exists?
I know this is an old question but you can do it using the List Places API in Graph API: https://learn.microsoft.com/en-us/graph/api/place-list?view=graph-rest-1.0&tabs=http
GET https://graph.microsoft.com/v1.0/places/microsoft.graph.room
RESPONSE:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#places/microsoft.graph.room",
"value": [
{
"id": "3162F1E1-C4C0-604B-51D8-91DA78989EB1",
"emailAddress": "cf100#contoso.com",
"displayName": "Conf Room 100",
"address": {
"street": "4567 Main Street",
"city": "Buffalo",
"state": "NY",
"postalCode": "98052",
"countryOrRegion": "USA"
},
"geoCoordinates": {
"latitude": 47.640568390488626,
"longitude": -122.1293731033803
},
"phone": "000-000-0000",
"nickname": "Conf Room",
"label": "100",
"capacity": 50,
"building": "1",
"floorNumber": 1,
"isManaged": true,
"isWheelChairAccessible": false,
"bookingType": "standard",
"tags": [
"bean bags"
],
"audioDeviceName": null,
"videoDeviceName": null,
"displayDevice": "surface hub"
},
{
"id": "3162F1E1-C4C0-604B-51D8-91DA78970B97",
"emailAddress": "cf200#contoso.com",
"displayName": "Conf Room 200",
"address": {
"street": "4567 Main Street",
"city": "Buffalo",
"state": "NY",
"postalCode": "98052",
"countryOrRegion": "USA"
},
"geoCoordinates": {
"latitude": 47.640568390488625,
"longitude": -122.1293731033802
},
"phone": "000-000-0000",
"nickname": "Conf Room",
"label": "200",
"capacity": 40,
"building": "2",
"floorNumber": 2,
"isManaged": true,
"isWheelChairAccessible": false,
"bookingType": "standard",
"tags": [
"benches",
"nice view"
],
"audioDeviceName": null,
"videoDeviceName": null,
"displayDevice": "surface hub"
}
]
}
I created a bill through the QuickBooks Online (QBO) web UI. Then I queried using the API (v3, documented here). The response:
{
"SyncToken": "16",
"domain": "QBO",
"VendorRef": {
"name": "MyVendor",
"value": "237"
},
"TxnDate": "2014-12-07",
"TotalAmt": 1.83,
"CurrencyRef": {
"name": "United States Dollar",
"value": "USD"
},
"PayType": "Check",
"PrivateNote": "test billpayment description (mod)",
"sparse": false,
"Line": [
{
"Amount": 1.22,
"LinkedTxn": [
{
"TxnId": "1412",
"TxnType": "Bill"
}
]
}
],
"Id": "1413",
"CheckPayment": {
"PrintStatus": "NeedToPrint",
"BankAccountRef": {
"name": "MyBankAcct#1234",
"value": "137"
}
},
"MetaData": {
"CreateTime": "2014-12-07T18:44:51-08:00",
"LastUpdatedTime": "2014-12-10T20:20:28-08:00"
}
}
As you can see, it has $0.61 of the TotalAmt unapplied to any Bills. (The other $1.22 is applied to Bill 1412.) Now, when I try to update this bill to change JUST the amount applied to the linked transaction, I get unexpected results.
Here's the update request body:
{
"SyncToken": "16",
"domain": "QBO",
"VendorRef": {
"name": "MyVendor",
"value": "237"
},
"TxnDate": "2014-12-07",
"TotalAmt": 1.83,
"CurrencyRef": {
"name": "United States Dollar",
"value": "USD"
},
"PayType": "Check",
"PrivateNote": "test billpayment description (mod)",
"sparse": false,
"Line": [
{
"Amount": 1.21,
"LinkedTxn": [
{
"TxnId": "1412",
"TxnType": "Bill"
}
]
}
],
"Id": "1413",
"CheckPayment": {
"PrintStatus": "NeedToPrint",
"BankAccountRef": {
"name": "MyBankAcct#1234",
"value": "137"
}
},
"MetaData": {
"CreateTime": "2014-12-07T18:44:51-08:00",
"LastUpdatedTime": "2014-12-10T20:20:28-08:00"
}
}
In the response, it appears that the API just basically can't handle the situation (even though it clearly existed when I created it in the web UI). Look what happens to the TotalAmt attribute! It's reduced to whatever the payment was in the LinkedTxn:
{
"BillPayment": {
"VendorRef": {
"value": "237",
"name": "MyVendor"
},
"PayType": "Check",
"CheckPayment": {
"BankAccountRef": {
"value": "137",
"name": "MyBankAcct#1234"
},
"PrintStatus": "NeedToPrint"
},
"TotalAmt": 1.21,
"domain": "QBO",
"sparse": false,
"Id": "1413",
"SyncToken": "17",
"MetaData": {
"CreateTime": "2014-12-07T18:44:51-08:00",
"LastUpdatedTime": "2014-12-10T20:25:02-08:00"
},
"TxnDate": "2014-12-07",
"CurrencyRef": {
"value": "USD",
"name": "United States Dollar"
},
"PrivateNote": "test billpayment description (mod)",
"Line": [
{
"Amount": 1.21,
"LinkedTxn": [
{
"TxnId": "1412",
"TxnType": "Bill"
}
]
}
]
},
"time": "2014-12-10T20:25:01.91-08:00"
}
I don't see discussion of this on the known issues page, so I'm pretty confused.
If you have any suggestions as to how to get this to do what I want it to, I thank you for your thoughts!
I created a quite complex schema of the EventRegistration type.
It contained two tickets, had images, contact details, etc.
But all I could get once was a Now card that only contained the title of the event, the date, the location and a action button to open the mail.
I'm wondering, if all the additional data has some error or if this is currently all that is supported. I would have loved to see Logos, contact details, a cancellation link and of course the ticket itself (=QR-Code + download link). This would have been such a nice alternative to Apple's Passbook.
What are the plans for this feature? Is this still going to be developed, is there perhaps already a rough roadmap on when to expect this?
Additionally what I was wondering about is, that the "Email Markup Tester" was complaining that the ticketToken property would be invalid for that type, even though the documentation clearly states that it is part of the EventReservation type.
FYI, here is the anonymized schema I used:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "EventReservation",
"reservationNumber": "TFXLLUS00008",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"#type": "Person",
"name": "Name 1",
"email": "...#gmail.com"
},
"bookingAgent": {
"#type": "Organization",
"name": "My company",
"description": "My company - online ticketing",
"image": "http://www.MyCompany.com/link/to/logo_1500x1500px.jpg",
"url": "http://www.MyCompany.com",
"url/googlePlus": "https://plus.google.com/+MyCompany/",
"ContactPoint": {
"#type": "ContactPoint",
"email": "support#MyCompany.com",
"telephone": "123456789"
}
},
"reservationFor": {
"#type": "Event",
"name": "Test-Event",
"startDate": "2014-04-26T20:00:00+00:00",
"endDate": "2014-04-30T18:00:00+00:00",
"description": "This is a test event for demo purposes.",
"image": "http://www.MyCompany.com/link/to/event/logo.png",
"url": "http://www.MyCompany.com/link/to/event.html",
"location": {
"#type": "Place",
"name": "Congress hall",
"address": {
"#type": "PostalAddress",
"streetAddress": "Street. 1",
"addressLocality": "City",
"addressRegion": "",
"postalCode": "12345",
"addressCountry": "DE"
}
}
},
"ticketToken": "qrCode:4641484423168988",
"ticketNumber": "1690-8587-4723",
"numSeats": "1",
"ticketDownloadUrl": "https://www.MyCompany.com/linkToTicket.pdf",
"ticketPrintUrl": "https://www.MyCompany.com/linkToTicket.pdf",
"price": "100",
"priceCurrency": "EUR",
"bookingTime": "2014-04-26T13:57:50+00:00",
"modifiedTime": "2014-04-26T13:57:50+00:00"
},
{
"#context": "http://schema.org",
"#type": "EventReservation",
"reservationNumber": "TFXLLUS00008",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"#type": "Person",
"name": "Name 2",
"email": "...#gmail.com"
},
"bookingAgent": {
"#type": "Organization",
"name": "My company",
"description": "My company - online ticketing",
"image": "http://www.MyCompany.com/link/to/logo_1500x1500px.jpg",
"url": "http://www.MyCompany.com",
"url/googlePlus": "https://plus.google.com/+MyCompany/",
"ContactPoint": {
"#type": "ContactPoint",
"email": "support#MyCompany.com",
"telephone": "123456789"
}
},
"reservationFor": {
"#type": "Event",
"name": "Test-Event",
"startDate": "2014-04-26T20:00:00+00:00",
"endDate": "2014-04-30T18:00:00+00:00",
"description": "This is a test event for demo purposes.",
"image": "http://www.MyCompany.com/link/to/event/logo.png",
"url": "http://www.MyCompany.com/link/to/event.html",
"location": {
"#type": "Place",
"name": "Congress hall",
"address": {
"#type": "PostalAddress",
"streetAddress": "Street. 1",
"addressLocality": "City",
"addressRegion": "",
"postalCode": "12345",
"addressCountry": "DE"
}
}
},
"ticketToken": "qrCode:4020229019819219",
"ticketNumber": "5218-3082-0382",
"numSeats": "1",
"ticketDownloadUrl": "https://www.MyCompany.com/linkToTicket.pdf",
"ticketPrintUrl": "https://www.MyCompany.com/linkToTicket.pdf",
"price": "100",
"priceCurrency": "EUR",
"bookingTime": "2014-04-26T13:57:50+00:00",
"modifiedTime": "2014-04-26T13:57:50+00:00"
}
</script>
If I pass a BSON::OrderedHash (from a MongoDb collection) to JSON.pretty_generate I get the json document but unformatted. How can I get a bson document formatted like .pretty() does?
It works for me with mongo 1.9.1, bson 1.9.1, and json 1.8.0 as shown in the following test code, as close as can be expected.
pretty_bson.rb
require 'mongo'
require 'bson'
require 'json'
require 'test/unit'
class BsonPrettyTest < Test::Unit::TestCase
def setup
#client = Mongo::MongoClient.new
#db = #client['test']
#coll = #db['people']
#coll.remove
assert_equal 0, #coll.count
end
test "bson pretty" do
text = <<-EOF
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
EOF
hash = JSON.parse(text)
#coll.insert(hash)
doc = #coll.find_one
assert_equal BSON::OrderedHash, doc.class
puts JSON.pretty_generate(hash)
puts JSON.pretty_generate(doc)
end
end
ruby pretty_bson.rb
Loaded suite pretty_bson
Started
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
],
"_id": {"$oid": "51df0c537f11bab55d000001"}
}
{
"_id": {"$oid": "51df0c537f11bab55d000001"},
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
.
Finished in 0.005689 seconds.
1 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
175.78 tests/s, 351.56 assertions/s