Help us shape the future of Go! Take the 2026 Go Developer Survey

wappa

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiError

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

ApiError implements the error interface and returns infos from the request.

func (*ApiError) Error

func (e *ApiError) Error() string

type Client

type Client struct {

	// Services implemented
	Collaborator *CollaboratorService
	CostCenter   *CostCenterService
	Role         *RoleService
	Unity        *UnityService
	// contains filtered or unexported fields
}

Client is responsible for handling requests to the Wappa API.

func New

func New(host *url.URL, client *http.Client) *Client

Client returns a new Wappa API client with provided host URL and HTTP client.

func (*Client) Request

func (c *Client) Request(ctx context.Context, method string, path endpoint, body, output interface{}) error

Request created an API request. A relative path can be providaded in which case it is resolved relative to the host of the Client.

type Collaborator

type Collaborator struct {
	ID                   int     `json:"IdColaborador,omitempty"`
	Company              int     `json:"Idempresa,omitempty"`
	Association          int     `json:"IdAssociacao,omitempty"`
	CostCenterID         int     `json:"IdCentroCusto,omitempty"`
	UnityID              int     `json:"IdUnidade,omitempty"`
	RoleID               int     `json:"IdCargo,omitempty"`
	Name                 string  `json:"Nome,omitempty"`
	CPF                  string  `json:"Cpf,omitempty"`
	Email                string  `json:"Email,omitempty"`
	Role                 string  `json:"Cargo,omitempty"`
	Enrollment           string  `json:"Matricula,omitempty"`
	Active               bool    `json:"StatusAtivo,omitempty"`
	Blocked              bool    `json:"StatusBloqueado,omitempty"`
	MonthlyTaxiFare      float64 `json:"ValorMensalTaxi,omitempty"`
	MonthlyLimit         string  `json:"LimiteMensal,omitempty"`
	UnlimitedTaxi        bool    `json:"FlgTaxiIlimitado,omitempty"`
	ExtraMonthlyTaxiFare float64 `json:"ValorAcrescimoMensalTaxi,omitempty"`
	AccumulatedTaxiFare  float64 `json:"ValorAcumuladoTaxi,omitempty"`
	AuthorizedFleet      bool    `json:"FlgFrotaAutorizado,omitempty"`
	SendUnblockSMS       bool    `json:"FlgEnviarSmsDesbloqueio,omitempty"`
	CostCenterCode       string  `json:"CodigoCentroCusto,omitempty"`
	CostCenterName       string  `json:"NomeCentroCusto,omitempty"`
	UnityCode            string  `json:"CodigoUnidade,omitempty"`
	UnityName            string  `json:"NomeUnidade,omitempty"`
	ChangedStatusAt      Time    `json:"DataStatus,omitempty"`
	CreatedAt            Time    `json:"DataCadastro,omitempty"`
	ActivatedAt          Time    `json:"DataAtivacao,omitempty"`
	ReactivatedAt        Time    `json:"DataReativacao,omitempty"`
	InactivatedAt        Time    `json:"DataDesativacao,omitempty"`
	BlockedAt            Time    `json:"DataBloqueio,omitempty"`
	PasswordResentAt     Time    `json:"DataReenvioSenha,omitempty"`
	Type                 int     `json:"TipoColaborador,omitempty"`
	Foreign              bool    `json:"Estrangeiro,omitempty"`
	CardExpiration       string  `json:"ValidadeCartao,omitempty"`
	CardFinalDigits      string  `json:"FinalCartao,omitempty"`
	CountryCode          string  `json:"CodPaisNF,omitempty"`
	CountryName          string  `json:"NomePaisNF,omitempty"`
	UnlimitedRides       bool    `json:"QtdCorridasIlimitado,omitempty"`
	AnswerToID           int     `json:"IdRespondePara,omitempty"`
	AnswerToName         string  `json:"NomeRespondePara,omitempty"`
	AnswerToEnrollment   string  `json:"MatriculaRespondePara,omitempty"`
	AppVersion           string  `json:"VersaoApp,omitempty"`
	UserID               int     `json:"IdUsuario,omitempty"`
	DDD                  string  `json:"Ddd,omitempty"`
	Login                string  `json:"Login,omitempty"`
}

Collaborator is the struct representing the collaborator entity in the API.

type CollaboratorResponse

type CollaboratorResponse struct {
	DefaultResponse

	Response []*Collaborator
}

UnitResponse is the API response payload.

type CollaboratorService

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

CollaboratorService is responsible for handling the requests to the collaborator resource.

func (*CollaboratorService) Activate

Activate activates the collaborator in the API.

func (*CollaboratorService) Create

Create creates a collaborator resource in the API.

func (*CollaboratorService) Inactivate

Inactivate inactivates the collaborator in the API.

func (*CollaboratorService) Read

Read returns the CollaboratorResponse for the passed filters.

func (*CollaboratorService) Update

Updated edits the collaborator information.

type CostCenter

type CostCenter struct {
	ID                   int    `json:"IdCentroCusto,omtempty"`
	Name                 string `json:"Nome,omitempty"`
	Code                 string `json:"Codigo,omitempty"`
	ParentCostCenterID   int    `json:"IdCentroCustoSuperior,omitempty"`
	ParentCostCenterCode string `json:"CodigoCCSuperior,omitempty"`
	ParentCostCenterName string `json:"NomeCCSuperior,omitempty"`
	CNPJ                 string `json:"CNPJEmpresaGrupo,omitempty"`
}

