Help us shape the future of Go! Take the 2026 Go Developer Survey

zohobooks

package module
v0.0.0-...-850e881 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 11 Imported by: 0

README

zohobooks-go

GO lang SDK for zohobooks

Documentation

Index

Constants

View Source
const BaseURL = "https://www.zohoapis.com/books/v3"

BaseURL stores the API base URL

View Source
const BaseURLAU = "https://www.zohoapis.com.au/books/v3"
View Source
const BaseURLEU = "https://www.zohoapis.eu/books/v3"
View Source
const BaseURLIN = "https://www.zohoapis.in/books/v3"
View Source
const BaseURLUS = "https://www.zohoapis.com/books/v3"
View Source
const InvStatusCancelled = "cancelled"
View Source
const InvStatusPushed = "pushed"
View Source
const InvStatusYTP = "yet_to_be_pushed"
View Source
const OAuthURL = "https://accounts.zoho.com/oauth/v2/token"
View Source
const OAuthURLAu = "https://accounts.zoho.com.au/oauth/v2/token"
View Source
const OAuthURLEu = "https://accounts.zoho.eu/oauth/v2/token"
View Source
const OAuthURLIn = "https://accounts.zoho.in/oauth/v2/token"
View Source
const TaxIGST = "IGST"

TaxIGST name of tax type

View Source
const TaxIGST0 = "IGST0"

TaxIGST0 name of tax type

View Source
const TaxIGST18 = "IGST18"

TaxIGST18 name of the tax

View Source
const TransactionTypeTransfer = "transfer_fund"

TransactionTypeTransfer constant is a bank transaction type of "transfer_fund"

Variables

This section is empty.

Functions

This section is empty.

Types

type BAddrInvoiceParams

type BAddrInvoiceParams struct {
	Address string `json:"address,omitempty"`
	City    string `json:"city,omitempty"`
	State   string `json:"state,omitempty"`
	Zip     string `json:"zip,omitempty"`
	Country string `json:"country,omitempty"`
}

Billing Address Params for Invoice

type BankAccount

type BankAccount struct {
	ID       string `json:"account_id"`
	Name     string `json:"account_name"`
	Type     string `json:"account_type"`
	IsActive bool   `json:"is_active"`
	BankName string `json:"bank_name"`
}

BankAccount struct will contain all the information of bank

func (*BankAccount) Endpoint

func (ba *BankAccount) Endpoint() string

Endpoint method returns the endpoint of the resource

func (*BankAccount) FindAll

func (ba *BankAccount) FindAll(opts *BankAccountFindOptions, client *Client) ([]BankAccount, error)

FindAll tries to find the contacts with given options

func (*BankAccount) New

func (ba *BankAccount) New() Resource

New method will create an object and return a pointer to it

type BankAccountFindOptions

type BankAccountFindOptions struct {
	FilterBy, SortColumn string
}

type BankTransaction

type BankTransaction struct {
	ID          string  `json:"transaction_id"`
	FromAccID   string  `json:"from_account_id"`
	FromAccName string  `json:"from_account_name"`
	ToAccID     string  `json:"to_account_id"`
	ToAccName   string  `json:"to_account_name"`
	Type        string  `json:"transaction_type"`
	Amount      float64 `json:"amount"`
	PaymentMode string  `json:"payment_mode"`
	Date        string  `json:"date"`
	RefNO       string  `json:"reference_number"`
	Description string  `json:"description"`
}

BankTransaction struct will contain all the information of bank

func (*BankTransaction) Create

func (bt *BankTransaction) Create(params *BankTransactionParams, client *Client) (*BankTransaction, error)

Create method will try to create a bank transaction on zohobooks

func (*BankTransaction) Endpoint

func (bt *BankTransaction) Endpoint() string

Endpoint method returns the endpoint of the resource

func (*BankTransaction) New

func (bt *BankTransaction) New() Resource

New method will create an object and return a pointer to it

type BankTransactionParams

type BankTransactionParams struct {
	FromAccID   string  `json:"from_account_id"`
	ToAccID     string  `json:"to_account_id"`
	Type        string  `json:"transaction_type"`
	Amount      float64 `json:"amount"`
	PaymentMode string  `json:"payment_mode"`
	Date        string  `json:"date"`
	RefNO       string  `json:"reference_number"`
	Description string  `json:"description"`
}

BankTransactionParams struct contains the params used to create a bank transaction on zohobooks

type BillingAddress

type BillingAddress struct {
	Attention string `json:"attention"`
	Address   string `json:"address"`
	Street2   string `json:"street2"`
	StateCode string `json:"state_code"`
	City      string `json:"city"`
	State     string `json:"state"`
	Zip       string `json:"zip"`
	Country   string `json:"country"`
	Fax       string `json:"fax"`
	Phone     string `json:"phone"`
}

