xerogolang icon indicating copy to clipboard operation
xerogolang copied to clipboard

Invoices creation example

Open fracasula opened this issue 5 years ago • 1 comments

Hi there,

Can someone provide an example for creating an invoice from a command line program without a callback URL? I'm struggling mostly with the session creation.

I'm looking for something along these lines:

xeroKey := "my xero key"
xeroSecret := "my xero secret"

invoices := accounting.Invoices{
	Invoices: []accounting.Invoice{
		{
			Type:   "ACCREC",
			Status: "DRAFT",
			Contact: accounting.Contact{
				ContactID: "restaurant xero contact id 001",
			},
			LineItems: []accounting.LineItem{
				{
					Description: "first line item",
					Quantity:    1,
					UnitAmount:  2,
					LineAmount:  3,
					TaxType:     "tax type 01",
					AccountCode: "account code 01",
				},
				{
					Description: "second line item",
					Quantity:    4,
					UnitAmount:  5,
					LineAmount:  6,
					TaxType:     "tax type 02",
					AccountCode: "account code 02",
				},
			},
			DueDate: "2019-06-30",
		},
	},
}

// no callback URL here since it's not a server making the call but a cli program
provider := xerogolang.New(xeroKey, xeroSecret, "") 

session := "??? how to get one without the callback?"

res, err := invoices.Create(provider, session)
if err != nil {
    return err
}

fmt.Println(res)

Thanks.

fracasula avatar Jun 27 '19 13:06 fracasula

I was having the same problem. I am not sure this library still works for golang. I believe this one might have superseded it:

https://github.com/quickaco/xerosdk

zaddok avatar Jun 05 '20 05:06 zaddok