harvest

package module
v0.0.0-...-2d2320d Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 14 Imported by: 0

README

harvest - Go bindings for Harvest invoicing

test Go Reference

https://www.getharvest.com/

Installation

go get github.com/rubenv/harvest

Import into your application with:

import "github.com/rubenv/harvest"

Usage

Create an API token on the Developers page of Harvest ID.

Use your account ID and API token to create a client:

client := harvest.New(123456, "my-token")

Check the documentation for available methods.

License

This library is distributed under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithClientID

func WithClientID(id int64) requestOption

Types

type Attachment

type Attachment struct {
	Path     string
	Filename string
	// contains filtered or unexported fields
}

func (*Attachment) Download

func (a *Attachment) Download() (io.ReadCloser, error)

type Client

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

func New

func New(accountID int64, token string) (*Client, error)

func (*Client) CreateExpense

func (hv *Client) CreateExpense(e *CreateExpense) error

func (*Client) CreateInvoice

func (hv *Client) CreateInvoice(invoice *Invoice) error

func (*Client) FetchCustomers

func (hv *Client) FetchCustomers() ([]*Customer, error)

func (*Client) FetchExpenses

func (hv *Client) FetchExpenses() ([]*Expense, error)

func (*Client) FetchInvoices

func (hv *Client) FetchInvoices(opts ...requestOption) ([]*Invoice, error)

func (*Client) GetCompanyInfo

func (hv *Client) GetCompanyInfo() (*Company, error)

func (*Client) GetRecipients

func (hv *Client) GetRecipients(customer int64) ([]*Recipient, error)

type Company

type Company struct {
	BaseURI              string `json:"base_uri"`
	FullDomain           string `json:"full_domain"`
	Name                 string `json:"name"`
	IsActive             bool   `json:"is_active"`
	WeekStartDay         string `json:"week_start_day"`
	WantsTimestampTimers bool   `json:"wants_timestamp_timers"`
	TimeFormat           string `json:"time_format"`
	PlanType             string `json:"plan_type"`
	ExpenseFeature       bool   `json:"expense_feature"`
	InvoiceFeature       bool   `json:"invoice_feature"`
	EstimateFeature      bool   `json:"estimate_feature"`
	ApprovalFeature      bool   `json:"approval_feature"`
	Clock                string `json:"clock"`
	DecimalSymbol        string `json:"decimal_symbol"`
	ThousandsSeparator   string `json:"thousands_separator"`
	ColorScheme          string `json:"color_scheme"`
}

type CreateExpense

type CreateExpense struct {
	ProjectID         int64
	ExpenseCategoryID int64
	SpentDate         string
	TotalCost         float64
	Notes             string

	Filename    string
	ContentType string
	File        io.Reader
}

type Customer

type Customer struct {
	ID   int64  `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	// contains filtered or unexported fields
}

type Expense

type Expense struct {
	ID int64 `json:"id"`

	// An object containing the associated project’s id, name, and code.
	Project *Project `json:"project"`

	SpentDate string  `json:"spent_date"`
	Notes     string  `json:"notes"`
	TotalCost float64 `json:"total_cost"`
	// contains filtered or unexported fields
}

type Invoice

type Invoice struct {
	ID             int64     `json:"id,omitempty"`
	ClientID       int64     `json:"client_id,omitempty"`
	ClientKey      string    `json:"client_key,omitempty"`
	Number         string    `json:"number,omitempty"`
	PurchaseOrder  string    `json:"purchase_order,omitempty"`
	State          string    `json:"state,omitempty"`
	SentAt         time.Time `json:"sent_at,omitempty"`
	PaidAt         time.Time `json:"paid_at,omitempty"`
	ClosedAt       time.Time `json:"closed_at,omitempty"`
	CreatedAt      time.Time `json:"created_at,omitempty"`
	UpdatedAt      time.Time `json:"updated_at,omitempty"`
	Customer       *Customer `json:"client,omitempty"`
	Amount         float64   `json:"amount,omitempty"`
	DueAmount      float64   `json:"due_amount,omitempty"`
	Tax            float64   `json:"tax,omitempty"`
	TaxAmount      float64   `json:"tax_amount,omitempty"`
	Tax2           float64   `json:"tax2,omitempty"`
	Tax2Amount     float64   `json:"tax2_amount,omitempty"`
	Discount       float64   `json:"discount,omitempty"`
	DiscountAmount float64   `json:"discount_amount,omitempty"`
	Subject        string    `json:"subject,omitempty"`
	Notes          string    `json:"notes,omitempty"`
	Currency       string    `json:"currency,omitempty"`

	PeriodStart    string   `json:"period_start,omitempty"`
	PeriodEnd      string   `json:"period_end,omitempty"`
	IssueDate      string   `json:"issue_date,omitempty"`
	DueDate        string   `json:"due_date,omitempty"`
	PaymentTerm    string   `json:"payment_term,omitempty"`
	PaymentOptions []string `json:"payment_options"`
	PaidDate       string   `json:"paid_date,omitempty"`

	LineItems []*LineItem `json:"line_items,omitempty"`
	// contains filtered or unexported fields
}

func (*Invoice) AddPayment

func (i *Invoice) AddPayment(amount float64, date time.Time, notes string) error

func (*Invoice) Download

func (i *Invoice) Download() (io.ReadCloser, error)

func (*Invoice) GetAttachments

func (i *Invoice) GetAttachments() ([]*Attachment, error)

func (*Invoice) MarkSent

func (i *Invoice) MarkSent() error

func (*Invoice) Send

func (i *Invoice) Send(subject, body string, to []*Recipient) error

type LineItem

type LineItem struct {
	// Unique ID for the line item.
	ID int64 `json:"id,omitempty"`

	// An object containing the associated project’s id, name, and code.
	Project *Project `json:"project,omitempty"`

	// The name of an invoice item category.
	Kind string `json:"kind,omitempty"`

	// Text description of the line item.
	Description string `json:"description,omitempty"`

	// The unit quantity of the item.
	Quantity float64 `json:"quantity,omitempty"`

	// The individual price per unit.
	UnitPrice float64 `json:"unit_price,omitempty"`

	// The line item subtotal (quantity * unit_price).
	Amount float64 `json:"amount,omitempty"`

	// Whether the invoice’s tax percentage applies to this line item.
	Taxed bool `json:"taxed,omitempty"`

	// Whether the invoice’s tax2 percentage applies to this line item.
	Taxed2 bool `json:"taxed_2,omitempty"`
}

type Project

type Project struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	Code string `json:"code"`
}

type Recipient

type Recipient struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

Jump to

Keyboard shortcuts

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