type Client

type Client struct {
	Key        string
	OAuthToken string

	OrgID      string
	Datacenter string
	// contains filtered or unexported fields
}

Client struct

func NewClient

func NewClient(key, orgID, datacenter string) *Client

NewClient returns a pointer to the zohobooks client

func NewClientWithConfig

func NewClientWithConfig(conf *ClientConfig) *Client

NewClientWithTimeout returns a pointer to the zohobooks client

func NewClientWithTimeout

func NewClientWithTimeout(key, orgID, datacenter string, timeout int) *Client

NewClientWithTimeout returns a pointer to the zohobooks client

func (*Client) Delete

func (c *Client) Delete(path string) (*http.Response, error)

Delete method makes a DELETE request to the resource

func (*Client) GenAccessToken

func (c *Client) GenAccessToken() (string, error)

func (*Client) Get

func (c *Client) Get(path string) (*http.Response, error)

Get method makes a GET request to the resource

func (*Client) GetBaseURL

func (c *Client) GetBaseURL() string

GetBaseURL will return the base URL for zohobooks based on the specified datacenter while initializing the client

func (*Client) GetOauthURL

func (c *Client) GetOauthURL() string

func (*Client) Post

func (c *Client) Post(path string, body string) (*http.Response, error)

Post method makes a POST and sends data in json format

func (*Client) Put

func (c *Client) Put(path string, body string) (*http.Response, error)

Put method makes a PUT and sends data in json format

type ClientConfig

type ClientConfig struct {
	ClientID     string
	ClientSecret string
	RedirectURI  string
	OAuthToken   string
	RefreshToken string
	Datacenter   string
	OrgID        string
	Timeout      int
}

type Contact

type Contact struct {
	ID           string `json:"contact_id"`
	Name         string `json:"contact_name"`
	Company      string `json:"company_name"`
	Website      string `json:"website"`
	LanguageCode string `json:"language_code"`
	ContactType  string `json:"contact_type"`
	Notes        string `json:"notes"`
	CurrencyID   string `json:"currency_id"`

	ContactPersons  []ContactPerson `json:"contact_persons"`
	BillingAddress  BillingAddress  `json:"billing_address"`
	ShippingAddress BillingAddress  `json:"shipping_address"`

	// possible values ---> vat_registered,vat_not_registered,gcc_vat_not_registered,gcc_vat_registered,non_gcc,dz_vat_registered and dz_vat_not_registered.
	TaxTreatment string `json:"tax_treatment"`
	GstNO        string `json:"gst_no"`        // 15 digit
	GstTreatment string `json:"gst_treatment"` // Allowed values are business_gst , business_none , overseas , consumer
	TaxID        string `json:"tax_id"`
	CreatedTime  string `json:"created_time"`

	LastModifiedTime string `json:"last_modified_time"`

	Status    string `json:"status"`
	CC        string `json:"country_code"`
	POC       string `json:"place_of_contact"` // should be same as billing state
	TaxName   string `json:"tax_name"`         // IGST0
	LegalName string `json:"legal_name"`
	Country   string `json:"country"`
}

Contact struct represents the information of the contact

func (*Contact) Create

func (c *Contact) Create(params *ContactParams, client *Client) (*Contact, error)

Create method will try to create a contact on razorpay

func (*Contact) Delete

func (c *Contact) Delete(id string, client *Client) error

Delete tries to delete the contact with given id

func (*Contact) Endpoint

func (c *Contact) Endpoint() string

Endpoint method returns the endpoint of the resource

func (*Contact) FindAll

func (c *Contact) FindAll(opts *ContactFindOptions, client *Client) ([]Contact, error)

FindAll tries to find the contacts with given options

func (*Contact) FindOne

func (c *Contact) FindOne(id string, client *Client) (*Contact, error)

FindOne tries to find the contact with given id

func (*Contact) New

func (c *Contact) New() Resource

New method will create a contact object and return a pointer to it

func (*Contact) Update

func (c *Contact) Update(id string, params *ContactParams, client *Client) (*Contact, error)

Update method will try to update a invoice on razorpay

type ContactFindOptions

type ContactFindOptions struct {
	EmailContains string
}

type ContactParams

