Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Invoices creation example #25

@fracasula

Description

@fracasula

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions