oblio

package module
v0.0.0-...-85b6212 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: MIT Imports: 12 Imported by: 0

README

OblioAPI

Test Status codecov

Oblio.eu API implementation for Go.

License

This package is distributed under the MIT License. See the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	AscOrderDir  = "ASC"
	DescOrderDir = "DESC"
)
View Source
const (
	IDOrderBy        = "id"
	IssueDateOrderBy = "issueDate"
	NumberOrderBy    = "number"
)
View Source
const (
	BaseURL = "https://www.oblio.eu/api"
)

Variables

View Source
var (
	ErrInvalidArgument = errors.New("invalid argument")
)

Functions

func IsUnauthorizedError

func IsUnauthorizedError(err error) bool

Types

type Authorized

type Authorized struct {
	AccessToken string `json:"-" url:"-"`
}

func (Authorized) GetAccessToken

func (a Authorized) GetAccessToken() string

type Client

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

func NewClient

func NewClient(clientID, clientSecret string, opts ...Option) *Client

func (*Client) CancelInvoice

func (c *Client) CancelInvoice(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) CancelNotice

func (c *Client) CancelNotice(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) CancelProforma

func (c *Client) CancelProforma(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) Collect

func (c *Client) Collect(ctx context.Context, req *CollectRequest) (*CollectResponse, error)

func (*Client) CreateInvoice

func (c *Client) CreateInvoice(ctx context.Context, req *CreateInvoiceRequest) (*CreateInvoiceResponse, error)

func (*Client) CreateNotice

func (c *Client) CreateNotice(ctx context.Context, req *CreateNoticeRequest) (*CreateNoticeResponse, error)

func (*Client) CreateProforma

func (c *Client) CreateProforma(ctx context.Context, req *CreateProformaRequest) (*CreateProformaResponse, error)

func (*Client) DeleteInvoice

func (c *Client) DeleteInvoice(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) DeleteNotice

func (c *Client) DeleteNotice(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) DeleteProforma

func (c *Client) DeleteProforma(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) GenerateToken

func (c *Client) GenerateToken(ctx context.Context) (*GenerateTokenResponse, error)

func (*Client) GetClients

func (c *Client) GetClients(ctx context.Context, req *GetClientsRequest) (*GetClientsResponse, error)

func (*Client) GetCompanies

func (c *Client) GetCompanies(ctx context.Context, req *GetCompaniesRequest) (*GetCompaniesResponse, error)

func (*Client) GetInvoice

func (c *Client) GetInvoice(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) GetInvoices

func (c *Client) GetInvoices(ctx context.Context, req *GetInvoicesRequest) (*GetInvoicesResponse, error)

func (*Client) GetLanguages

func (c *Client) GetLanguages(ctx context.Context, req *GetLanguagesRequest) (*GetLanguagesResponse, error)

func (*Client) GetManagement

func (c *Client) GetManagement(ctx context.Context, req *GetManagementRequest) (*GetManagementResponse, error)

func (*Client) GetNotice

func (c *Client) GetNotice(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) GetProducts

func (c *Client) GetProducts(ctx context.Context, req *GetProductsRequest) (*GetProductsResponse, error)

func (*Client) GetProforma

func (c *Client) GetProforma(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) GetSeries

func (c *Client) GetSeries(ctx context.Context, req *GetSeriesRequest) (*GetSeriesResponse, error)

func (*Client) GetVATRates

func (c *Client) GetVATRates(ctx context.Context, req *GetVATRatesRequest) (*GetVATRatesResponse, error)

func (*Client) RestoreInvoice

func (c *Client) RestoreInvoice(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) RestoreNotice

