Documentation ¶
Overview ¶
Package scoro provides Go client code for sending requests to Scoro API.
Services ¶
Code of the library is divided into several services, one for each Scoro API "module". Each service provides a subset of View/List/Modify/Delete actions which are directly mapped to the corresponding API calls.
Products service:
products := scoro.Products(credentials)
Quotes service:
quotes := scoro.Quotes(credentials)
Orders service:
orders := scoro.Orders(credentials)
Invoices service:
invoices := scoro.Invoices(credentials)
Index ¶
- Constants
- type Address
- type Bool
- type Contact
- type ContactList
- type ContactsAPI
- type Credentials
- type Date
- type Decimal
- type DecimalLike
- type Invoice
- type InvoiceLine
- type InvoiceList
- type InvoicesAPI
- type MeansOfContact
- type Order
- type OrderLine
- type OrderList
- type OrdersAPI
- type Product
- type ProductList
- type ProductsAPI
- type Quote
- type QuoteLine
- type QuoteList
- type QuotesAPI
- type Receipt
- type ReceiptList
- type ReceiptsAPI
- type Relation
- type RelationList
- type RelationsAPI
- type Request
- func (t Request) Delete(id int, filter interface{}) (interface{}, error)
- func (t Request) List(filter interface{}, page int, count int) (interface{}, error)
- func (t Request) Modify(obj interface{}) (interface{}, error)
- func (t Request) SetResponse(response ResponseType) Request
- func (t Request) View(id string) (interface{}, error)
- type ResponseHeader
- type ResponseType
- type Strings
- type Time
Constants ¶
const DatePattern = `"2006-01-02"`
DatePattern represents time format used in Scoro API requests and responses
const DefaultLang = "eng"
const NullStr = "null"
const TimePattern = `"2006-01-02 15:04:05"`
TimePattern represents time format used in Scoro API requests and responses
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool struct {
Value bool `json:",inlline"`
}
Bool type provides the implementation of serialization boolean values into Scoro API format. True -> "1" and False -> "0" mappings are used to serialize boolean values to into request JSON. Both boolean and "0"/"1" values are supported in response.
func (Bool) MarshalJSON ¶
func (*Bool) UnmarshalJSON ¶
type Contact ¶
type Contact struct { ContactID *int `json:"contact_id,omitempty"` Name string `json:"name,omitempty"` Lastname string `json:"lastname,omitempty"` ContactType string `json:"contact_type,omitempty"` IdCode string `json:"id_code,omitempty"` BankAccount string `json:"bankaccount,omitempty"` Birthday Date `json:"birthday,omitempty"` Position string `json:"position,omitempty"` Comments string `json:"comments,omitempty"` Sex string `json:"sex,omitempty"` VatNo string `json:"vatno,omitempty"` Timezone string `json:"timezone,omitempty"` ManagerID int `json:"manager_id,omitempty"` IsSupplier Bool `json:"is_supplier,omitempty"` IsClient Bool `json:"is_client,omitempty"` ModifiedDate Time `json:"modified_date,omitempty"` Addresses []Address `json:"addresses,omitempty"` MeansOfContact MeansOfContact `json:"means_of_contact,omitempty"` Tags []string `json:"tags,omitempty"` ReferenceNo string `json:"reference_no,omitempty"` CustomFields map[string]string `json:"custom_fields,omitempty"` IsDeleted Bool `json:"is_deleted"` }
Contact struct represents contacts data type of Scoro API. https://api.scoro.com/api/#contactsApiDocs
type ContactList ¶
type ContactList []Contact
type ContactsAPI ¶
type ContactsAPI struct {
// contains filtered or unexported fields
}
ContactsAPI provides type safe wrappers for View/List/Modify/Delete actions of contacts API
func Contacts ¶
func Contacts(credentials Credentials) ContactsAPI
func (ContactsAPI) Delete ¶
func (t ContactsAPI) Delete(id int) error
func (ContactsAPI) List ¶
func (t ContactsAPI) List(filter interface{}, page int, count int) (*ContactList, error)
func (ContactsAPI) Request ¶
func (t ContactsAPI) Request() Request
type Credentials ¶
type Credentials struct { // ApiKey holds apiKey value that is listed in Settings > External Connections > API. ApiKey string `json:"apiKey"` // CompanyID holds company_account_id value that is listed in Settings > External Connections > API. CompanyID string `json:"company_account_id"` // API subdomain Subdomain string `json:"-"` }
Credentials holds authentication parameters used to identificate Scoro customer and authorize requested action.
type Date ¶
Date type provides the implementation of JSON date serialization into Scoro API format.
Notes
- format is YYYY-MM-DD
- null value is supported
- "0000-00-00" is considered as null
func (Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
type Decimal ¶
type Decimal struct {
// contains filtered or unexported fields
}
Decimal is custom representation of decimal values to avoid using types from 3rd part libraries in exported methods.
func CopyDecimal ¶
func CopyDecimal(val DecimalLike) Decimal
func NewDecimal ¶
func NewDecimalFromFloat ¶
func (Decimal) MarshalJSON ¶
func (*Decimal) UnmarshalJSON ¶
type DecimalLike ¶
DecimalLike is interface for numeric values that can be represented as decimal
type Invoice ¶
type Invoice struct { Id *int `json:"id,omitempty"` PaymentType string `json:"payment_type,omitempty"` Fine string `json:"fine,omitempty"` QuoteID int `json:"quote_id"` OrderID int `json:"order_id"` PrepaymentPercent float32 `json:"prepayment_percent,omitempty"` PrepaymentSum Decimal `json:"prepayment_sum,omitempty"` ReferenceNo string `json:"reference_no,omitempty"` No string `json:"no,omitempty"` Discount float32 `json:"discount,omitempty"` Discount2 float32 `json:"discount2,omitempty"` Discount3 float32 `json:"discount3,omitempty"` Sum Decimal `json:"sum,omitempty"` VatSum Decimal `json:"vat_sum,omitempty"` Vat Decimal `json:"vat,omitempty"` CompanyID int `json:"company_id,omitempty"` PersonID int `json:"person_id,omitempty"` CompanyAddressID int `json:"company_address_id,omitempty"` InterestedPartyID int `json:"interested_party_id,omitempty"` InterestedPartyAddressID int `json:"interested_party_address_id,omitempty"` ProjectID int `json:"project_id,omitempty"` Currency string `json:"currency,omitempty"` OwnerID int `json:"owner_id,omitempty"` Date Date `json:"date,omitempty"` Deadline Date `json:"deadline,omitempty"` Status string `json:"status,omitempty"` Description string `json:"description,omitempty"` IsSent Bool `json:"is_sent"` Lines []InvoiceLine `json:"lines,omitempty"` ModifiedDate Time `json:"modified_date,omitempty"` CustomFields map[string]string `json:"custom_fields,omitempty"` IsDeleted Bool `json:"is_deleted"` DeletedDate Time `json:"deleted_date,omitempty"` }
Invoice struct represents invoices data type of Scoro API. https://api.scoro.com/api/#invoicesApiDocs
type InvoiceLine ¶
type InvoiceLine struct { Id int `json:"id"` ProductID int `json:"product_id"` Comment string `json:"comment"` Comment2 string `json:"comment2"` UnitPrice Decimal `json:"price"` Amount Decimal `json:"amount"` Amount2 Decimal `json:"amount2"` Discount Decimal `json:"discount"` Sum Decimal `json:"sum"` Vat Decimal `json:"vat"` Unit string `json:"unit"` FinanceObjectID int `json:"finance_object_id"` Cost Decimal `json:"cost"` ProjectID int `json:"project_id"` CustomFields map[string]string `json:"custom_fields,omitempty"` }
InvoiceLine struct represents invoice lines data type of Scoro API. https://api.scoro.com/api/#invoiceLinesApiDocs
type InvoiceList ¶
type InvoiceList []Invoice
type InvoicesAPI ¶
type InvoicesAPI struct {
// contains filtered or unexported fields
}
InvoicesAPI provides type safe wrappers for View/List/Modify/Delete actions of invoices API
func Invoices ¶
func Invoices(credentials Credentials) InvoicesAPI
InvoicesAPI provides type safe wrappers for View/List/Modify/Delete actions of invoices API
func PrepaymentInvoices ¶
func PrepaymentInvoices(credentials Credentials) InvoicesAPI
InvoicesAPI provides type safe wrappers for View/List/Modify/Delete actions of prepayments API https://api.scoro.com/api/#prepaymentsApiDocs
func (InvoicesAPI) Delete ¶
func (t InvoicesAPI) Delete(id int) error
func (InvoicesAPI) List ¶
func (t InvoicesAPI) List(filter interface{}, page int, count int) (*InvoiceList, error)
func (InvoicesAPI) Request ¶
func (t InvoicesAPI) Request() Request
type MeansOfContact ¶
type Order ¶
type Order struct { Id *int `json:"id,omitempty"` QuoteID int `json:"quote_id"` No string `json:"no,omitempty"` Discount float32 `json:"discount,omitempty"` Discount2 float32 `json:"discount2,omitempty"` Discount3 float32 `json:"discount3,omitempty"` Sum Decimal `json:"sum,omitempty"` VatSum Decimal `json:"vat_sum,omitempty"` Vat Decimal `json:"vat,omitempty"` CompanyID int `json:"company_id,omitempty"` PersonID int `json:"person_id,omitempty"` CompanyAddressID int `json:"company_address_id,omitempty"` InterestedPartyID int `json:"interested_party_id,omitempty"` InterestedPartyAddressID int `json:"interested_party_address_id,omitempty"` ProjectID int `json:"project_id,omitempty"` Currency string `json:"currency,omitempty"` OwnerID int `json:"owner_id,omitempty"` Date Date `json:"date,omitempty"` Deadline Date `json:"deadline,omitempty"` Status string `json:"status,omitempty"` Description string `json:"description,omitempty"` IsSent Bool `json:"is_sent"` Lines []OrderLine `json:"lines,omitempty"` ModifiedDate Time `json:"modified_date,omitempty"` CustomFields map[string]string `json:"custom_fields,omitempty"` IsDeleted Bool `json:"is_deleted"` DeletedDate Time `json:"deleted_date,omitempty"` }
Order struct represents orders data type of Scoro API. https://api.scoro.com/api/#ordersApiDocs
type OrderLine ¶
type OrderLine struct { Id int `json:"id"` ProductID int `json:"product_id"` Comment string `json:"comment"` Comment2 string `json:"comment2"` UnitPrice Decimal `json:"price"` Amount Decimal `json:"amount"` Amount2 Decimal `json:"amount2"` Discount Decimal `json:"discount"` Sum Decimal `json:"sum"` Vat Decimal `json:"vat"` Unit string `json:"unit"` FinanceObjectID int `json:"finance_object_id"` Cost Decimal `json:"cost"` ProjectID int `json:"project_id"` CustomFields map[string]string `json:"custom_fields,omitempty"` }
OrderLine struct represents order lines data type of Scoro API. https://api.scoro.com/api/#orderLinesApiDocs
type OrdersAPI ¶
type OrdersAPI struct {
// contains filtered or unexported fields
}
OrdersAPI provides type safe wrappers for View/List/Modify/Delete actions of orders API
func Orders ¶
func Orders(credentials Credentials) OrdersAPI
type Product ¶
type Product struct { Id *int `json:"product_id,omitempty"` Code string `json:"code,omitempty"` Name string `json:"name,omitempty"` Names Strings `json:"names,omitempty"` Price Decimal `json:"price,omitempty"` BuyingPrice Decimal `json:"buying_price,omitempty"` Description Strings `json:"description,omitempty"` Description2 Strings `json:"description2,omitempty"` Tag string `json:"tag,omitempty"` Url string `json:"url,omitempty"` SupplierID int `json:"supplier_id,omitempty"` ProductGroupID int `json:"productgroup_id,omitempty"` IsActive Bool `json:"is_active"` IsService Bool `json:"is_service"` DefaultVatCodeID int `json:"default_vat_code_id,omitempty"` AccountinObjectID int `json:"accounting_object_id,omitempty"` ModifiedDate Time `json:"modified_date,omitempty"` CustomFields map[string]string `json:"custom_fields,omitempty"` IsDeleted Bool `json:"is_deleted"` DeletedDate Time `json:"deleted_date,omitempty"` }
Product struct represents products data type of Scoro API. https://api.scoro.com/api/#productsApiDocs
type ProductList ¶
type ProductList []Product
type ProductsAPI ¶
type ProductsAPI struct {
// contains filtered or unexported fields
}
ProductsAPI provides type safe wrappers for View/List/Modify/Delete actions of products API
func Products ¶
func Products(credentials Credentials) ProductsAPI
func (ProductsAPI) Delete ¶
func (t ProductsAPI) Delete(id int) error
func (ProductsAPI) List ¶
func (t ProductsAPI) List(filter interface{}, page int, count int) (*ProductList, error)
func (ProductsAPI) Request ¶
func (t ProductsAPI) Request() Request
type Quote ¶
type Quote struct { Id *int `json:"id,omitempty"` No string `json:"no,omitempty"` Discount float32 `json:"discount,omitempty"` Discount2 float32 `json:"discount2,omitempty"` Discount3 float32 `json:"discount3,omitempty"` Sum Decimal `json:"sum,omitempty"` VatSum Decimal `json:"vat_sum,omitempty"` Vat Decimal `json:"vat,omitempty"` CompanyID int `json:"company_id,omitempty"` PersonID int `json:"person_id,omitempty"` CompanyAddressID int `json:"company_address_id,omitempty"` InterestedPartyID int `json:"interested_party_id,omitempty"` InterestedPartyAddressID int `json:"interested_party_address_id,omitempty"` ProjectID int `json:"project_id,omitempty"` Currency string `json:"currency,omitempty"` OwnerID int `json:"owner_id,omitempty"` Date Date `json:"date,omitempty"` Deadline Date `json:"deadline,omitempty"` Status string `json:"status,omitempty"` Description string `json:"description,omitempty"` IsSent Bool `json:"is_sent"` AccountID string `json:"account_id,omitempty"` Lines []QuoteLine `json:"lines,omitempty"` ModifiedDate Time `json:"modified_date,omitempty"` CustomFields map[string]string `json:"custom_fields,omitempty"` IsDeleted Bool `json:"is_deleted"` DeletedDate Time `json:"deleted_date,omitempty"` }
Quote struct represents quotes data type of Scoro API. https://api.scoro.com/api/#quotesApiDocs
type QuoteLine ¶
type QuoteLine struct { Id int `json:"id"` ProductID int `json:"product_id"` Comment string `json:"comment"` Comment2 string `json:"comment2"` UnitPrice Decimal `json:"price"` Amount Decimal `json:"amount"` Amount2 Decimal `json:"amount2"` Discount Decimal `json:"discount"` Sum Decimal `json:"sum"` Vat Decimal `json:"vat"` Unit string `json:"unit"` FinanceObjectID int `json:"finance_object_id"` Cost Decimal `json:"cost"` ProjectID int `json:"project_id"` CustomFields map[string]string `json:"custom_fields,omitempty"` }
QuoteLine struct represents quote lines data type of Scoro API. https://api.scoro.com/api/#quoteLinesApiDocs
type QuotesAPI ¶
type QuotesAPI struct {
// contains filtered or unexported fields
}
QuotesAPI provides type safe wrappers for View/List/Modify/Delete actions of quotes API
func Quotes ¶
func Quotes(credentials Credentials) QuotesAPI
type Receipt ¶
type Receipt struct { Id *int `json:"receipt_id,omitempty"` Date Date `json:"date,omitempty"` InvoiceID *int `json:"invoice_id,omitempty"` PrepaymentID *int `json:"prepayment_id,omitempty"` Sum Decimal `json:"sum,omitempty"` SalesDocType string `json:"sales_doc_type,omitempty"` ContactID int `json:"contact_id,omitempty"` ContactName string `json:"contact_name,omitempty"` }
Receipt struct represents receipts data type of Scoro API. https://api.scoro.com/api/#receiptsApiDocs
type ReceiptList ¶
type ReceiptList []Receipt
type ReceiptsAPI ¶
type ReceiptsAPI struct {
// contains filtered or unexported fields
}
ReceiptsAPI provides type safe wrappers for View/List/Modify/Delete actions of receipts API
func Receipts ¶
func Receipts(credentials Credentials) ReceiptsAPI
func (ReceiptsAPI) Delete ¶
func (t ReceiptsAPI) Delete(id int) error
func (ReceiptsAPI) List ¶
func (t ReceiptsAPI) List(filter interface{}, page int, count int) (*ReceiptList, error)
func (ReceiptsAPI) Request ¶
func (t ReceiptsAPI) Request() Request
type Relation ¶
type Relation struct { ObjectID int `json:"object_id,omitempty"` // RelatedObjects is map containing related objects ID-s for each type on // list request and list of ID-s on modify/delete request. RelatedObjects interface{} `json:"related_objects,omitempty"` Type string `json:"type,omitempty"` }
Relation struct represents relations data type of Scoro API. https://api.scoro.com/api/#relationsApiDocs
type RelationList ¶
type RelationList []Relation
type RelationsAPI ¶
type RelationsAPI struct {
// contains filtered or unexported fields
}
RelationsAPI provides type safe wrappers for View/List/Modify/Delete actions of relations API
func Relations ¶
func Relations(credentials Credentials) RelationsAPI
func (RelationsAPI) Delete ¶
func (t RelationsAPI) Delete(id int) error
func (RelationsAPI) List ¶
func (t RelationsAPI) List(filter interface{}, page int, count int) (*RelationList, error)
func (RelationsAPI) Request ¶
func (t RelationsAPI) Request() Request
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request helps to build and send custom request to Scoro API. It supports automatic mappings of data structures into request body and from response.
It is unlikely that you will need to use this type directly. Most of the time service wrappers should be used instead. But it could be helpful in some case, for instance, if some new request isn't implemented yet.
Example:
response := NewRequest(credentials).SetResponse(ProductResponse{}).View(id)
func NewRequest ¶
func NewRequest(credentials Credentials, entityType string) Request
NewRequest creates request object configured with specified credentials and pointed to the endpoint corresponding to the specified entityType.
entityType can be "products", "orders", "invoices" or any other type supported by Scoro API
func (Request) SetResponse ¶
func (t Request) SetResponse(response ResponseType) Request
SetResponse method is to register the response object for automatic unmarshalling of JSON responses. Response type shoul conforms to the ResponseType interface.
request.SetResult(ProductResponse{})
Accessing a result value
if resp, err := request.View(id); err != nil { product := resp.(*productResponse).Product }
type ResponseHeader ¶
type ResponseHeader struct { Status string `json:"status"` StatusCode string `json:"statusCode"` Messages *struct { Error []string `json:"error"` } `json:"messages,omitempty"` }
ResponseHeader represents base part of API response that is common for all responses.
Example of defining new response type:
type SomeNewResponse{ RequestHeader `json:",inline"` Data SomeDataType `json:"data,omitempty"` }
type ResponseType ¶
type ResponseType interface {
GetResponseHeader() ResponseHeader
}
ResponseType interface provides methods for retrieving information common for all responses. Each response type must implement this interface in order to be compatible with Request type.
type Strings ¶
Strings provides support for string fields with localization support. Scoro expects strings as localied dictionaries for some fields in request. However, it can return them as localized dictionary as single string (in requested lang) for the same fields in response. Marshal/Unmarshal implementations for this type handle both cases appropriately.
Examples:
field := scoro.MakeStrings("Some string", scoro.DefaultLang) field := scoro.MakeStrings("Привет", "rus")
func MakeStrings ¶
MakeStrings is helper method that creates strings for single language, it can be convinient if you don't need localization for multiple languages.
func (Strings) MarshalJSON ¶
func (*Strings) UnmarshalJSON ¶
type Time ¶
Time type provides the implementation of JSON date/time serialization into Scoro API format.
Notes
- format is YYYY-MM-DD hh:mm:ss
- null value is supported
- "0000-00-00 00:00:00" is considered as null