type ContactParams struct {
	Name         string `json:"contact_name"`
	Company      string `json:"company_name,omitempty"`
	Website      string `json:"website,omitempty"`
	LanguageCode string `json:"language_code,omitempty"`
	ContactType  string `json:"contact_type,omitempty"`
	Notes        string `json:"notes,omitempty"`
	CurrencyID   string `json:"currency_id"`
	OwnerID      string `json:"owner_id"`

	ContactPersons  []ContactPerson `json:"contact_persons,omitempty"`
	BillingAddress  BillingAddress  `json:"billing_address,omitempty"`
	ShippingAddress BillingAddress  `json:"shipping_address,omitempty"`

	// possible values ---> vat_registered,vat_not_registered,gcc_vat_not_registered,gcc_vat_registered,non_gcc,dz_vat_registered and dz_vat_not_registered.
	TaxTreatment string `json:"tax_treatment,omitempty"`
	GstNO        string `json:"gst_no,omitempty"`        // 15 digit
	GstTreatment string `json:"gst_treatment,omitempty"` // Allowed values are business_gst , business_none , overseas , consumer
	TaxID        string `json:"tax_id,omitempty"`

	Status        string  `json:"status,omitempty"`
	TaxPercentage float64 `json:"tax_percentage,omitempty"`
	CC            string  `json:"country_code,omitempty"`
	POC           string  `json:"place_of_contact,omitempty"` // should be same as billing state
	TaxName       string  `json:"tax_name,omitempty"`         // IGST0
	LegalName     string  `json:"legal_name,omitempty"`
	Country       string  `json:"country,omitempty"`
}

ContactParams struct represents the information to create a contact

type ContactPerson

