models

package
v0.0.0-...-3f9ec74 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 12 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// BancoDoBrasil constante do Banco do Brasil
	BancoDoBrasil = 1

	// Santander constante do Santander
	Santander = 33

	// Itau constante do Itau
	Itau = 341

	//Bradesco constante do Bradesco
	Bradesco = 237
	// Caixa constante do Caixa
	Caixa = 104

	// Citibank constante do Citi
	Citibank = 745

	//Real constante do REal
	Real = 9

	// Pefisa constante do Pefisa
	Pefisa = 174

	// Stone constante do Stone
	Stone = 197

	JPMorgan = 376
)

Variables

This section is empty.

Functions

func BoletoErrorConector

func BoletoErrorConector(e *flow.ExchangeMessage, u flow.URI, params ...interface{}) error

BoletoErrorConector é um connector flow para criar um objeto de erro

func HasValidId

func HasValidId(g *GetBoletoResult) bool

func HasValidPublicKey

func HasValidPublicKey(g *GetBoletoResult) bool

HasValidPublicKey Verifica se a chave pública para buscar um boleto está presente e se é um hexadecimal

Types

type Address

type Address struct {
	Street     string `json:"street,omitempty"`
	Number     string `json:"number,omitempty"`
	Complement string `json:"complement,omitempty"`
	ZipCode    string `json:"zipCode,omitempty"`
	City       string `json:"city,omitempty"`
	District   string `json:"district,omitempty"`
	StateCode  string `json:"stateCode,omitempty"`
}

Address informações de entrada do endereço

type Agreement

type Agreement struct {
	AgreementNumber uint   `json:"agreementNumber,omitempty"`
	Wallet          uint16 `json:"wallet,omitempty"`
	WalletVariation uint16 `json:"walletVariation,omitempty"`
	Agency          string `json:"agency,omitempty"`
	AgencyDigit     string `json:"agencyDigit,omitempty"`
	Account         string `json:"account,omitempty"`
	AccountDigit    string `json:"accountDigit,omitempty"`
}

Agreement afiliação do cliente com o bano

func (*Agreement) CalculateAccountDigit

func (a *Agreement) CalculateAccountDigit(digitCalculator func(agency, account string) string)

CalculateAccountDigit calcula dígito da conta

func (*Agreement) CalculateAgencyDigit

func (a *Agreement) CalculateAgencyDigit(digitCalculator func(agency string) string)

CalculateAgencyDigit calcula dígito da agência

func (*Agreement) IsAccountValid

func (a *Agreement) IsAccountValid(accountLength int) error

IsAccountValid retorna se é uma conta válida

func (*Agreement) IsAgencyValid

func (a *Agreement) IsAgencyValid() error

IsAgencyValid retorna se é uma agência válida

type ArrayDataError

type ArrayDataError struct {
	Error []ErrorResponse `json:"error"`
}

DataError objeto de erro

type Authentication

type Authentication struct {
	Username           string `json:"Username,omitempty"`
	Password           string `json:"Password,omitempty"`
	AuthorizationToken string `json:"AuthorizationToken,omitempty"`
	AccessKey          string `json:"AccessKey,omitempty"`
}

Authentication autenticação para entrada na API do banco

type BadGatewayError

type BadGatewayError ErrorResponse

BadGatewayError interface para implementar Error

func NewBadGatewayError

func NewBadGatewayError(e string) BadGatewayError

NewBadGatewayError cria um novo objeto de BadGatewayError com descrição do erro

func (BadGatewayError) Error

func (e BadGatewayError) Error() string

Error Retorna um erro code

func (BadGatewayError) ErrorCode

func (e BadGatewayError) ErrorCode() string

ErrorCode Retorna um erro code

type BankNumber

type BankNumber int

BankNumber número de identificação do banco

func (BankNumber) GetBoletoBankNumberAndDigit

func (b BankNumber) GetBoletoBankNumberAndDigit() string

GetBoletoBankNumberAndDigit Retorna o numero da conta do banco do boleto

func (BankNumber) IsBankNumberValid

func (b BankNumber) IsBankNumberValid() bool

