api

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeCreateUserRequest added in v0.0.10

func MakeCreateUserRequest(c *gin.Context) (result CreateUserRequest, errors []FieldError)

func MakeCreateUserRequestBody added in v0.0.10

func MakeCreateUserRequestBody(c *gin.Context) (result CreateUserRequestBody, errors []FieldError)

func MakeCreateUserRequestBodyForm added in v0.0.10

func MakeCreateUserRequestBodyForm(c *gin.Context) (result CreateUserRequestBodyForm, errors []FieldError)

func MakeExampleRequest

func MakeExampleRequest(c *gin.Context) (result ExampleRequest, errors []FieldError)

func MakeExampleRequestPath

func MakeExampleRequestPath(c *gin.Context) (result ExampleRequestPath, errors []FieldError)

func MakeExampleRequestQuery

func MakeExampleRequestQuery(c *gin.Context) (result ExampleRequestQuery, errors []FieldError)

func MakeGetFileRequest added in v0.0.10

func MakeGetFileRequest(c *gin.Context) (result GetFileRequest, errors []FieldError)

func MakeGetFileRequestPath added in v0.0.10

func MakeGetFileRequestPath(c *gin.Context) (result GetFileRequestPath, errors []FieldError)

func MakeGetPaymentRequest

func MakeGetPaymentRequest(c *gin.Context) (result GetPaymentRequest, errors []FieldError)

func MakeGetPaymentRequestQuery

func MakeGetPaymentRequestQuery(c *gin.Context) (result GetPaymentRequestQuery, errors []FieldError)

func MakeGetUserRequest added in v0.0.10

func MakeGetUserRequest(c *gin.Context) (result GetUserRequest, errors []FieldError)

func MakeGetUserRequestPath added in v0.0.10

func MakeGetUserRequestPath(c *gin.Context) (result GetUserRequestPath, errors []FieldError)

func MakeProvidePaymentRequest

func MakeProvidePaymentRequest(c *gin.Context) (result ProvidePaymentRequest, errors []FieldError)

func MakeProvidePaymentRequestBody

func MakeProvidePaymentRequestBody(c *gin.Context) (result ProvidePaymentRequestBody, errors []FieldError)

func RegisterRoutes

func RegisterRoutes(r *gin.Engine, api PaymentGatewayAPI)

Router

func RegisterRoutesCustom added in v0.0.13

func RegisterRoutesCustom(handlerRegister HandlerRegister, api PaymentGatewayAPI)

CustomRouter

Types

type ContentType

type ContentType int
const (
	UndefinedContentType ContentType = iota
	AppJSON
	AppXML
	AppFormUrlencoded
	MultipartFormData
	TextPlain
)

type CreateUserRequest added in v0.0.10

type CreateUserRequest struct {
	Body CreateUserRequestBody
}

func (CreateUserRequest) Validate added in v0.0.10

func (t CreateUserRequest) Validate() (errors []FieldError)

type CreateUserRequestBody added in v0.0.10

type CreateUserRequestBody struct {
	Form CreateUserRequestBodyForm
	Type ContentType
}

func (CreateUserRequestBody) Validate added in v0.0.10

func (t CreateUserRequestBody) Validate() (errors []FieldError)

type CreateUserRequestBodyForm added in v0.0.10

type CreateUserRequestBodyForm struct {
	Age    int64
	Avatar *multipart.FileHeader
	Email  string
	Name   string
}

func (CreateUserRequestBodyForm) Validate added in v0.0.10

func (t CreateUserRequestBodyForm) Validate() (errors []FieldError)

type Decimal

type Decimal struct {
	decimal.Decimal
}

func (*Decimal) SetFromString

func (d *Decimal) SetFromString(data string) error

type ExampleRequest

type ExampleRequest struct {
	Path  ExampleRequestPath
	Query ExampleRequestQuery
}

func (ExampleRequest) Validate

func (t ExampleRequest) Validate() (errors []FieldError)

type ExampleRequestPath

type ExampleRequestPath struct {
	User string
	Year int64
}

func (ExampleRequestPath) Validate

func (t ExampleRequestPath) Validate() (errors []FieldError)

type ExampleRequestQuery

type ExampleRequestQuery struct {
	Debug    bool
	From     time.Time
	FromDate time.Time
	Sum      Decimal
	Test     string
	To       time.Time
}

func (ExampleRequestQuery) Validate

func (t ExampleRequestQuery) Validate() (errors []FieldError)

type FieldError

type FieldError struct {
	In      ParamPlace
	Field   string
	Message string
	Reason  error
}

func NewFieldError

func NewFieldError(in ParamPlace, f string, msg string, err error) FieldError

type FromStringSetter

type FromStringSetter interface {
	SetFromString(string) error
}

type GetFileRequest added in v0.0.10

type GetFileRequest struct {
	Path GetFileRequestPath
}

func (GetFileRequest) Validate added in v0.0.10

func (t GetFileRequest) Validate() (errors []FieldError)

type GetFileRequestPath added in v0.0.10

type GetFileRequestPath struct {
	Filename string
}

func (GetFileRequestPath) Validate added in v0.0.10

func (t GetFileRequestPath) Validate() (errors []FieldError)

type GetPaymentRequest

type GetPaymentRequest struct {
	Query GetPaymentRequestQuery
}