func (c *Client) RestoreNotice(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

func (*Client) RestoreProforma

func (c *Client) RestoreProforma(ctx context.Context, req *DocumentRequest) (*DocumentResponse, error)

type ClientFilter

type ClientFilter struct {
	CIF   string `json:"CIF,omitempty" url:"cif,omitempty"`
	Email string `json:"email,omitempty" url:"email,omitempty"`
	Phone string `json:"phone,omitempty" url:"phone,omitempty"`
	Code  string `json:"code,omitempty" url:"code,omitempty"`
}

type CollectRequest

type CollectRequest struct {
	CIF        string          `json:"cif,omitempty"`
	SeriesName string          `json:"seriesName,omitempty"`
	Number     string          `json:"number,omitempty"`
	Collects   []types.Collect `json:"collects,omitempty"`
}

type CollectResponse

type CollectResponse struct {
	Status

	Data types.Document `json:"data"`
}

type CreateInvoiceRequest

type CreateInvoiceRequest struct {
	CIF                string                  `json:"cif,omitempty"`
	Client             types.Client            `json:"client,omitempty"`
	IssueDate          types.Date              `json:"issueDate,omitempty"`
	DueDate            types.Date              `json:"dueDate,omitempty"`
	DeliveryDate       types.Date              `json:"deliveryDate,omitempty"`
	CollectDate        types.Date              `json:"collectDate,omitempty"`
	SeriesName         string                  `json:"seriesName,omitempty"`
	Language           string                  `json:"language,omitempty"`
	Precision          types.Int               `json:"precision,omitempty"`
	Currency           string                  `json:"currency,omitempty"`
	ExchangeRate       string                  `json:"exchangeRate,omitempty"`
	Products           []types.DocumentRow     `json:"products,omitempty"`
	IssuerName         string                  `json:"issuerName,omitempty"`
	IssuerID           string                  `json:"issuerId,omitempty"`
	NoticeNumber       string                  `json:"noticeNumber,omitempty"`
	InternalNote       string                  `json:"internalNote,omitempty"`
	DeputyName         string                  `json:"deputyName,omitempty"`
	DeputyIdentityCard string                  `json:"deputyIdentityCard,omitempty"`
	DeputyAuto         string                  `json:"deputyAuto,omitempty"`
	SalesAgent         string                  `json:"selesAgent,omitempty"`
	Mentions           string                  `json:"mentions,omitempty"`
	WorkStation        string                  `json:"workStation,omitempty"`
	Collect            types.Collect           `json:"collect,omitempty"`
	ReferenceDocument  types.ReferenceDocument `json:"referenceDocument,omitempty"`
	SendEmail          types.Bool              `json:"sendEmail,omitempty"`
	UseStock           types.Bool              `json:"useStock,omitempty"`
}

type CreateInvoiceResponse

type CreateInvoiceResponse struct {
	Status

	Data types.Document `json:"data"`
}

type CreateNoticeRequest

type CreateNoticeRequest struct {
	CIF                string              `json:"cif,omitempty"`
	Client             types.Client        `json:"client,omitempty"`
	IssueDate          types.Date          `json:"issueDate,omitempty"`
	DueDate            types.Date          `json:"dueDate,omitempty"`
	SeriesName         string              `json:"seriesName,omitempty"`
	Language           string              `json:"language,omitempty"`
	Precision          types.Int           `json:"precision,omitempty"`
	Currency           string              `json:"currency,omitempty"`
	ExchangeRate       int                 `json:"exchangeRate,omitempty"`
	Products           []types.DocumentRow `json:"products,omitempty"`
	IssuerName         string              `json:"issuerName,omitempty"`
	IssuerID           int64               `json:"issuerId,omitempty"`
	InternalNote       string              `json:"internalNote,omitempty"`
	DeputyName         string              `json:"deputyName,omitempty"`
	DeputyIdentityCard string              `json:"deputyIdentityCard,omitempty"`
	DeputyAuto         string              `json:"deputyAuto,omitempty"`
	SalesAgent         string              `json:"selesAgent,omitempty"`
	Mentions           string              `json:"mentions,omitempty"`
	WorkStation        string              `json:"workStation,omitempty"`
	SendEmail          types.Bool          `json:"sendEmail,omitempty"`
	UseStock           types.Bool          `json:"useStock"`
}

type CreateNoticeResponse

type CreateNoticeResponse struct {
	Status

	Data types.Document `json:"data"`
}

type CreateProformaRequest

type CreateProformaRequest struct {
	CIF                string              `json:"cif,omitempty"`
	Client             types.Client        `json:"client,omitempty"`
	IssueDate          types.Date          `json:"issueDate,omitempty"`
	DueDate            types.Date          `json:"dueDate,omitempty"`
	SeriesName         string              `json:"seriesName,omitempty"`
	Language           string              `json:"language,omitempty"`
	Precision          types.Int           `json:"precision,omitempty"`
	Currency           string              `json:"currency,omitempty"`
	ExchangeRate       int                 `json:"exchangeRate,omitempty"`
	Products           []types.DocumentRow `json:"products,omitempty"`
	IssuerName         string              `json:"issuerName,omitempty"`
	IssuerID           int64               `json:"issuerId,omitempty"`
	NoticeNumber       string              `json:"noticeNumber,omitempty"`
	InternalNote       string              `json:"internalNote,omitempty"`
	DeputyName         string              `json:"deputyName,omitempty"`
	DeputyIdentityCard string              `json:"deputyIdentityCard,omitempty"`
	DeputyAuto         string              `json:"deputyAuto,omitempty"`
	SalesAgent         string              `json:"selesAgent,omitempty"`
	Mentions           string              `json:"mentions,omitempty"`
	WorkStation        string              `json:"workStation,omitempty"`
	SendEmail          bool                `json:"sendEmail,omitempty"`
}

type CreateProformaResponse

type CreateProformaResponse struct {
	Status

	Data types.Document `json:"data"`
}

type DocumentRequest

type DocumentRequest struct {
	CIF        string `json:"cif,omitempty" url:"cif,omitempty"`
	SeriesName string `json:"seriesName,omitempty" url:"seriesName,omitempty"`
	Number     string `json:"number,omitempty" url:"number,omitempty"`
}

type DocumentResponse

type DocumentResponse struct {
	Status

	Data types.Document `json:"data"`
}

type ErrorResponse

type ErrorResponse struct {
	Status  int    `json:"status,omitempty"`
	Message string `json:"statusMessage,omitempty"`
}

func UnmarshalErrorResponse

func UnmarshalErrorResponse(resp *http.Response) *ErrorResponse

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type GenerateTokenResponse

type GenerateTokenResponse struct {
	AccessToken string          `json:"access_token,omitempty"`
	ExpiresIn   types.Int       `json:"expires_in,omitempty"`
	TokenType   string          `json:"token_type,omitempty"`
	Scope       string          `json:"scope,omitempty"`
	RequestTime types.Timestamp `json:"request_time,omitempty"`
}

type GetClientsRequest

type GetClientsRequest struct {
	Authorized

	CIF       string `json:"cif,omitempty" url:"cif,omitempty"`
	Name      string `json:"name,omitempty" url:"name,omitempty"`
	ClientCIF string `json:"clientCif,omitempty" url:"clientCif,omitempty"`
	Offset    int    `json:"offset,omitempty" url:"offset,omitempty"`
}

type GetClientsResponse

type GetClientsResponse struct {
	Status

	Data []types.Client `json:"data"`
}

type GetCompaniesRequest

type GetCompaniesRequest struct {
	Authorized
}

type GetCompaniesResponse

type GetCompaniesResponse struct {
	Status

	Data []types.Company `json:"data"`
}

type GetInvoicesRequest

type GetInvoicesRequest struct {
	CIF                string       `json:"cif,omitempty" url:"cif,omitempty"`
	SeriesName         string       `json:"seriesName,omitempty" url:"seriesName,omitempty"`
	Number             string       `json:"number,omitempty" url:"number,omitempty"`
	Draft              types.Bool   `json:"draft,omitempty" url:"draft,omitempty"`
	Client             ClientFilter `json:"client,omitempty" url:"client,omitempty"`
	Canceled           types.Bool   `json:"canceled,omitempty" url:"canceled,omitempty"`
	IssuedAfter        types.Date   `json:"issuedAfter" url:"issuedAfter,omitempty"`
	IssuedBefore       types.Date   `json:"issuedBefore" url:"issuedBefore,omitempty"`
	WithProducts       types.Bool   `json:"withProducts,omitempty" url:"withProducts,omitempty"`
	WithEInvoiceStatus types.Bool   `json:"withEInvoiceStatus,omitempty" url:"withEInvoiceStatus,omitempty"`
	OrderBy            OrderBy      `json:"orderBy,omitempty" url:"orderBy,omitempty"`
	OrderDir           OrderDir     `json:"orderDir,omitempty" url:"orderDir,omitempty"`
	LimitPerPage       int          `json:"limitPerPage,omitempty" url:"limitPerPage,omitempty"`
	Offset             int          `json:"offset,omitempty" url:"offset,omitempty"`
}

type GetInvoicesResponse

type GetInvoicesResponse struct {
	Status

	Data []types.Invoice `json:"data,omitempty"`
}

type GetLanguagesRequest

type GetLanguagesRequest struct {
	Authorized

	CIF string `json:"cif,omitempty" url:"cif,omitempty"`
}

type GetLanguagesResponse

type GetLanguagesResponse struct {
	Status

	Data []types.Language `json:"data"`
}

type GetManagementRequest

type GetManagementRequest struct {
	Authorized

	CIF string `json:"cif,omitempty" url:"cif,omitempty"`
}

type GetManagementResponse

type GetManagementResponse struct {
	Status

	Data []types.Management `json:"data"`
}

type GetProductsRequest

type GetProductsRequest struct {
	Authorized

	CIF         string `json:"cif,omitempty" url:"cif,omitempty"`
	Name        string `json:"name,omitempty" url:"name,omitempty"`
	Code        string `json:"code,omitempty" url:"code,omitempty"`
	Management  string `json:"management,omitempty" url:"management,omitempty"`
	WorkStation string `json:"workStation,omitempty" url:"workStation,omitempty"`
	Offset      int    `json:"offset,omitempty" url:"offset,omitempty"`
}

type GetProductsResponse

type GetProductsResponse struct {
	Status

	Data []types.Product `json:"data"`
}

type GetSeriesRequest

type GetSeriesRequest struct {
	Authorized

	CIF string `json:"cif,omitempty" url:"cif,omitempty"`
}

type GetSeriesResponse

type GetSeriesResponse struct {
	Status

	Data []types.Series `json:"data"`
}

type GetVATRatesRequest

type GetVATRatesRequest struct {
	Authorized

	CIF string `json:"cif,omitempty" url:"cif,omitempty"`
}

type GetVATRatesResponse

type GetVATRatesResponse struct {
	Status

	Data []types.VATRate `json:"data"`
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithClient

func WithClient(client *http.Client) Option

func WithTokenStorage

func WithTokenStorage(tokenStorage TokenStorage) Option

type OrderBy

type OrderBy string

type OrderDir

type OrderDir string

type Status

type Status struct {
	Status        int    `json:"status,omitempty"`
	StatusMessage string `json:"statusMessage,omitempty"`
}

type TokenStorage

type TokenStorage interface {
	Set(ctx context.Context, value string, ttl time.Duration) error
	Get(ctx context.Context) (string, error)
}

type Validator

type Validator interface {
	Validate() error
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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