IsBankNumberValid verifica se o banco enviado existe

type BoletoRequest

type BoletoRequest struct {
	Authentication Authentication  `json:"authentication"`
	Agreement      Agreement       `json:"agreement"`
	Title          Title           `json:"title"`
	Recipient      Recipient       `json:"recipient"`
	PayeeGuarantor *PayeeGuarantor `json:"payeeGuarantor,omitempty"`
	Buyer          Buyer           `json:"buyer"`
	BankNumber     BankNumber      `json:"bankNumber"`
	RequestKey     string          `json:"requestKey,omitempty"`
}

BoletoRequest entidade de entrada para o boleto

func (BoletoRequest) HasPayeeGuarantor

func (b BoletoRequest) HasPayeeGuarantor() bool

HasPayeeGuarantor verify if PayeeGuarantor is not nil

func (BoletoRequest) MaskBoletoRequest

func (b BoletoRequest) MaskBoletoRequest() BoletoRequest

MaskBoletoRequest Retorna um BoletoRequest com os campos sensiveis mascarados

type BoletoResponse

type BoletoResponse struct {
	StatusCode    int    `json:"-"`
	Errors        Errors `json:"errors,omitempty"`
	ID            string `json:"id,omitempty"`
	DigitableLine string `json:"digitableLine,omitempty"`
	BarCodeNumber string `json:"barCodeNumber,omitempty"`
	OurNumber     string `json:"ourNumber,omitempty"`
	Links         []Link `json:"links,omitempty"`
}

BoletoResponse entidade de saída para o boleto

func ErrorResponseToClient

func ErrorResponseToClient() BoletoResponse

func GetBoletoResponseError

func GetBoletoResponseError(code, message string) BoletoResponse

GetBoletoResponseError Retorna um BoletoResponse com um erro específico

func (*BoletoResponse) HasErrors

func (b *BoletoResponse) HasErrors() bool

HasErrors verify if Response has any error

type BoletoView

type BoletoView struct {
	ID            primitive.ObjectID `bson:"_id,omitempty"`
	UID           string             `json:"uid,omitempty"`
	SecretKey     string             `json:"secretkey,omitempty"`
	PublicKey     string             `json:"publickey,omitempty"`
	Format        string             `json:"format,omitempty"`
	Boleto        BoletoRequest      `json:"boleto,omitempty"`
	BankID        BankNumber         `json:"bankId,omitempty"`
	CreateDate    time.Time          `json:"createDate,omitempty"`
	BankNumber    string             `json:"bankNumber,omitempty"`
	DigitableLine string             `json:"digitableLine,omitempty"`
	OurNumber     string             `json:"ourNumber,omitempty"`
	Barcode       string             `json:"barcode,omitempty"`
	Barcode64     string             `json:"barcode64,omitempty"`
	Links         []Link             `json:"links,omitempty"`
}

BoletoView contem as informações que serão preenchidas no boleto

func NewBoletoView

func NewBoletoView(boleto BoletoRequest, response BoletoResponse, bankName string) BoletoView

NewBoletoView cria um novo objeto view de boleto a partir de um boleto request, codigo de barras e linha digitavel

func (b *BoletoView) CreateLinks() []Link

CreateLinks cria a lista de links com os formatos suportados

func (*BoletoView) EncodeURL

func (b *BoletoView) EncodeURL(format string) string

EncodeURL tranforma o boleto view na forma que será escrito na url

func (*BoletoView) GeneratePublicKey

func (b *BoletoView) GeneratePublicKey()

GeneratePublicKey Gera a chave pública criptografada para geração da URL do boleto

func (BoletoView) ToJSON

func (b BoletoView) ToJSON() string

ToJSON tranforma o boleto view em json

func (BoletoView) ToMinifyJSON

func (b BoletoView) ToMinifyJSON() string

ToMinifyJSON converte um model BoletoView para um JSON/STRING

type Buyer

type Buyer struct {
	Name     string   `json:"name,omitempty"`
	Email    string   `json:"email,omitempty"`
	Document Document `json:"document,omitempty"`
	Address  Address  `json:"address,omitempty"`
}

Buyer informações de entrada do comprador