func (GetPaymentRequest) Validate

func (t GetPaymentRequest) Validate() (errors []FieldError)

type GetPaymentRequestQuery

type GetPaymentRequestQuery struct {
	Async string
	ID    string
}

func (GetPaymentRequestQuery) Validate

func (t GetPaymentRequestQuery) Validate() (errors []FieldError)

type GetUserRequest added in v0.0.10

type GetUserRequest struct {
	Path GetUserRequestPath
}

func (GetUserRequest) Validate added in v0.0.10

func (t GetUserRequest) Validate() (errors []FieldError)

type GetUserRequestPath added in v0.0.10

type GetUserRequestPath struct {
	UserID string
}

func (GetUserRequestPath) Validate added in v0.0.10

func (t GetUserRequestPath) Validate() (errors []FieldError)

type HandlerRegister added in v0.0.13

type HandlerRegister func(operationID, httpMethod, relativePath string, handler gin.HandlerFunc)

type ID

type ID string

func (ID) Validate added in v0.0.6

func (t ID) Validate() (errors []FieldError)

type ParamPlace

type ParamPlace int
const (
	UndefinedPlace ParamPlace = iota
	InBody
	InCookie
	InFormData
	InHeader
	InPath
	InQuery
)

type Payment

type Payment struct {
	MerchantID string          `json:"merchant_id"`
	Meta       json.RawMessage `json:"meta"`
	PaymentID  ID              `json:"payment_id"`
	Sum        Decimal         `json:"sum"`
	Type       string          `json:"type"`
}

func (Payment) Validate added in v0.0.6

func (t Payment) Validate() (errors []FieldError)

type PaymentGatewayAPI

type PaymentGatewayAPI interface {
	// GET /v1/example/:year/:user
	Example(in ExampleRequest, c *gin.Context)

	// GET /v1/files/:filename
	GetFile(in GetFileRequest, c *gin.Context)

	// GET /v1/payment
	GetPayment(in GetPaymentRequest, c *gin.Context)
	// POST /v1/payment
	ProvidePayment(in ProvidePaymentRequest, c *gin.Context)

	// POST /v1/user
	CreateUser(in CreateUserRequest, c *gin.Context)

	// GET /v1/user/:userId
	GetUser(in GetUserRequest, c *gin.Context)

	// Service methods
	ProcessMakeRequestErrors(c *gin.Context, errors []FieldError)
	ProcessValidateErrors(c *gin.Context, errors []FieldError)
}

func NewPaymentGatewayAPI added in v0.0.10

func NewPaymentGatewayAPI() PaymentGatewayAPI

type PaymentGatewayAPIImpl

type PaymentGatewayAPIImpl struct {
	ProvidedSumTotal int64
	Files            map[string][]byte
	Users            map[ID]User
}

func (*PaymentGatewayAPIImpl) CreateUser added in v0.0.10

func (p *PaymentGatewayAPIImpl) CreateUser(in CreateUserRequest, c *gin.Context)

func (*PaymentGatewayAPIImpl) Example

func (p *PaymentGatewayAPIImpl) Example(in ExampleRequest, c *gin.Context)

func (*PaymentGatewayAPIImpl) GetFile added in v0.0.10

func (p *PaymentGatewayAPIImpl) GetFile(in GetFileRequest, c *gin.Context)

func (*PaymentGatewayAPIImpl) GetPayment

func (p *PaymentGatewayAPIImpl) GetPayment(in GetPaymentRequest, c *gin.Context)

func (PaymentGatewayAPIImpl) GetUser added in v0.0.10

func (p PaymentGatewayAPIImpl) GetUser(in GetUserRequest, c *gin.Context)

func (*PaymentGatewayAPIImpl) ProcessMakeRequestErrors

func (p *PaymentGatewayAPIImpl) ProcessMakeRequestErrors(c *gin.Context, errors []FieldError)

func (*PaymentGatewayAPIImpl) ProcessValidateErrors

func (p *PaymentGatewayAPIImpl) ProcessValidateErrors(c *gin.Context, errors []FieldError)

func (PaymentGatewayAPIImpl) ProvidePayment

func (p PaymentGatewayAPIImpl) ProvidePayment(in ProvidePaymentRequest, c *gin.Context)

type PaymentGatewayAPIServer

type PaymentGatewayAPIServer struct {
	Srv PaymentGatewayAPI
}

type Payments

type Payments []Payment

func (Payments) Validate added in v0.0.6

func (t Payments) Validate() (errors []FieldError)

type ProvidePaymentRequest

type ProvidePaymentRequest struct {
	Body ProvidePaymentRequestBody
}

func (ProvidePaymentRequest) Validate

func (t ProvidePaymentRequest) Validate() (errors []FieldError)

type ProvidePaymentRequestBody

type ProvidePaymentRequestBody struct {
	JSON Payment
	Type ContentType
}

func (ProvidePaymentRequestBody) Validate

func (t ProvidePaymentRequestBody) Validate() (errors []FieldError)

type User added in v0.0.10

type User struct {
	ID        ID     `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	Email     string `json:"email,omitempty"`
	Age       int    `json:"age,omitempty"`
	AvatarURL string `json:"avatar_url,omitempty"`
}

Jump to

Keyboard shortcuts

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