invdapi

package module
v0.0.0-...-bb996b3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 12 Imported by: 0

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.11

Version

3.2.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

Overview

Transactions can represent a charge, payment, refund, or adjustment. We record charge and refund transactions for you that happen through Invoiced. The payment transaction type is designated for recording offline payments like checks. Finally, an adjustment transaction represents any additional credit or debits to a customer’s balance. Most transactions will be associated with an invoice, however, not all. For example, if you wanted to credit your customer for $20 you would create an adjustment transaction for -$20 using the customer ID only instead of the invoice ID. We currently support the following payment methods on transactions: credit_card ach bitcoin paypal wire_transfer check cash other

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 MockConnection

func MockConnection(key string, server *httptest.Server) *Connection

func NewConnection

func NewConnection(key string, devMode bool) *Connection

func (*Connection) CancelSubscription

func (c *Connection) CancelSubscription(subscriptionID int64) error

CancelSubscription calls: DELETE /subscriptions/:subscriptionID

func (*Connection) MakeEndPointURL

func (c *Connection) MakeEndPointURL(endPoint string) string

func (*Connection) NewCustomer

func (c *Connection) NewCustomer() *Customer

func (*Connection) NewEvent

func (c *Connection) NewEvent() *Event

func (*Connection) NewFile

func (c *Connection) NewFile() *File

func (*Connection) NewInvoice

func (c *Connection) NewInvoice() *Invoice

func (*Connection) NewSubscription

func (c *Connection) NewSubscription() *Subscription

func (*Connection) NewTransaction

func (c *Connection) NewTransaction() *Transaction

func (*Connection) SetCancelAtPeriodEnd

func (c *Connection) SetCancelAtPeriodEnd(subscriptionID int64, val bool) (*Subscription, error)

SetCancelAtPeriodEnd sets the cancel_at_period_end field for the given subscription ID. This is a convenience function to save having to fetch or construct a whole Subscription object in order to call Subscription.Save() on it.

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) CreateContact

func (c *Customer) CreateContact(contact *invdendpoint.Contact) (*invdendpoint.Contact, error)

func (*Customer) CreatePendingLineItem

func (c *Customer) CreatePendingLineItem(pendingLineItem *invdendpoint.PendingLineItem) (*invdendpoint.PendingLineItem, error)

func (*Customer) Delete

func (c *Customer) Delete() error

func (*Customer) DeleteContact

func (c *Customer) DeleteContact(contactID int64) error

func (*Customer) DeletePendingLineItem

func (c *Customer) DeletePendingLineItem(id int64) error

func (*Customer) GetBalance

func (c *Customer) GetBalance() (*invdendpoint.CustomerBalance, 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) ListAllContacts

func (c *Customer) ListAllContacts() (invdendpoint.Contacts, 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) RetrieveContact

func (c *Customer) RetrieveContact(contactID int64) (*invdendpoint.Contact, error)

func (*Customer) RetrievePendingLineItem

func (c *Customer) RetrievePendingLineItem(id int64) (*invdendpoint.PendingLineItem, error)

func (*Customer) Save

func (c *Customer) Save() error

func (*Customer) SendStatement

func (c *Customer) SendStatement(custStmtReq *invdendpoint.EmailResponse) (*invdendpoint.EmailResponses, error)

func (*Customer) TriggerInvoice

func (c *Customer) TriggerInvoice() (*Invoice, error)

func (*Customer) UpdateContact

func (c *Customer) UpdateContact(contactToUpdate *invdendpoint.Contact) (*invdendpoint.Contact, error)

func (*Customer) UpdatePendingLineItem

func (c *Customer) UpdatePendingLineItem(pendingLineItem *invdendpoint.PendingLineItem) (*invdendpoint.PendingLineItem, error)

type Customers

type Customers []*Customer

type Event

type Event struct {
	*Connection
	*invdendpoint.Event
}

func (*Event) List

func (c *Event) List(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Events, string, error)

func (*Event) ListAll

func (c *Event) ListAll(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Events, error)

type Events

type Events []*Event

type File

type File struct {
	*Connection
	*invdendpoint.File
}

func (*File) Create

func (c *File) Create(file *File) (*File, error)

func (*File) Delete

func (c *File) Delete() error

func (*File) Retrieve

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

type Files

type Files []*File

type Invoice

type Invoice struct {
	*Connection
	*invdendpoint.Invoice
	IncludeUpdatedAt bool
}

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) ListAttachements

func (c *Invoice) ListAttachements() (Files, error)

func (*Invoice) ListInvoiceByNumber

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

func (*Invoice) Pay

func (c *Invoice) Pay() error

func (*Invoice) Retrieve

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

func (*Invoice) Save

func (c *Invoice) Save() error

func (*Invoice) Send

func (*Invoice) String

func (c *Invoice) String() string

type InvoicedToken

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

type Invoices

type Invoices []*Invoice

type Subscription

type Subscription struct {
	*Connection
	*invdendpoint.Subscription
}

func (*Subscription) Cancel

func (c *Subscription) Cancel() error

func (*Subscription) Count

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

func (*Subscription) Create

func (c *Subscription) Create(subscription *Subscription) (*Subscription, 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) 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) ListSuccessfulRefundsByInvoiceID

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

func (*Transaction) Refund

func (c *Transaction) Refund(refund *invdendpoint.Refund) error

func (*Transaction) Retrieve

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

func (*Transaction) Save

func (c *Transaction) Save() error

func (*Transaction) SendReceipt

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