func (Buyer) HasAddress

func (b Buyer) HasAddress() bool

HasAddress verify if Adress is not empty

type Credentials

type Credentials struct {
	ID       primitive.ObjectID `bson:"_id,omitempty"`
	UserKey  string
	Username string `bson:"username,omitempty"`
	Password string `bson:"password,omitempty"`
}

Credentials Credenciais para requisição de Registro de Boleto

func NewCredentials

func NewCredentials(k, p string) *Credentials

NewCredentials Cria uma instância de Credential

type Document

type Document struct {
	Type   string `json:"type,omitempty"`
	Number string `json:"number,omitempty"`
}

Document nó com o tipo de documento e número do documento

func (Document) IsCNPJ

func (d Document) IsCNPJ() bool

IsCNPJ diz se o DocumentType é um CNPJ

func (Document) IsCPF

func (d Document) IsCPF() bool

IsCPF diz se o DocumentType é um CPF

func (*Document) ValidateCNPJ

func (d *Document) ValidateCNPJ() error

ValidateCNPJ verifica se é um CNPJ válido

func (*Document) ValidateCPF

func (d *Document) ValidateCPF() error

ValidateCPF verifica se é um CPF válido

type ErrorResponse

type ErrorResponse struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

ErrorResponse objeto de erro

func NewErrorResponse

func NewErrorResponse(code, msg string) ErrorResponse

NewErrorResponse cria um novo objeto de ErrorReponse com código e mensagem

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

func (ErrorResponse) ErrorCode

func (e ErrorResponse) ErrorCode() string

ErrorCode retorna código do erro

type Errors

type Errors []ErrorResponse

Errors coleção de erros

func NewErrorCollection

func NewErrorCollection(errorResponse ErrorResponse) Errors

NewErrorCollection cria nova coleção de erros

func NewErrors

func NewErrors() Errors

NewErrors cria nova coleção de erros vazia

func NewSingleErrorCollection

func NewSingleErrorCollection(code, msg string) Errors

NewSingleErrorCollection cria nova coleção de erros com 1 item

func (*Errors) Append

func (e *Errors) Append(code, message string)

Append adiciona mais um erro na coleção

type Fees

type Fees struct {
	Fine     *Fine     `json:"fine,omitempty"`
	Interest *Interest `json:"interest,omitempty"`
}

func (*Fees) HasFine

func (f *Fees) HasFine() bool

HasFine Verifica se o nó de fine está preenchido

func (*Fees) HasInterest

func (f *Fees) HasInterest() bool

HasInterest Verifica se o nó de interest está preenchido

type Fine

type Fine struct {
	DaysAfterExpirationDate uint    `json:"daysAfterExpirationDate,omitempty"`
	AmountInCents           uint64  `json:"amountInCents,omitempty"`
	PercentageOnTotal       float64 `json:"percentageOnTotal,omitempty"`
}

Fine Representa as informações sobre Multa

func (*Fine) HasAmountInCents

func (fine *Fine) HasAmountInCents() bool

HasAmountInCents Verifica se há AmountInCents

func (*Fine) HasDaysAfterExpirationDate

func (fine *Fine) HasDaysAfterExpirationDate() bool

HasDaysAfterExpirationDate Verifica se há DaysAfterExpirationDate

func (*Fine) HasExclusiveRateValues

func (fine *Fine) HasExclusiveRateValues() bool

HasExclusiveRateValues Verifica se foram informados os valores reverente a multa de forma exclusiva

func (*Fine) HasFine

func (fine *Fine) HasFine() bool

HasFine Verifica algum dado de multa está preenchido

func (*Fine) HasPercentageOnTotal

func (fine *Fine) HasPercentageOnTotal() bool

HasPercentageOnTotal Verifica se há PercentageOnTotal

func (*Fine) Validate

func (fine *Fine) Validate() error

Validate Valida as regras de negócio da struct Fine Caso haja alguma violação retorna o erro caso a regra violada, caso contrário retorna nulo

type FormatError

type FormatError ErrorResponse

FormatError interface para implementar Error

func NewFormatError

func NewFormatError(e string) FormatError

