invdapi

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2016 License: MIT Imports: 11 Imported by: 31

README

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

0.8.1

//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)
}

Documentation

Index

Constants

View Source
const InvoicedTokenString = "invoicedToken"

Variables

This section is empty.

Functions

func Version

func Version() string

Types

type APIError

type APIError struct {
	Type    string `json:"type"`
	Message string `json:"message"`
	Param   string `json:"param"`
}

func NewAPIError

func NewAPIError(typeE, message, param string) *APIError

func (*APIError) Error

func (apiErr *APIError) Error() string

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(key string, devMode bool) *Connection

func (*Connection) NewCustomer

func (c *Connection) NewCustomer() *Customer

func (*Connection) NewInvoice

func (c *Connection) NewInvoice() *Invoice

func (*Connection) NewSubscription

func (c *Connection) NewSubscription() *Subscription

func (*Connection) NewTransaction

func (c *Connection) NewTransaction() *Transaction

type Customer

type Customer struct {
	*Connection
	*invdendpoint.Customer
}

func (*Customer) Count

func (c *Customer) Count() (int64, error)

func (*Customer) Create

func (c *Customer) Create(customer *Customer) (*Customer, error)

func (*Customer) Delete

func (c *Customer) Delete() error

func (*Customer) List

func (c *Customer) List(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Customers, string, error)

func (*Customer) ListAll

func (c *Customer) ListAll(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Customers, error)

func (*Customer) ListCustomerByNumber

func (c *Customer) ListCustomerByNumber(customerNumber string) (*Customer, error)

func (*Customer) ListCustomersByName

func (c *Customer) ListCustomersByName(customerName string) (Customers, error)

func (*Customer) Retrieve

func (c *Customer) Retrieve(id int64) (*Customer, error)

func (*Customer) Save

func (c *Customer) Save() error

type Customers

type Customers []*Customer

type Invoice

type Invoice struct {
	*Connection
	*invdendpoint.Invoice
}

func (*Invoice) Count

func (c *Invoice) Count() (int64, error)

func (*Invoice) Create

func (c *Invoice) Create(invoice *Invoice) (*Invoice, error)

func (*Invoice) Delete

func (c *Invoice) Delete() error

func (*Invoice) List

func (c *Invoice) List(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Invoices, string, error)

func (*Invoice) ListAll

func (c *Invoice) ListAll(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Invoices, error)

func (*Invoice) ListInvoiceByNumber

func (c *Invoice) ListInvoiceByNumber(invoiceNumber string) (*Invoice, error)

func (*Invoice) Retrieve

func (c *Invoice) Retrieve(id int64) (*Invoice, error)

func (*Invoice) Save

func (c *Invoice) Save() error

type InvoicedToken

type InvoicedToken struct {
	Key string `json:"invoicedApiKey"`
}

type Invoices

type Invoices []*Invoice

type Subscription

type Subscription struct {
	*Connection
	*invdendpoint.Subscription
}

func (*Subscription) Count

func (c *Subscription) Count() (int64, error)

func (*Subscription) Create

func (c *Subscription) Create(subscription *Subscription) (*Subscription, error)

func (*Subscription) Delete

func (c *Subscription) Delete() error

func (*Subscription) List

func (*Subscription) ListAll

func (c *Subscription) ListAll(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Subscriptions, error)

func (*Subscription) Retrieve

func (c *Subscription) Retrieve(id int64) (*Subscription, error)

func (*Subscription) Save

func (c *Subscription) Save() error

type Subscriptions

type Subscriptions []*Subscription

type Transaction

type Transaction struct {
	*Connection
	*invdendpoint.Transaction
}

func (*Transaction) Count

func (c *Transaction) Count() (int64, error)

func (*Transaction) Create

func (c *Transaction) Create(transaction *Transaction) (*Transaction, error)

func (*Transaction) Delete

func (c *Transaction) Delete() error

func (*Transaction) List

func (*Transaction) ListAll

func (c *Transaction) ListAll(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Transactions, error)

func (*Transaction) ListByNumber

func (c *Transaction) ListByNumber(transactionNumber string) (*Transaction, error)

func (*Transaction) ListSuccessfulByInvoiceID

func (c *Transaction) ListSuccessfulByInvoiceID(invoiceID int64) (Transactions, error)

func (*Transaction) ListSuccessfulChargesAndPaymentsByInvoiceID

func (c *Transaction) ListSuccessfulChargesAndPaymentsByInvoiceID(invoiceID int64) (Transactions, error)

func (*Transaction) ListSuccessfulChargesByInvoiceID

func (c *Transaction) ListSuccessfulChargesByInvoiceID(invoiceID int64) (Transactions, error)

func (*Transaction) ListSuccessfulPaymentsByInvoiceID

func (c *Transaction) ListSuccessfulPaymentsByInvoiceID(invoiceID int64) (Transactions, error)

func (*Transaction) Retrieve

func (c *Transaction) Retrieve(id int64) (*Transaction, error)

func (*Transaction) Save

func (c *Transaction) Save() error

type Transactions

type Transactions []*Transaction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL