moneybird

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: MIT Imports: 8 Imported by: 0

README

Moneybird Go

GoDoc Build Status Coverage Status

An unofficial Go client library for Moneybird. This package is still experimental and could be subject to heavy change.

Usage

import (
  "net/http"
  "github.com/dannyvankooten/moneybird-go"
)

mb := &moneybird.Client{
  Token: "token",
  AdministrationID: "administration-id-here",
  HTTPClient: &http.Client{},
}

contact, _ := mb.Contact().Create(&moneybird.Contact{
  Email: "john@doe.com",
  FirstName: "John",
  LastName: "Doe",
})

See the integration tests for some more working examples.

Testing

In order to run the integration tests, you have to configure a sandbox account in Moneybird. Before running the integration tests with go test, make sure the following environment variables are set.

export MONEYBIRD_TEST_TOKEN="your-sandbox-token"
export MONEYBIRD_TEST_ADMINISTRATION_ID="your-sandbox-administration-id"

License

MIT Licensed. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Response *Response
	Data     map[string]interface{}
}

APIError holds data for a MoneyBird API error

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	Token            string
	AdministrationID string

	Logger     *log.Logger
	HTTPClient *http.Client
}

Client is the MoneyBird API consumer

func (*Client) Contact

func (c *Client) Contact() *ContactGateway

Contact returns a new gateway instance

func (*Client) Invoice

func (c *Client) Invoice() *InvoiceGateway

Invoice returns a new InvoiceGateway instance

func (*Client) InvoiceNote

func (c *Client) InvoiceNote() *InvoiceNoteGateway

InvoiceNote returns a new gateway instance

func (*Client) InvoicePayment

func (c *Client) InvoicePayment() *InvoicePaymentGateway

InvoicePayment returns a new gateway instance

func (*Client) InvoiceSending

func (c *Client) InvoiceSending() *InvoiceSendingGateway

InvoiceSending returns a new gateway instance

func (*Client) LedgerAccount

func (c *Client) LedgerAccount() *LedgerAccountGateway

LedgerAccount returns a new gateway instance

func (*Client) TaxRate

func (c *Client) TaxRate() *TaxRateGateway

TaxRate returns a TaxRateGateway instance

func (*Client) Webhook

func (c *Client) Webhook() *WebhookGateway

Webhook returns a new gateway instance

func (*Client) Workflow

func (c *Client) Workflow() *WorkflowGateway

Workflow returns a WorkflowGateway instance

type Contact

type Contact struct {
	ID                       string `json:"id,omitempty"`
	AdministrationID         string `json:"administration_id,omitempty"`
	CompanyName              string `json:"company_name,omitempty"`
	FirstName                string `json:"firstname,omitempty"`
	LastName                 string `json:"lastname,omitempty"`
	Address1                 string `json:"address1,omitempty"`
	Address2                 string `json:"address2,omitempty"`
	ZipCode                  string `json:"zipcode,omitempty"`
	City                     string `json:"city,omitempty"`
	Country                  string `json:"country,omitempty"`
	Phone                    string `json:"phone,omitempty"`
	DeliveryMethod           string `json:"delivery_method,omitempty"`
	CustomerID               string `json:"customer_id,omitempty"`
	TaxNumber                string `json:"tax_number,omitempty"`
	ChamberOfCommerce        string `json:"chamber_of_commerce,omitempty"`
	BankAccount              string `json:"bank_account,omitempty"`
	Attention                string `json:"attention,omitempty"`
	Email                    string `json:"email"`
	EmailUBL                 bool   `json:"email_ubl,omitempty"`
	SendInvoicesToAttention  string `json:"send_invoices_to_attention,omitempty"`
	SendInvoicesToEmail      string `json:"send_invoices_to_email,omitempty"`
	SendEstimatesToAttention string `json:"send_estimates_to_attention,omitempty"`
	SendEstimatesToEmail     string `json:"send_estimates_to_email,omitempty"`
	SEPAActive               bool   `json:"sepa_active,omitempty"`
	SEPAIBAN                 string `json:"sepa_iban,omitempty"`
	SEPAIBANAccountName      string `json:"sepa_iban_account_name,omitempty"`
	SEPABIC                  string `json:"sepa_bic,omitempty"`
	SEPAMandateID            string `json:"sepa_mandate_id,omitempty"`
	SEPAMandateDate          string `json:"sepa_mandate_date,omitempty"`
	SEPASequenceType         string `json:"sepa_sequence_type,omitempty"`
	CreditCardNumber         string `json:"credit_card_number,omitempty"`
	CreditCardReference      string `json:"credit_card_reference,omitempty"`
	CreditCardType           string `json:"credit_card_type,omitempty"`
	TaxNumberValidatedAt     string `json:"tax_number_validated_at,omitempty"`
	CreatedAt                string `json:"created_at,omitempty"`
	UpdatedAt                string `json:"updated_at,omitempty"`
	SalesInvoicesURL         string `json:"sales_invoices_url,omitempty"`
}

Contact is a MoneyBird contact

type ContactGateway

type ContactGateway struct {
	*Client
}

ContactGateway encapsulates all /contacts related endpoints

func (*ContactGateway) Create

func (c *ContactGateway) Create(contact *Contact) (*Contact, error)

Create adds a contact to MoneyBird

func (*ContactGateway) Delete

func (c *ContactGateway) Delete(contact *Contact) error

Delete the given contact

func (*ContactGateway) Get

func (c *ContactGateway) Get(ID string) (*Contact, error)

Get returns the contact with the specified id, or nil

func (*ContactGateway) List

func (c *ContactGateway) List() ([]*Contact, error)

List returns all contacts in Moneybird

func (*ContactGateway) Update

func (c *ContactGateway) Update(contact *Contact) (*Contact, error)

Update updates an existing contact in Moneybird

type Invoice

type Invoice struct {
	ID                string            `json:"id,omitempty"`
	AdministrationID  string            `json:"administration_id,omitempty"`
	InvoiceID         string            `json:"invoice_id,omitempty"`
	Contact           Contact           `json:"contact,omitempty"`
	ContactID         string            `json:"contact_id,omitempty"`
	UpdateContact     bool              `json:"update_contact,omitempty"`
	WorkflowID        string            `json:"workflow_id,omitempty"`
	DocumentStyleID   string            `json:"document_style_id,omitempty"`
	IdentityID        string            `json:"identity_id,omitempty"`
	State             string            `json:"state,omitempty"`
	InvoiceDate       string            `json:"invoice_date,omitempty"`
	DueDate           string            `json:"due_date,omitempty"`
	PaymentConditions string            `json:"payment_conditions,omitempty"`
	Reference         string            `json:"reference,omitempty"`
	Language          string            `json:"language,omitempty"`
	Currency          string            `json:"currency,omitempty"`
	Discount          string            `json:"discount,omitempty"`
	PaidAt            string            `json:"paid_at,omitempty"`
	SentAt            string            `json:"sent_at,omitempty"`
	CreatedAt         string            `json:"created_at,omitempty"`
	UpdatedAt         string            `json:"updated_at,omitempty"`
	Details           []*InvoiceDetails `json:"details_attributes,omitempty"`
	TotalPaid         string            `json:"total_paid,omitempty"`
	TotalUnpaid       string            `json:"total_unpaid,omitempty"`
	TotalUnpaidBase   string            `json:"total_unpaid_base,omitempty"`
	PricesAreInclTax  bool              `json:"prices_are_incl_tax,omitempty"`
	TotalPriceExclTax string            `json:"total_price_excl_tax,omitempty"`
	TotalPriceInclTax string            `json:"total_price_incl_tax,omitempty"`
	URL               string            `json:"url,omitempty"`
	Notes             []*InvoiceNote    `json:"notes,omitempty"`
	Payments          []*InvoicePayment `json:"payments,omitempty"`
}

Invoice contains all invoice details

type InvoiceDetails

type InvoiceDetails struct {
	ID              string `json:"id,omitempty"`
	Description     string `json:"description"`
	Price           string `json:"price"`
	Period          string `json:"period,omitempty"`
	Amount          string `json:"amount,omitempty"`
	TaxRateID       string `json:"tax_rate_id,omitempty"`
	LedgerAccountID string `json:"ledger_account_id,omitempty"`
	Destroy         bool   `json:"_destroy,omitempty"`
}

InvoiceDetails is a line on an invoice

type InvoiceGateway

type InvoiceGateway struct {
	*Client
}

InvoiceGateway encapsulates all /sales_invoices related endpoints

func (*InvoiceGateway) Create

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

Create creates the invoice in Moneybird

func (*InvoiceGateway) Delete

func (c *InvoiceGateway) Delete(invoice *Invoice) error

Delete deletes the invoice in Moneybird

func (*InvoiceGateway) Get

func (c *InvoiceGateway) Get(ID string) (*Invoice, error)

Get returns the invoice with the specified id, or nil

func (*InvoiceGateway) List

func (c *InvoiceGateway) List() ([]*Invoice, error)

List returns all invoices

func (*InvoiceGateway) Update

func (c *InvoiceGateway) Update(invoice *Invoice) (*Invoice, error)

Update updates the invoice in Moneybird

type InvoiceNote

type InvoiceNote struct {
	ID               string `json:"id,omitempty"`
	AdministrationID string `json:"administration_id,omitempty"`
	Note             string `json:"note"`
	Todo             bool   `json:"todo,omitempty"`
	AssigneeID       int    `json:"assignee_id,omitempty"`
	CreatedAt        string `json:"created_at,omitempty"`
	UpdatedAt        string `json:"updated_at,omitempty"`
}

InvoiceNote is a note for an invoice

type InvoiceNoteGateway

type InvoiceNoteGateway struct {
	*Client
}

InvoiceNoteGateway encapsulates all /invoices related endpoints

func (*InvoiceNoteGateway) Create

func (c *InvoiceNoteGateway) Create(invoice *Invoice, note *InvoiceNote) (*InvoiceNote, error)

Create adds a note to an existing invoice

func (*InvoiceNoteGateway) Delete

func (c *InvoiceNoteGateway) Delete(invoice *Invoice, note *InvoiceNote) error

Delete destroys the invoice note

type InvoicePayment

type InvoicePayment struct {
	ID                  string `json:"id,omitempty"`
	PaymentDate         string `json:"payment_date"`
	Price               string `json:"price"`
	PriceBase           string `json:"price_base,omitempty"`
	FinancialAccountID  int64  `json:"financial_account_id,omitempty"`
	FinancialMutationID int64  `json:"financial_mutation_id,omitempty"`
}

InvoicePayment contains info on how the invoice is paid

type InvoicePaymentGateway

type InvoicePaymentGateway struct {
	*Client
}

InvoicePaymentGateway encapsulates all /invoices related endpoints

func (*InvoicePaymentGateway) Create

func (c *InvoicePaymentGateway) Create(invoice *Invoice, payment *InvoicePayment) error

Create marks the invoice as paid in Moneybird

func (*InvoicePaymentGateway) Delete

func (c *InvoicePaymentGateway) Delete(invoice *Invoice, payment *InvoicePayment) error

Delete payment of invoice in Moneybird

type InvoiceSending

type InvoiceSending struct {
	DeliveryMethod   string `json:"delivery_method"`
	EmailAddress     string `json:"email_address,omitempty"`
	EmailMessage     string `json:"email_message,omitempty"`
	SendingScheduled bool   `json:"sending_scheduled,omitempty"`
	DeliverUBL       bool   `json:"deliver_ubl,omitempty"`
	Mergeable        bool   `json:"mergeable,omitempty"`
	InvoiceDate      string `json:"invoice_date,omitempty"`
}

InvoiceSending contains info on how the invoice is sent

type InvoiceSendingGateway

type InvoiceSendingGateway struct {
	*Client
}

InvoiceSendingGateway encapsulates all /invoices related endpoints

func (*InvoiceSendingGateway) Create

func (c *InvoiceSendingGateway) Create(invoice *Invoice, sending *InvoiceSending) error

Create marks the invoice as sent in Moneybird

type LedgerAccount

type LedgerAccount struct {
	ID               string `json:"id,omitempty"`
	AdministrationID string `json:"administration_id,omitempty"`
	Name             string `json:"name"`
	AccountType      string `json:"account_type"`
	AccountID        string `json:"account_id,omitempty"`
	ParentID         string `json:"parent_id,omitempty"`
	CreatedAt        string `json:"created_at,omitempty"`
	UpdatedAt        string `json:"updated_at,omitempty"`
}

LedgerAccount represents a ledger account in Moneybird

type LedgerAccountGateway

type LedgerAccountGateway struct {
	*Client
}

LedgerAccountGateway encapsulates all /ledger_accounts related endpoints

func (*LedgerAccountGateway) Create

func (c *LedgerAccountGateway) Create(ledgerAccount *LedgerAccount) (*LedgerAccount, error)

Create adds a ledger account to MoneyBird

func (*LedgerAccountGateway) Delete

func (c *LedgerAccountGateway) Delete(ledgerAccount *LedgerAccount) error

Delete the given ledger account

func (*LedgerAccountGateway) Get

Get returns the ledger account with the specified id, or nil

func (*LedgerAccountGateway) List

func (c *LedgerAccountGateway) List() ([]*LedgerAccount, error)

List returns all ledger accounts in Moneybird

func (*LedgerAccountGateway) Update

func (c *LedgerAccountGateway) Update(ledgerAccount *LedgerAccount) (*LedgerAccount, error)

Update updates an existing ledger account in Moneybird

type Response

type Response struct {
	*http.Response
}

Response wraps a Moneybird API response

type TaxRate

type TaxRate struct {
	ID               string `json:"id"`
	AdministrationID string `json:"administration_id,omitempty"`
	Name             string `json:"name"`
	Percentage       string `json:"percentage"`
	TaxRateType      string `json:"tax_rate_type"`
	ShowTax          bool   `json:"show_tax"`
	Active           bool   `json:"active"`
	CreatedAt        string `json:"created_at,omitempty"`
	UpdatedAt        string `json:"updated_at,omitempty"`
}

TaxRate contains info about a tax rate stored in Moneybird

type TaxRateGateway

type TaxRateGateway struct {
	*Client
}

TaxRateGateway encapsulates all /tax_rates related endpoints

func (*TaxRateGateway) List

func (c *TaxRateGateway) List() ([]*TaxRate, error)

List returns all tax rates stored in Moneybird

type Webhook

type Webhook struct {
	ID               string `json:"id,omitempty"`
	AdministrationID string `json:"administration_id,omitempty"`
	URL              string `json:"url"`
	LastHTTPStatus   string `json:"last_http_status,omitempty"`
	LastHTTPBody     string `json:"last_http_body,omitempty"`
}

Webhook is a MoneyBird webhook

type WebhookGateway

type WebhookGateway struct {
	*Client
}

WebhookGateway encapsulates all /webhooks related endpoints

func (*WebhookGateway) Create

func (c *WebhookGateway) Create(webhook *Webhook) (*Webhook, error)

Create adds a webhook to MoneyBird

func (*WebhookGateway) Delete

func (c *WebhookGateway) Delete(webhook *Webhook) error

Delete the given webhook

func (*WebhookGateway) List

func (c *WebhookGateway) List() ([]*Webhook, error)

List returns all webhooks in Moneybird

type Workflow

type Workflow struct {
	ID               string    `json:"id"`
	AdministrationID string    `json:"administration_id,omitempty"`
	Type             string    `json:"type,omitempty"`
	Name             string    `json:"name,omitempty"`
	Default          bool      `json:"default,omitempty"`
	Currency         string    `json:"currency,omitempty"`
	Language         string    `json:"language,omitempty"`
	Active           bool      `json:"active,omitempty"`
	PricesAreInclTax bool      `json:"prices_are_incl_tax,omitempty"`
	CreatedAt        time.Time `json:"created_at,omitempty"`
	UpdatedAt        time.Time `json:"updated_at,omitempty"`
}

Workflow contains info about a tax rate stored in Moneybird

type WorkflowGateway

type WorkflowGateway struct {
	*Client
}

WorkflowGateway encapsulates all /tax_rates related endpoints

func (*WorkflowGateway) List

func (c *WorkflowGateway) List() ([]*Workflow, error)

List returns all workflows stored in Moneybird

Jump to

Keyboard shortcuts

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