models

package
v0.0.0-...-65f3c3b Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2017 License: MIT Imports: 11 Imported by: 0

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
)
View Source
const LogoBB = `` /* 20775-byte string literal not displayed */
View Source
const LogoCiti = `` /* 5767-byte string literal not displayed */
View Source
const LogoSantander = `` /* 6879-byte string literal not displayed */

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

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 Authentication

type Authentication struct {
	Username           string `json:"username,omitempty"`
	Password           string `json:"password,omitempty"`
	AuthorizationToken string `json:"authenticationToken,omitempty"`
}

Authentication autenticação para entrada na API do banco

type BankNumber

type BankNumber int

BankNumber número de identificação do banco

func (BankNumber) BankName

func (b BankNumber) BankName() string

BankName retorna o nome 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"`
	Buyer          Buyer          `json:"buyer"`
	BankNumber     BankNumber     `json:"bankNumber"`
	RequestKey     string         `json:"requestKey,omitempty"`
}

BoletoRequest entidade de entrada para o boleto

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

type BoletoView

type BoletoView struct {
	ID            string
	UID           string
	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"`
	ConfigBank    ConfigBank    `json:"configBank,omitempty"`
}

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

func NewBoletoView

func NewBoletoView(boleto BoletoRequest, response BoletoResponse) 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) ToJSON

func (b BoletoView) ToJSON() string

ToJSON tranforma o boleto view em json

type Buyer

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

Buyer informações de entrada do comprador

type ConfigBank

type ConfigBank struct {
	EspecieDoc   string
	Aceite       string
	Quantidade   string
	ValorCotacao string
}

func GetConfig

func GetConfig(number BankNumber) ConfigBank

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 FormatError

type FormatError struct {
	Err string
}

FormatError objeto para erros de input no request da API

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

type GatewayTimeout

type GatewayTimeout struct {
	Err string
	Msg string
}

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

func NewGatewayTimeout

func NewGatewayTimeout(err, 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 retorna o erro original

func (GatewayTimeout) Message

func (e GatewayTimeout) Message() string

Message retorna a mensagem final para o usuário

type HttpNotFound

type HttpNotFound struct {
	Err string
	Msg string
}

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

func NewHTTPNotFound

func NewHTTPNotFound(err, 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) Message

func (e HttpNotFound) Message() string

Message retorna a mensagem final para o usuário

type IErrorResponse

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

IErrorResponse interface para implementar Error

type IFormatError

type IFormatError interface {
	Error() string
}

IFormatError interface para implementar Error

type IGatewayTimeout

type IGatewayTimeout interface {
	Error() string
	Message() string
}

IGatewayTimeout interface para timeout

type IHttpNotFound

type IHttpNotFound interface {
	Error() string
	Message() string
}

IHttpNotFound interface para implementar Error

type IServerError

type IServerError interface {
	Error() string
	Message() string
}

IServerError interface para implementar Error

type InternalServerError

type InternalServerError struct {
	Err string
	Msg string
}

InternalServerError objeto para erros internos da aplicação: ex banco de dados

func NewInternalServerError

func NewInternalServerError(err, 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) Message

func (e InternalServerError) Message() string

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 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 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"`
}

Title título de cobrança de entrada

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 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