Documentation
¶
Overview ¶
Package stackin is the official Go SDK for the stackin fiscal document API — issue, consult, and cancel Brazilian NF-e and NFS-e electronic invoices with a single API key, no certificates or XML handling required.
See https://docs.stackin.io for the REST API reference and https://docs.stackin.io/blog/go-sdk for the Go SDK guide.
Index ¶
- Constants
- type APIError
- type Address
- type ConnectionFailedError
- type DocumentType
- type Environment
- type HistoryQuery
- type InvalidationRequest
- type Invoice
- func (inv *Invoice) Cancel(accessKey string, documentType DocumentType, reason string) (map[string]any, error)
- func (inv *Invoice) Consult(accessKey string, documentType DocumentType) (map[string]any, error)
- func (inv *Invoice) Correct(accessKey string, documentType DocumentType, correction string) (map[string]any, error)
- func (inv *Invoice) History(query HistoryQuery) (map[string]any, error)
- func (inv *Invoice) Invalidate(req InvalidationRequest) (map[string]any, error)
- func (inv *Invoice) Issue(req IssueRequest) (map[string]any, error)
- func (inv *Invoice) Manifest(accessKey string, manifestation Manifestation, reason string) (map[string]any, error)
- func (inv *Invoice) Pdf(accessKey string, documentType DocumentType) ([]byte, error)
- func (inv *Invoice) Received(limit, offset int) (map[string]any, error)
- func (inv *Invoice) Reissue(invoiceID string, opts ...RequestOption) (map[string]any, error)
- type InvoiceError
- type IssueRequest
- type Manifestation
- type Option
- type RequestOption
Constants ¶
const DefaultBaseURL = "https://sdk.stackin.io"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
State string `json:"state,omitempty"`
CityCode string `json:"city_code,omitempty"`
Street string `json:"street,omitempty"`
Number string `json:"number,omitempty"`
Neighborhood string `json:"neighborhood,omitempty"`
City string `json:"city,omitempty"`
ZipCode string `json:"zip_code,omitempty"`
}
type ConnectionFailedError ¶
type ConnectionFailedError struct {
Message string
}
func (*ConnectionFailedError) Error ¶
func (e *ConnectionFailedError) Error() string
type DocumentType ¶
type DocumentType string
const ( NFE DocumentType = "nfe" NFSE DocumentType = "nfse" )
type Environment ¶
type Environment string
const ( Local Environment = "local" Test Environment = "test" Production Environment = "production" )
type HistoryQuery ¶ added in v0.5.0
type HistoryQuery struct {
DocumentType DocumentType
Status string
Limit int
Offset int
SortBy string
OrderBy string
}
HistoryQuery filters the issuance history. Every field is optional; the zero value asks for the newest page with the API's own defaults.
type InvalidationRequest ¶ added in v0.2.0
type Invoice ¶
type Invoice struct {
BaseURL string
APIKey string
Timeout time.Duration
// contains filtered or unexported fields
}
func NewInvoice ¶
func (*Invoice) History ¶ added in v0.5.0
func (inv *Invoice) History(query HistoryQuery) (map[string]any, error)
History lists what this company issued, newest first.
The counterpart of Received: that one lists what was issued against the company, this one what the company issued.
func (*Invoice) Invalidate ¶ added in v0.2.0
func (inv *Invoice) Invalidate(req InvalidationRequest) (map[string]any, error)
func (*Invoice) Manifest ¶ added in v0.3.1
func (inv *Invoice) Manifest(accessKey string, manifestation Manifestation, reason string) (map[string]any, error)
Manifest files the recipient's formal answer to a received document.
Only OperacaoNaoRealizada takes a reason, and it requires one. Both are fixed rules, checked here rather than spending a round trip to be told.
func (*Invoice) Pdf ¶ added in v0.3.0
func (inv *Invoice) Pdf(accessKey string, documentType DocumentType) ([]byte, error)
Pdf returns the authorizer's own rendering of an authorized document, as raw bytes — the only method that does not return a parsed object. The XML is the legally valid document; this is a convenience, and the authorizer's endpoint for it is unstable, so an APIError with status 502 means the authorizer is unavailable, not that the invoice is wrong. NFS-e only.
type InvoiceError ¶
type InvoiceError struct {
Message string
}
func (*InvoiceError) Error ¶
func (e *InvoiceError) Error() string
type IssueRequest ¶
type IssueRequest struct {
DocumentType DocumentType
ClientName string
TaxID string
Items []br.Product
RecipientAddress *Address
Series string
Number string
// IdempotencyKey makes a retry safe: the same key with the same body
// replays the first response instead of issuing a second document.
// Keys live 24 hours. Never generated for you — only the caller knows
// which two requests are meant to be the same one.
IdempotencyKey string
}
type Manifestation ¶ added in v0.3.1
type Manifestation string
Manifestation is the recipient's answer to a document issued against it.
const ( Confirmacao Manifestation = "210200" Ciencia Manifestation = "210210" Desconhecimento Manifestation = "210220" OperacaoNaoRealizada Manifestation = "210240" )
type Option ¶
type Option func(*Invoice)
func WithAPIKey ¶
func WithBaseURL ¶
func WithEnvironment ¶
func WithEnvironment(env Environment) Option
func WithTimeout ¶
type RequestOption ¶ added in v0.2.0
type RequestOption func(*requestConfig)
RequestOption tunes a single call, as opposed to Option, which tunes the client.
func WithIdempotencyKey ¶ added in v0.2.0
func WithIdempotencyKey(key string) RequestOption
WithIdempotencyKey attaches an Idempotency-Key to one call. See IssueRequest.IdempotencyKey for what the API does with it.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
cancel_invoice
command
|
|
|
consult_invoice
command
|
|
|
nfe/basic
command
|
|
|
nfe/full
command
|
|
|
nfe/icms_isento
command
|
|
|
nfe/imported
command
|
|
|
nfe/interstate_with_icms_dest
command
|
|
|
nfe/scale_manufactured
command
|
|
|
nfe/taxed_icms
command
|
|
|
nfe/used_asset
command
|
|
|
nfe/with_barcode
command
|
|
|
nfe/with_extra_charges
command
|
|
|
nfe/with_purchase_order
command
|
|
|
nfe/with_quantity
command
|
|
|
nfe/with_tax_benefit
command
|
|
|
nfse/basic
command
|
|
|
nfse/full
command
|
|
|
nfse/with_discount
command
|
|
|
nfse/with_observations
command
|
|
|
nfse/with_service_code
command
|
|
|
nfse/with_tax_retained
command
|
|
|
reissue_invoice
command
|