type ContactPerson struct {
	ID        string `json:"contact_person_id,omitempty"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
	Phone     string `json:"phone,omitempty"`
	Skype     string `json:"skype,omitempty"`
	IsPrimary bool   `json:"is_primary"`
}

type Currency

type Currency struct {
	ID             string  `json:"currency_id"`
	Code           string  `json:"currency_code"`
	Name           string  `json:"currency_name"`
	Symbol         string  `json:"currency_symbol"`
	PricePrecision int     `json:"price_precision"`
	IsBaseCurrency bool    `json:"is_base_currency"`
	ExchangeRate   float64 `json:"exchange_rate"`
	EffectiveDate  string  `json:"effective_date"`
}

Currency struct represents the information of the currency

func (*Currency) Endpoint

func (c *Currency) Endpoint() string

Endpoint method returns the endpoint of the resource

func (*Currency) FindAll

func (c *Currency) FindAll(client *Client) ([]Currency, error)

FindAll will return the list of currencies present in zohobooks org

func (*Currency) New

func (c *Currency) New() Resource

New method will create a contact object and return a pointer to it

type EInvDetails

type EInvDetails struct {
	InvRefNo     string `json:"inv_ref_num"`
	AckNo        string `json:"ack_number"`
	Status       string `json:"status"`
	FormatStatus string `json:"formatted_status"`
	AckDate      string `json:"ack_date"`
}

type Invoice

type Invoice struct {
	ID             string   `json:"invoice_id"`
	CustomerID     string   `json:"customer_id"`
	CustomerName   string   `json:"customer_name"`
	ContactPersons []string `json:"contact_persons"`
	InvoiceNumber  string   `json:"invoice_number"`
	PlaceOfSupply  string   `json:"place_of_supply"`

	// possible values ---> vat_registered,vat_not_registered,gcc_vat_not_registered,gcc_vat_registered,non_gcc,dz_vat_registered and dz_vat_not_registered.
	TaxTreatment string `json:"tax_treatment"`
	GstNO        string `json:"gst_no"`        // 15 digit
	GstTreatment string `json:"gst_treatment"` // Allowed values are business_gst , business_none , overseas , consumer

	Status            string     `json:"status"`
	Date              string     `json:"date"`
	PaymentTerms      int        `json:"payment_terms"`
	PaymentTermsLabel string     `json:"payment_terms_label"`
	DueDate           string     `json:"due_date"`
	CurrencyCode      string     `json:"currency_code"`
	CurrencyID        string     `json:"currency_id"`
	Discount          float64    `json:"discount"`
	TaxID             string     `json:"tax_id"`
	RefNo             string     `json:"reference_number"`
	LineItems         []LineItem `json:"line_items"`
	Notes             string     `json:"notes"`
	Terms             string     `json:"terms"`
	BranchID          string     `json:"branch_id"`
	BranchName        string     `json:"branch_name"`

	SubTotal float64   `json:"sub_total"`
	TaxTotal float64   `json:"tax_total"`
	Total    float64   `json:"total"`
	Taxes    []taxInfo `json:"taxes"`

	PaymentReminder   bool    `json:"payment_reminder_enabled"`
	PaymentMade       float64 `json:"payment_made"`
	CreditsApplied    float64 `json:"credits_applied"`
	TaxAmountWithheld float64 `json:"tax_amount_withheld"`
	Balance           float64 `json:"balance"`
	WriteOffAmount    float64 `json:"write_off_amount"`
	CreatedTime       string  `json:"created_time"`
	LastModifiedTime  string  `json:"last_modified_time"`
	InvoiceURL        string  `json:"invoice_url"`

	Country     string      `json:"country"`
	EInvDetails EInvDetails `json:"einvoice_details"`

	BillingAddress  BillingAddress `json:"billing_address"`
	ShippingAddress BillingAddress `json:"shipping_address"`
}

Invoice struct represents the information of the invoice

func (*Invoice) Create

func (i *Invoice) Create(params *InvoiceParams, client *Client) (*Invoice, error)

Create method will try to create a invoice on razorpay

func (*Invoice) DownloadPDF

func (i *Invoice) DownloadPDF(id, filepath string, client *Client) error

DownloadPDF method will download the pdf to the given filepath

func (*Invoice) Email

func (i *Invoice) Email(id string, params *InvoiceEmailParams, client *Client)

Email method will send the invoice to the customer

func (*Invoice) Endpoint

func (i *Invoice) Endpoint() string

Endpoint method returns the endpoint of the resource

func (*Invoice) FindOne

func (i *Invoice) FindOne(id string, client *Client) (*Invoice, error)

FindOne tries to find the invoice with given id

func (*Invoice) New

func (i *Invoice) New() Resource

New method will create a invoice object and return a pointer to it

func (*Invoice) PushInvoiceToIRP

func (i *Invoice) PushInvoiceToIRP(id string, client *Client) (*Invoice, error)

push Invoice to IRP portal and returns the Invoice with IRP Ack Num and Ref Num

func (*Invoice) Update

func (i *Invoice) Update(id string, params *InvoiceParams, client *Client) (*Invoice, error)

Update method will try to update a invoice on razorpay

func (*Invoice) UpdateInvBillingAddress

func (i *Invoice) UpdateInvBillingAddress(id string, billingAddress *BAddrInvoiceParams, client *Client) (*Invoice, error)

update invoice billing address

type InvoiceEmailParams

type InvoiceEmailParams struct {
	SendFromOrgEmail bool     `json:"send_from_org_email_id"`
	ToMailIDs        []string `json:"to_mail_ids"`
	CCMailIDs        []string `json:"cc_mail_ids,omitempty"`
	Subject          string   `json:"subject,omitempty"`
	Body             string   `json:"body,omitempty"`
}

InvoiceEmailParams struct contains the parameters to be used while sending invoices

type InvoiceInfo

type InvoiceInfo struct {
	InvoiceID         string  `json:"invoice_id"`
	Number            string  `json:"invoice_number,omitempty"`
	Date              string  `json:"date,omitempty"`
	Amount            float64 `json:"invoice_amount,omitempty"`
	AmountApplied     float64 `json:"amount_applied"`
	BalanceAmount     float64 `json:"balance_amount,omitempty"`
	TaxAmountWithheld float64 `json:"tax_amount_withheld,omitempty"`
}

type InvoiceParams

type InvoiceParams struct {
	CustomerID     string   `json:"customer_id"`
	ContactPersons []string `json:"contact_persons,omitempty"`
	InvoiceNumber  string   `json:"invoice_number,omitempty"`
	ReferenceNo    string   `json:"reference_number,omitempty"`
	PlaceOfSupply  string   `json:"place_of_supply,omitempty"`

	// possible values ---> vat_registered,vat_not_registered,gcc_vat_not_registered,gcc_vat_registered,non_gcc,dz_vat_registered and dz_vat_not_registered.
	TaxTreatment string `json:"tax_treatment,omitempty"`
	GstNO        string `json:"gst_no,omitempty"`        // 15 digit
	GstTreatment string `json:"gst_treatment,omitempty"` // Allowed values are business_gst , business_none , overseas , consumer

	Date              string     `json:"date,omitempty"`
	PaymentTerms      int        `json:"payment_terms,omitempty"`
	PaymentTermsLabel string     `json:"payment_terms_label,omitempty"`
	DueDate           string     `json:"due_date,omitempty"`
	IsInclusiveTax    bool       `json:"is_inclusive_tax"`
	Discount          float64    `json:"discount,omitempty"`
	TaxID             string     `json:"tax_id,omitempty"`
	Reason            string     `json:"reason,omitempty"` // required when updating sent invoice
	LineItems         []LineItem `json:"line_items"`
	Notes             string     `json:"notes,omitempty"`
	Terms             string     `json:"terms,omitempty"`
	BranchID          string     `json:"branch_id,omitempty"`

	Country string `json:"country"`
}

InvoiceParams struct represents the information to create a invoice

type LineItem

type LineItem struct {
	ItemID      string  `json:"item_id,omitempty"`
	ProjectID   string  `json:"project_id,omitempty"`
	ProductType string  `json:"product_type,omitempty"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Rate        float64 `json:"rate"`
	Quantity    float64 `json:"quantity"`
	Unit        string  `json:"unit,omitempty"`
	TaxID       string  `json:"tax_id,omitempty"`
	HsnOrSac    string  `json:"hsn_or_sac,omitempty"`
	TaxName     string  `json:"tax_name,omitempty"`
	TaxType     string  `json:"tax_type,omitempty"`
	TaxPercent  float64 `json:"tax_percentage,omitempty"`

	LineItemTaxes []LineItemTaxes `json:"line_item_taxes,omitempty"`
}