NewFormatError cria um novo objeto de FormatError com descrição do erro

func (FormatError) Error

func (e FormatError) Error() string

Error Retorna um erro code

func (FormatError) ErrorCode

func (e FormatError) ErrorCode() string

ErrorCode Retorna um erro code

type GatewayTimeout

type GatewayTimeout ErrorResponse

GatewayTimeout objeto para erros 404 da aplicação: ex boleto não encontrado

func NewGatewayTimeout

func NewGatewayTimeout(code, msg string) GatewayTimeout

NewGatewayTimeout cria um novo objeto NewGatewayTimeout a partir de uma mensagem original e final

func (GatewayTimeout) Error

func (e GatewayTimeout) Error() string

Error Error

func (GatewayTimeout) ErrorCode

func (e GatewayTimeout) ErrorCode() string

ErrorCode ErrorCode

type GetBoletoResult

type GetBoletoResult struct {
	Id                                string
	Format                            string
	PublicKey                         string
	URI                               string
	BoletoSource                      string
	TotalElapsedTimeInMilliseconds    int64
	CacheElapsedTimeInMilliseconds    int64
	DatabaseElapsedTimeInMilliseconds int64
	ErrorResponse                     BoletoResponse
	LogSeverity                       string
}

GetBoletoResult Centraliza as informações da operação GetBoleto

func NewGetBoletoResult

func NewGetBoletoResult(c *gin.Context) *GetBoletoResult

func (*GetBoletoResult) HasValidParameters

func (g *GetBoletoResult) HasValidParameters() bool

func (*GetBoletoResult) SetErrorResponse

func (g *GetBoletoResult) SetErrorResponse(c *gin.Context, err ErrorResponse, statusCode int)

SetErrorResponse Insere as informações de erro para resposta

type HttpNotFound

type HttpNotFound ErrorResponse

HttpNotFound interface para implementar Error

func NewHTTPNotFound

func NewHTTPNotFound(code, msg string) HttpNotFound

NewHTTPNotFound cria um novo objeto NewHttpNotFound a partir de uma mensagem original e final

func (HttpNotFound) Error

func (e HttpNotFound) Error() string

Error retorna o erro original

func (HttpNotFound) ErrorCode

func (e HttpNotFound) ErrorCode() string

ErrorCode Message retorna a mensagem final para o usuário

type IErrorResponse

type IErrorResponse interface {
	Error() string
	ErrorCode() string
}

IErrorResponse interface para implementar Error

type Interest

type Interest struct {
	DaysAfterExpirationDate uint    `json:"daysAfterExpirationDate,omitempty"`
	AmountPerDayInCents     uint64  `json:"amountPerDayInCents,omitempty"`
	PercentagePerMonth      float64 `json:"percentagePerMonth,omitempty"`
}

Interest Representa as informações sobre juros

func (*Interest) HasAmountPerDayInCents

func (interest *Interest) HasAmountPerDayInCents() bool

HasAmountPerDayInCents Verifica se há AmountPerDayInCents

func (*Interest) HasDaysAfterExpirationDate

func (interest *Interest) HasDaysAfterExpirationDate() bool

HasDaysAfterExpirationDate Verifica se há DaysAfterExpirationDate

func (*Interest) HasExclusiveRateValues

func (interest *Interest) HasExclusiveRateValues() bool

HasExclusiveRateValues Verifica se foi informados os valores reverente aos juros de forma exclusiva

func (*Interest) HasInterest

func (interest *Interest) HasInterest() bool

HasInterest Verifica se algum dado de juros está preenchido

func (*Interest) HasPercentagePerMonth

func (interest *Interest) HasPercentagePerMonth() bool

HasPercentagePerMonth Verifica se há PercentagePerMonth

func (*Interest) Validate

func (interest *Interest) Validate() error

Validate Valida as regras de negócio da struct Interest Caso haja alguma violação retorna o erro caso a regra infrigida, caso contrário retorna nulo

type InternalServerError

type InternalServerError ErrorResponse

InternalServerError IServerError interface para implementar Error

func NewInternalServerError

func NewInternalServerError(code, msg string) InternalServerError

