Official Go client library for the Invoiced API
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
invdendpoint
invdmockserver
invdutil
.gitignore
.travis.yml
LICENSE
README.md
connector.go
connector_test.go
customer.go
customer_test.go
errors.go
errors_test.go
event.go
file.go
invoice.go
invoice_test.go
mockconnection.go
mockconnection_test.go
subscriptions.go
subscriptions_test.go
transactions.go
transactions_test.go

README.md

invdapi

Build Status Coverage Status

This repository contains the Go client library for the Invoiced API.

##API Documentation The API Documenation is good to look at, as it list fields which can used for creating versus updating objects. The Go Client Library uses all of the endpoint object's fields. The server will simply return an error if you try to use a field that should not be used during a create or update call.

Installing

The Invoiced Go Client can be installed liked this:

go get -u https://github.com/Invoiced/invoiced-go

Requirements

  • = Go 1.4

Version

3.0.0

//Will print out the version.
invd.Version()

Usage

package main

import "github.com/Invoiced/invoiced-go"
import "github.com/Invoiced/invoiced-go/invdendpoint"
import "fmt"

func main() {

    key := "YOUR DEVELOPER KEY"

    conn := invdapi.NewConnection(key, true)

    //Get All The Invoices With Auto Pagination
    invoiceConn := conn.NewInvoice()
    invoices, err := invoiceConn.ListAll(nil, nil)

    if err != nil {
        panic(err)
    }

    //Let's print all the invoices
    for _, invoice := range invoices {
        fmt.Println(invoice)
    }

    //Let's create a new customer
    customerConn := conn.NewCustomer()

    customerToCreate := conn.NewCustomer()
    customerToCreate.Name = "Test Customer"

    customerResponse, err := customerConn.Create(customerToCreate)

    if err != nil {
        panic(err)
    }

    fmt.Println("Customer Response => ", customerResponse.Customer)

    //Let's create a new invoice
    invoiceToCreate := conn.NewInvoice()
    invoiceToCreate.Customer = customerResponse.Id

    //Create a Line Item
    lineItem := invdendpoint.LineItem{}
    lineItem.Description = "Retina MacBook Pro"
    lineItem.Quantity = 5
    lineItem.UnitCost = 1999.22

    lineItems := append([]invdendpoint.LineItem{}, lineItem)

    invoiceToCreate.Items = lineItems

    //Add a Payment Term
    invoiceToCreate.PaymentTerms = "NET15"

    invoiceResponse, err := invoiceConn.Create(invoiceToCreate)

    if err != nil {
        panic(err)
    }

    fmt.Println("Invoice Response => ", invoiceResponse.Invoice)
}