Documentation
¶
Overview ¶
Package ticketbai provides a client for generating and sending TicketBAI documents to the different regional services in the Basque Country.
Index ¶
- Constants
- Variables
- func ParseCancelDocument(data []byte) (*convert.AnulaTicketBAI, error)
- func ParseDocument(data []byte) (*convert.TicketBAI, error)
- func ZoneFor(env *gobl.Envelope) l10n.Code
- type Client
- func (c *Client) Cancel(ctx context.Context, env *gobl.Envelope, d *convert.AnulaTicketBAI) error
- func (c *Client) Convert(env *gobl.Envelope) (*convert.TicketBAI, error)
- func (c *Client) CurrentTime() time.Time
- func (c *Client) Fingerprint(d *convert.TicketBAI, prev *convert.ChainData) error
- func (c *Client) FingerprintCancel(cd *convert.AnulaTicketBAI) error
- func (c *Client) GenerateCancel(env *gobl.Envelope) (*convert.AnulaTicketBAI, error)
- func (c *Client) Post(ctx context.Context, env *gobl.Envelope, d *convert.TicketBAI) error
- func (c *Client) Sandbox() bool
- func (c *Client) Sign(d *convert.TicketBAI, env *gobl.Envelope) error
- func (c *Client) SignCancel(cd *convert.AnulaTicketBAI, env *gobl.Envelope) error
- func (c *Client) Zone() l10n.Code
- type Error
- type Licenses
- type Option
- func InProduction() Option
- func InSandbox() Option
- func WithCertificate(cert *xmldsig.Certificate) Option
- func WithConnection(conn gateways.Connection) Option
- func WithCurrentTime(curTime time.Time) Option
- func WithCustomerIssuer() Option
- func WithSupplierIssuer() Option
- func WithThirdPartyIssuer() Option
- type Software
- type TestConnection
Constants ¶
const ( ZoneBI l10n.Code = convert.ZoneBI // Bizkaia ZoneSS l10n.Code = convert.ZoneSS // Gipuzkoa ZoneVI l10n.Code = convert.ZoneVI // Araba )
Expose zone codes for external use.
Variables ¶
var ( ErrValidation = newError("validation") ErrDuplicate = newError("duplicate") ErrConnection = newError("connection") ErrInternal = newError("internal") )
Main error types return by this package.
Functions ¶
func ParseCancelDocument ¶ added in v0.31.0
func ParseCancelDocument(data []byte) (*convert.AnulaTicketBAI, error)
ParseCancelDocument will parse the XML data into a Cancel TicketBAI document.
func ParseDocument ¶ added in v0.31.0
ParseDocument will parse the XML data into a TicketBAI document.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides the main interface to the TicketBAI package.
func New ¶
New creates a new TicketBAI client with shared software and configuration options for creating and sending new documents.
func (*Client) Cancel ¶ added in v0.15.0
Cancel will send the cancel document in the TicketBAI gateway.
func (*Client) Convert ¶ added in v0.31.0
Convert creates a new TicketBAI document from the provided GOBL Envelope. The envelope must contain a valid Invoice.
func (*Client) CurrentTime ¶
CurrentTime returns the current time to use when generating the TicketBAI document.
func (*Client) Fingerprint ¶
Fingerprint generates a fingerprint for the TicketBAI document using the data provided from the previous chain data. If there was no previous document in the chain, the parameter should be nil. The document is updated in place.
func (*Client) FingerprintCancel ¶ added in v0.31.0
func (c *Client) FingerprintCancel(cd *convert.AnulaTicketBAI) error
FingerprintCancel generates a finger print for the TicketBAI document using the data provided from the previous invoice data.
func (*Client) GenerateCancel ¶ added in v0.31.0
GenerateCancel creates a new AnulaTicketBAI document from the provided GOBL Envelope.
func (*Client) Sandbox ¶ added in v0.32.1
Sandbox returns true if the client is using the sandbox environment.
func (*Client) Sign ¶
Sign is used to generate the XML DSig components of the final XML document. This method will also update the GOBL Envelope with the QR codes that are generated.
func (*Client) SignCancel ¶ added in v0.31.0
SignCancel is used to generate the XML DSig components of the final XML document.
type Error ¶ added in v0.31.0
type Error struct {
// contains filtered or unexported fields
}
Error allows for structured responses to better handle errors upstream.
func (*Error) Is ¶ added in v0.31.0
Is checks to see if the target error is the same as the current one or forms part of the chain.
type Licenses ¶ added in v0.37.0
type Licenses map[gateways.Environment]map[l10n.Code]string
Licenses stores the licenses for the different zones and environments.
type Option ¶
type Option func(*Client)
Option is used to configure the client.
func InProduction ¶
func InProduction() Option
InProduction defines the connection to use the production environment.
func InSandbox ¶ added in v0.32.0
func InSandbox() Option
InSandbox defines the connection to use the testing environment.
func WithCertificate ¶
func WithCertificate(cert *xmldsig.Certificate) Option
WithCertificate defines the signing certificate to use when producing the TicketBAI document.
func WithConnection ¶ added in v0.31.0
func WithConnection(conn gateways.Connection) Option
WithConnection defines a new gateway connection to use for the client. Useful for testing and mocking the connection responses.
func WithCurrentTime ¶
WithCurrentTime defines the current time to use when generating the TicketBAI document. Useful for testing.
func WithCustomerIssuer ¶ added in v0.9.0
func WithCustomerIssuer() Option
WithCustomerIssuer set the issuer type to customer. To be used when the invoice's supplier, using their own certificate, is issuing the document.
func WithSupplierIssuer ¶ added in v0.9.0
func WithSupplierIssuer() Option
WithSupplierIssuer set the issuer type to supplier. To be used when the invoice's supplier, using their own certificate, is issuing the document.
func WithThirdPartyIssuer ¶ added in v0.9.0
func WithThirdPartyIssuer() Option
WithThirdPartyIssuer set the issuer type to third party. To be used when the an authorised third party, using their own certificate, is issuing the document on behalf of the invoice's supplier.
type Software ¶
Software defines the details about the software that is using this library to generate TicketBAI documents. These details are included in the final document.
type TestConnection ¶ added in v0.16.0
type TestConnection struct {
// contains filtered or unexported fields
}
TestConnection is a mock gateway connection for testing purposes
func (*TestConnection) Cancel ¶ added in v0.16.0
func (tc *TestConnection) Cancel(_ context.Context, _ *bill.Invoice, _ *convert.AnulaTicketBAI) error
Cancel mocks the Cancel method of the Connection interface
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ca is used to provide the root certificates used by the TicketBAI services.
|
Package ca is used to provide the root certificates used by the TicketBAI services. |
|
cmd
|
|
|
gobl.ticketbai
command
Package main provides the command line interface to the TicketBAI package.
|
Package main provides the command line interface to the TicketBAI package. |
|
Package convert contains the TicketBAI document structures and methods to generate it.
|
Package convert contains the TicketBAI document structures and methods to generate it. |
|
internal
|
|
|
gateways
Package gateways contains the different interfaces to send the TicketBAI documents to.
|
Package gateways contains the different interfaces to send the TicketBAI documents to. |
|
gateways/ebizkaia
Package ebizkaia provides a gatewy for generating and sending documents to the Bizkaia region.
|
Package ebizkaia provides a gatewy for generating and sending documents to the Bizkaia region. |
|
Package test provides common functions for testing.
|
Package test provides common functions for testing. |