api

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Test Environment = "https://ksef-test.mf.gov.pl/api"
	Demo             = "https://ksef-demo.mf.gov.pl/api"
	Prod             = "https://ksef.mf.gov.pl/api"
	Dev              = "http://localhost:8080/api"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	PostXMLFromBytes(endpoint string, body []byte, result interface{}) error
	GetJson(endpoint, token string, result interface{}) error
	Get(endpoint, token string) ([]byte, error)
	GetJsonNoAuth(endpoint string, result interface{}) error
	PostJson(endpoint, token string, body interface{}, result interface{}) error
	PostJsonNoAuth(endpoint string, body interface{}, result interface{}) error
	PutJson(endpoint, token string, body interface{}, result interface{}) error
	Env() Environment
}

func New

func New(environment Environment) Client

type Environment

type Environment string

type InvoiceService

type InvoiceService interface {
	SendInvoice(content []byte, token string) (*model.SendInvoiceResponse, error)
	EncryptAndSend(content []byte, cipher cipher.AesCipher, token string) (*model.SendInvoiceResponse, error)
	GetUpo(referenceNumber string) (*model.UpoDTO, error)
	GetInvoice(invoiceId, token string) ([]byte, error)
}

func NewInvoiceService

func NewInvoiceService(client Client) InvoiceService

type RequestError

type RequestError struct {
	StatusCode   int
	Err          error
	Body         string
	ErrorDetails map[string]any
}

func (*RequestError) Error

func (r *RequestError) Error() string

type SessionService

type SessionService interface {
	AuthorisationChallenge(identifier string, identifierType model.IdentifierType) (*model.AuthorisationChallengeResponse, error)
	LoginByToken(identifier string, identifierType model.IdentifierType, token, keyFileName string) (*model.TokenResponse, error)
	Status(pageSize, offset int, token string) (*model.SessionStatusResponse, error)
	StatusByReferenceNumber(pageSize, offset int, referenceNumber, token string) (*model.SessionStatusResponse, error)
	Terminate(token string) (*model.TerminateSessionResponse, error)
}

func NewSessionService

func NewSessionService(client Client) SessionService

NewSessionService prepare session without any encryption

func NewSessionServiceWithEncryption

func NewSessionServiceWithEncryption(client Client, aesCipher cipher.AesCipher) SessionService

NewSessionServiceWithEncryption prepare session with AES encryption

Jump to

Keyboard shortcuts

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