handlers

package
v0.0.0-...-05e99d8 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidRequestParams  = "invalid request params"
	ErrInvalidAccountIDParam = "invalid account ID parameter"
	ErrAccountNotFound       = "account not found"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountHandler

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

func NewAccountHandler

func NewAccountHandler(accountService services.AccountService) *AccountHandler

func (*AccountHandler) CreateAccount

func (s *AccountHandler) CreateAccount(c *fiber.Ctx) error

CreateAccount creates a new account. @Summary Create a new account @Description Creates a new account with the provided document number. @Tags accounts @Accept json @Produce json @Param document_number body string true "Document Number" example("12345678900") @Success 201 {object} AccountResponse "account_id and document_number of the created account" @Failure 400 {object} ErrorResponse "Invalid request or account already exists" @Router /accounts [post]

func (*AccountHandler) GetAccount

func (s *AccountHandler) GetAccount(c *fiber.Ctx) error

GetAccount retrieves an account by account ID. @Summary Get an account by ID @Description Retrieves the account details using the account ID. @Tags accounts @Accept json @Produce json @Param id path int true "Account ID" example(1) @Success 200 {object} AccountResponse "account_id and document_number of the retrieved account" @Failure 400 {object} ErrorResponse400 "Invalid accountId provided" @Failure 404 {object} ErrorResponse404 "Account not found" @Router /accounts/{id} [get]

type AccountResponse

type AccountResponse struct {
	AccountID      uint   `json:"account_id" example:"1"`
	DocumentNumber string `json:"document_number" example:"12345678900"`
}

AccountResponse is the response struct for account creation

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error" example:"account with this document number already exists"`
}

ErrorResponse is the response struct for error messages

type ErrorResponse400

type ErrorResponse400 struct {
	Error string `json:"error" example:"invalid accountId provided"`
}

ErrorResponse400 is the response struct for 400 Bad Request errors

type ErrorResponse404

type ErrorResponse404 struct {
	Error string `json:"error" example:"account not found"`
}

ErrorResponse404 is the response struct for 404 Not Found errors

type TransactionHandler

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

func NewTransactionHandler

func NewTransactionHandler(service services.TransactionService) *TransactionHandler

NewTransactionHandler initializes a new transaction handler

func (*TransactionHandler) CreateTransaction

func (s *TransactionHandler) CreateTransaction(c *fiber.Ctx) error

CreateTransaction creates a new transaction. @Summary Create a new transaction @Description Creates a transaction with the provided account ID, operation type ID, and amount. @Tags transactions @Accept json @Produce json @Param transaction body TransactionRequest true "Transaction request" @Success 201 {object} TransactionResponse "transaction_id, account_id, operation_type_id, and amount of the created transaction" @Failure 400 {object} ErrorResponse400 "Invalid request or failed transaction creation" @Router /transactions [post]

type TransactionRequest

type TransactionRequest struct {
	AccountID       uint    `json:"account_id" example:"1"`
	OperationTypeID uint    `json:"operation_type_id" example:"4"`
	Amount          float64 `json:"amount" example:"123.45"`
}

TransactionRequest is the request struct for transaction creation

type TransactionResponse

type TransactionResponse struct {
	TransactionID   uint    `json:"transaction_id" example:"1"`
	AccountID       uint    `json:"account_id" example:"1"`
	OperationTypeID uint    `json:"operation_type_id" example:"4"`
	Amount          float64 `json:"amount" example:"123.45"`
}

TransactionResponse is the response struct for transaction creation

Jump to

Keyboard shortcuts

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