我想通过我的rails应用程序中的API在我的Quickbooks帐户中创建发票,但它需要在创建发票之前添加客户和项目。但我无法了解如何通过API添加客户和项目。你能建议我吗???
感谢。
答案 0 :(得分:0)
从这里开始:
按照文档(https://developer.intuit.com/docs/0100_accounting)操作OAuth以连接到QuickBooks Online。
通过HTTP将JSON请求发布到QuickBooks Online来创建客户:
JSON请求看起来像这样:
{
"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"
}
你会得到这样的东西:
Id
请务必保存Items
属性,稍后您将需要该属性。
创建 import java.io.*;
import java.util.Scanner;
public class main
{
public static void main (String [] args)throws Exception
{
Scanner sf = new Scanner(new FileInputStream("prog415h.dat"));
int[] number = new int[100];
int count = 0;
Runner runner = new Runner();
while(sf.hasNextLine())
{
number[count] = sf.nextInt();
System.out.print("The orginal set of numbers are: " + number[count] + " ");
count++;
}
runner.Repeat();
}
}
public class Runner
{
public static int[] numbers;
public static void setNumbers(int[] numbers)
{
Runner.numbers = numbers;
}
public static void Repeat()
{
for (int i = 0; i < 30; i++)
{
int x = numbers[i];
boolean good = true; //any duplicates found?
for (int j = 0; j < 30; j++)
{
if (i != j) //dont compare it to itself
{
if (x == numbers[j]) // duplicate
{
good = false;
System.out.print("");
}
}
}
}
}
}
的过程类似。文档:
一切都只是标准的OAuth请求。去抓Rails的OAuth库,你应该全部设置好。