LineItem struct contains info about the line items of the invoice

type LineItemTaxes

type LineItemTaxes struct {
	TaxId   string  `json:"tax_id"`
	TaxName string  `json:"tax_name"`
	TaxAmt  float32 `json:"tax_amount"`
}

type OAuthResponse

type OAuthResponse struct {
	Error       string `json:"error"`
	AccessToken string `json:"access_token"`
	APIDomain   string `json:"api_domain"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
}

type Payment

type Payment struct {
	ID             string        `json:"payment_id"`
	Mode           string        `json:"payment_mode"`
	Amount         float64       `json:"amount"`
	AmountRefunded float64       `json:"amount_refunded"`
	BankCharges    float64       `json:"bank_charges"`
	Date           string        `json:"date"`
	Status         string        `json:"status"`
	RefNo          string        `json:"reference_number"`
	Description    string        `json:"description"`
	CustomerID     string        `json:"customer_id"`
	CustomerName   string        `json:"customer_name"`
	Email          string        `json:"email"`
	Invoices       []InvoiceInfo `json:"invoices"`
	CurrencyCode   string        `json:"currency_code"`
	CurrencySymbol string        `json:"currency_symbol"`
}

func (*Payment) Create

func (p *Payment) Create(params *PaymentParams, client *Client) (*Payment, error)

Create method will try to create a contact on razorpay

func (*Payment) Delete

func (p *Payment) Delete(id string, client *Client) error

Delete tries to delete the payment with given id

func (*Payment) Endpoint

func (p *Payment) Endpoint() string

Endpoint method returns the endpoint of the resource

func (*Payment) FindAll

func (p *Payment) FindAll(opts *PaymentFindOptions, client *Client) ([]Payment, error)

FindAll tries to find the payment with given options

func (*Payment) FindOne

func (p *Payment) FindOne(id string, client *Client) (*Payment, error)

FindOne tries to find the contact with given id

func (*Payment) New

func (p *Payment) New() Resource

New method will create a payment object and return a pointer to it

type PaymentFindOptions

type PaymentFindOptions struct {
	CustomerID string
}

type PaymentParams

type PaymentParams struct {
	CustomerID  string  `json:"customer_id"`
	Mode        string  `json:"payment_mode"` // This can be check, cash, creditcard, banktransfer, bankremittance, autotransaction or others
	Amount      float64 `json:"amount"`
	Date        string  `json:"date"`
	RefNo       string  `json:"reference_number,omitempty"`
	Description string  `json:"description,omitempty"`

	Invoices       []InvoiceInfo `json:"invoices"`
	BankCharges    float64       `json:"bank_charges"`
	AccountID      string        `json:"account_id,omitempty"`
	TaxAccountID   string        `json:"tax_account_id,omitempty"`
	ContactPersons []string      `json:"contact_persons,omitempty"`
}

type Resource

type Resource interface {
	New() Resource
	Endpoint() string
}

Resource interface is to be used for generic decoding of object

type Response

type Response struct {
	Code    int     `json:"code"`
	Message string  `json:"message"`
	Contact Contact `json:"contact"`
	Invoice Invoice `json:"invoice"`
	Payment Payment `json:"payment"`

	BankTransaction BankTransaction `json:"banktransaction"`

	Contacts     []Contact     `json:"contacts"`
	Payments     []Payment     `json:"customerpayments"`
	Currencies   []Currency    `json:"currencies"`
	BankAccounts []BankAccount `json:"bankaccounts"`
	Data         zohoRespError `json:"data"`
}

Response struct to handle zohobooks response

func SendResp

func SendResp(resp *http.Response, err error, rs Resource) (*Response, error)

Jump to

Keyboard shortcuts

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