gateways

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package gateways contains the different interfaces to send the TicketBAI documents to.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnection = newError("connection")
	ErrValidation = newError("validation")
	ErrDuplicate  = newError("duplicate")
)

Standard gateway error responses. Keys match the ones from main package.

Functions

This section is empty.

Types

type ArabaConn added in v0.31.0

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

ArabaConn keeps all the connection details together for the Araba region.

func (*ArabaConn) Cancel added in v0.31.0

func (c *ArabaConn) Cancel(ctx context.Context, doc *doc.AnulaTicketBAI) error

Cancel will send a request to the Araba API to cancel a previously issued document.

func (*ArabaConn) Post added in v0.31.0

func (c *ArabaConn) Post(ctx context.Context, doc *doc.TicketBAI) error

Post sends the complete TicketBAI document to the Araba API.

type ArabaResponse added in v0.31.0

type ArabaResponse struct {
	Output struct {
		ID                string `xml:"IdentificadoTBAI"`
		Data              string `xml:"FechaRecepcion"`
		Status            string `xml:"Estado"`
		Description       string `xml:"Descripcion"`
		BasqueDescription string `xml:"Azalpena"` // Description, but in Basque
		Errors            []struct {
			Code              string `xml:"Codigo"`
			Description       string `xml:"Descripcion"`
			BasqueDescription string `xml:"Azalpena"`
		} `xml:"ResultadosValidacion"`
		CSV string `xml:"CSV"` // Secure Verification Code
	} `xml:"Salida"`
}

ArabaResponse defines the response fields from the Araba region.

type Connection

type Connection interface {
	// Post sends the complete TicketBAI document to the remote end-point. We assume
	// the document has been fully prepared and signed.
	Post(ctx context.Context, doc *doc.TicketBAI) error
	Cancel(ctx context.Context, doc *doc.AnulaTicketBAI) error
}

Connection defines what is expected from a connection to a gateway.

func New

func New(env Environment, zone l10n.Code, cert *xmldsig.Certificate) (Connection, error)

New instantiates a new connection for the given zone and environment.

type EBizkaiaConn

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

EBizkaiaConn keeps all the connection details together for the Vizcaya region.

func (*EBizkaiaConn) Cancel added in v0.15.0

func (c *EBizkaiaConn) Cancel(ctx context.Context, doc *doc.AnulaTicketBAI) error

Cancel sends the cancellation request for the TickeBAI invoice to the remote end-point.

func (*EBizkaiaConn) Fetch added in v0.15.0

func (c *EBizkaiaConn) Fetch(ctx context.Context, nif, name, year string, page int, head *doc.CabeceraFactura) ([]*doc.TicketBAI, error)

Fetch retrieves the TicketBAI from the remote end-point for the given taxpayer and year. This is no longer used as it is only available in this region.

func (*EBizkaiaConn) Post

func (c *EBizkaiaConn) Post(ctx context.Context, doc *doc.TicketBAI) error

Post sends the complete TicketBAI document to the remote end-point. We assume the document has been signed and prepared.

type Environment added in v0.15.0

type Environment string

Environment defines the environment to use for connections

const (
	EnvironmentProduction Environment = "production"
	EnvironmentSandbox    Environment = "sandbox"
)

Environment to use for connections

type Error

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

Error allows for structured responses from the gateway to be able to response codes and messages.

func (*Error) Code added in v0.31.0

func (e *Error) Code() string

Code returns the code provided by the remote service.

func (*Error) Error

func (e *Error) Error() string

Error produces a human readable error message.

func (*Error) Is added in v0.31.0

func (e *Error) Is(target error) bool

Is checks to see if the target error is the same as the current one or forms part of the chain.

func (*Error) Key added in v0.31.0

func (e *Error) Key() string

Key returns the key for the error.

func (*Error) Message added in v0.31.0

func (e *Error) Message() string

Message returns the human message for the error.

type GipuzkoaConn added in v0.31.0

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

GipuzkoaConn keeps all the connection details together for the Gipuzkoa region.

func (*GipuzkoaConn) Cancel added in v0.31.0

func (c *GipuzkoaConn) Cancel(ctx context.Context, doc *doc.AnulaTicketBAI) error

Cancel will send a request to the Gipuzkoa API to cancel a previously issued document.

func (*GipuzkoaConn) Post added in v0.31.0

func (c *GipuzkoaConn) Post(ctx context.Context, doc *doc.TicketBAI) error

Post sends the complete TicketBAI document to the Gipuzkoa API.

type GipuzkoaResponse added in v0.31.0

type GipuzkoaResponse struct {
	Output struct {
		ID                string `xml:"IdentificadoTBAI"`
		Data              string `xml:"FechaRecepcion"`
		Status            string `xml:"Estado"`
		Description       string `xml:"Descripcion"`
		BasqueDescription string `xml:"Azalpena"` // Description, but in Basque
		Errors            []struct {
			Code              string `xml:"Codigo"`
			Description       string `xml:"Descripcion"`
			BasqueDescription string `xml:"Azalpena"`
		} `xml:"ResultadosValidacion"`
		CSV string `xml:"CSV"` // Secure Verification Code
	} `xml:"Salida"`
}

GipuzkoaResponse defines the response fields from the Gipuzkoa region.

Directories

Path Synopsis
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.

Jump to

Keyboard shortcuts

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