NewInternalServerError cria um novo objeto InternalServerError a partir de uma mensagem original e final

func (InternalServerError) Error

func (e InternalServerError) Error() string

Error retorna o erro original

func (InternalServerError) ErrorCode

func (e InternalServerError) ErrorCode() string

ErrorCode Message retorna a mensagem final para o usuário

type Link struct {
	Href   string `json:"href,omitempty"`
	Rel    string `json:"rel,omitempty"`
	Method string `json:"method,omitempty"`
}

Link é um tipo padrão no restfull para satisfazer o HATEOAS

type PayeeGuarantor

type PayeeGuarantor struct {
	Name     string   `json:"name,omitempty"`
	Document Document `json:"document,omitempty"`
}

PayeeGuarantor informações de entrada do lojista(sacador avalista)

func (PayeeGuarantor) HasName

func (p PayeeGuarantor) HasName() bool

HasName diz se o Name está preenchido com algum valor

type Recipient

type Recipient struct {
	Name     string   `json:"name,omitempty"`
	Document Document `json:"document,omitempty"`
	Address  Address  `json:"address,omitempty"`
}

Recipient informações de entrada do comprador

type Rule

type Rule func(interface{}) error

Rule é a regra que será adiciona a camada de validação

type Rules

type Rules struct {
	AcceptDivergentAmount bool `json:"acceptDivergentAmount"`
	MaxDaysToPayPastDue   uint `json:"maxDaysToPayPastDue"`
}

Rules Define regras de pagamento e baixa do título

type Title

type Title struct {
	CreateDate     time.Time `json:"createDate,omitempty"`
	ExpireDateTime time.Time `json:"expireDateTime,omitempty"`
	ExpireDate     string    `json:"expireDate,omitempty"`
	AmountInCents  uint64    `json:"amountInCents,omitempty"`
	OurNumber      uint      `json:"ourNumber,omitempty"`
	Instructions   string    `json:"instructions,omitempty"`
	DocumentNumber string    `json:"documentNumber,omitempty"`
	NSU            string    `json:"nsu,omitempty"`
	BoletoType     string    `json:"boletoType,omitempty"`
	Rules          *Rules    `json:"rules,omitempty"`
	Fees           *Fees     `json:"fees,omitempty"`
	BoletoTypeCode string
}

Title título de cobrança de entrada

func (Title) HasFees

func (t Title) HasFees() bool

HasFees Verifica se o nó de fees está preenchido

func (*Title) HasRules

func (t *Title) HasRules() bool

HasRules Verifica se o nó de rules está preenchido

func (*Title) IsAmountInCentsValid

func (t *Title) IsAmountInCentsValid() error

IsAmountInCentsValid retorna um erro se o valor em centavos for inválido

func (*Title) IsExpireDateValid

func (t *Title) IsExpireDateValid() error

IsExpireDateValid retorna um erro se a data de expiração for inválida

func (*Title) ValidateDocumentNumber

func (t *Title) ValidateDocumentNumber() error

ValidateDocumentNumber número do documento

func (Title) ValidateInstructionsLength

func (t Title) ValidateInstructionsLength(max int) error

ValidateInstructionsLength valida se texto das instruções possui quantidade de caracteres corretos

type Token

type Token struct {
	ClientID    string    `json:"clientid,omitempty"`
	IssuerBank  string    `json:"issuerbank,omitempty"`
	AccessToken string    `json:"accesstoken,omitempty"`
	CreatedAt   time.Time `json:"createdat"`
}

Token represents a token used to access external resources The field CreatedAt is used by Mongo to control token TTL

func NewToken

func NewToken(clientID, issuerbank, token string) Token

Token Creates a Token instance

type Validator

type Validator struct {
	Rules []Rule
}

Validator estrutura de validação

func NewValidator

func NewValidator() *Validator

NewValidator retorna nova instância de validação

func (*Validator) Assert

func (v *Validator) Assert(o interface{}) Errors

Assert aplica todas as validações no objeto passado como parâmetro

func (*Validator) Push

func (v *Validator) Push(r Rule)

Push insere no Validator uma nova regra

Jump to

Keyboard shortcuts

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