CostCenter is the struct representing the cost center entity in the API.

type CostCenterResponse

type CostCenterResponse struct {
	DefaultResponse

	Response []*CostCenter
}

CostCenterResponse is the API response payload.

type CostCenterService

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

CostCenterService is responsible for handling the requests to the cost center resource.

func (*CostCenterService) Create

Create creates a cost center resource in the API.

func (*CostCenterService) Inactivate

func (cs *CostCenterService) Inactivate(ctx context.Context, id int) (*OperationDefaultResponse, error)

Inactivate inactivates the cost center in the API.

func (*CostCenterService) Read

Read returns the CostCenterResponse for the passed filters.

func (*CostCenterService) Update

Updated edits the cost center information.

type DefaultResponse

type DefaultResponse struct {
	Success  bool
	Quantity int `json:"Quantidade,omitempty"`
	Error    ResponseError
	// Returned by the API when error occurs
	Message       string
	MessageDetail string
	// Response of Create, Update and Activate/Inactivate-family operations.
	Response string
}

DefaultResponse contains the basics porperties all requests to the Wappa API returns.

type Filter

type Filter map[string]string

Filter is used to filter the requests to the API.

func (Filter) Values

func (f Filter) Values(fields map[string]string) url.Values

Values returns a url.Values mapped between Filter and values.

type OperationDefaultResponse

type OperationDefaultResponse struct {
	DefaultResponse
}

func (*OperationDefaultResponse) Parse

func (d *OperationDefaultResponse) Parse(body io.Reader) error

Parse implements the Parser interface for reading the request body.

type ResponseError

type ResponseError struct {
	Code    int
	Message int
}

ResponseError contains the default error porperties returnes by the API.

type Role

type Role struct {
	ID          int    `json:"IdCargo,omtempty"`
	Description string `json:"Descricao,omitempty"`
	Filter      string `json:"Filtro,omitempty"`
}

Role is the struct representing the role entity in the API.

type RoleResponse

type RoleResponse struct {
	DefaultResponse

	Response []*Role
}

RoleResponse is the API reading response payload for role entity.

type RoleService

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

RoleService is responsible for handling the requests to the role resource.

func (*RoleService) Create

func (rs *RoleService) Create(ctx context.Context, r *Role) (*DefaultResponse, error)

Create creates a role resource in the API.

func (*RoleService) Read

func (rs *RoleService) Read(ctx context.Context, f Filter) (*RoleResponse, error)

Read returns the RoleResponse for the passed filters.

type Time

type Time struct {
	time.Time
}

Time is a custom time type for unmashaling data from the API.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

type TokenSource

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

TokenSource implements the oauth2.TokenSource interface, in order to reuse the Wappa token.

func NewTokenSource

func NewTokenSource(ctx context.Context, host, clientID, clientSecret, username, password string) *TokenSource

NewTokenSource returns a oauth2.TokenSource for issuing a Wappa token.

The provided context optionally controls which HTTP client is used. See the oauth2.HTTPClient variable. host should be sufixed by '/'.

func (*TokenSource) Token

func (ts *TokenSource) Token() (*oauth2.Token, error)

Token returns a new oauth2.Token or error.

type Unity

type Unity struct {
	ID              int    `json:"IdUnidade,omtempty"`
	CustomerCompany int    `json:"IdEmpresaCliente,omitempty"`
	Code            string `json:"Codigo,omitempty"`
	Name            string `json:"Nome,omitempty"`
	Address         string `json:"Endereco,omitempty"`
	Number          string `json:"Numero,omitempty"`
	Complement      string `json:"Complemento,omitempty"`
	Neighborhood    string `json:"Bairro,omitempty"`
	StateID         string `json:"SiglaUf,omitempty"`
	ZipCode         string `json:"Cep,omitempty"`
	AreaCode        string `json:"Ddd,omitempty"`
	Phone           string `json:"Telefone,omitempt"`
	AreaCode2       string `json:"Ddd2,omitempty"`
	Phone2          string `json:"Telefone2,omitempty"`
	CityID          int    `json:"IdCidade,omitempty"`
	City            string `json:"Cidade,omitempty"`
}

Unity is the struct representing the unity entity in the API.

type UnityResponse

type UnityResponse struct {
	DefaultResponse

	Response []*Unity
}

UnitResponse is the API response payload.

type UnityService

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

UnityService is responsible for handling the requests to the unity resource.

func (*UnityService) Create

func (us *UnityService) Create(ctx context.Context, u *Unity) (*DefaultResponse, error)

Create creates a unity resource in the API.

func (*UnityService) Inactivate

func (us *UnityService) Inactivate(ctx context.Context, id int) (*OperationDefaultResponse, error)

Inactivate inactivates the unity in the API.

func (*UnityService) Read

func (us *UnityService) Read(ctx context.Context, f Filter) (*UnityResponse, error)

Read returns the UnityResponse for the passed filters.

func (*UnityService) Update

Updated edits the unity information.

Jump to

Keyboard shortcuts

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