routes

package
v0.0.0-...-d24a92c Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePayment

func CreatePayment(c *fiber.Ctx) error

Create a new payment godoc @Summary Create a new payment @Description Create a new payment @Tags payments @Accept json @Produce json @Param payment body Payment true "Payment" @Success 200 {object} Payment @Failure 400 {string} string "Something went wrong" @Router /api/payments [post]

func CreateProduct

func CreateProduct(c *fiber.Ctx) error

Create product godoc @Summary Create product @Description Create product @Tags products @Accept json @Produce json @Param product body Product true "Product" @Success 200 {object} Product @Failure 400 {string} string "Product name is required" @Failure 400 {string} string "Product name already taken" @Router /api/products [post]

func CreateUser

func CreateUser(c *fiber.Ctx) error

Create user godoc @Summary Create user @Description Create user @Tags users @Accept json @Produce json @Param user body User true "User" @Success 201 {object} User @Failure 400 {string} string "Invalid request" @Failure 500 {string} string "Error encrypting password" @Router /api/users [post]

func DeletePayment

func DeletePayment(c *fiber.Ctx) error

Delete the payment with the given id godoc @Summary Delete the payment with the given id @Description Delete the payment with the given id @Tags payments @Accept json @Produce json @Param id path int true "Payment ID" @Success 200 {object} Payment @Failure 400 {string} string "Payment not found" @Router /api/payments/{id} [delete]

func DeleteProduct

func DeleteProduct(c *fiber.Ctx) error

Delete product godoc @Summary Delete product @Description Delete product @Tags products @Accept json @Produce json @Param id path int true "Product ID" @Success 200 {string} string "Product deleted" @Failure 400 {string} string "Please ensure that :id is an integer" @Failure 400 {string} string "Product not found" @Router /api/products/{id} [delete]

func DeleteUser

func DeleteUser(c *fiber.Ctx) error

Delete user godoc @Summary Delete user @Description Delete user @Tags users @Accept json @Produce json @Param id path int true "User ID" @Success 200 {string} string "User deleted" @Failure 400 {string} string "Invalid request" @Failure 404 {string} string "User not found" @Router /api/users/{id} [delete]

func GetAllPaymentsByProductId

func GetAllPaymentsByProductId(c *fiber.Ctx) error

func GetPayment

func GetPayment(c *fiber.Ctx) error

Get payment by id godoc @Summary Get payment by id @Description Get payment by id @Tags payments @Accept json @Produce json @Param id path int true "Payment ID" @Success 200 {object} Payment @Failure 400 {string} string "Payment not found" @Router /api/payments/{id} [get]

func GetPaymentByProductId

func GetPaymentByProductId(c *fiber.Ctx) error

func GetPayments

func GetPayments(c *fiber.Ctx) error

Get all payments godoc @Summary Get all payments @Description Get all payments @Tags payments @Accept json @Produce json @Success 200 {object} []Payment @Failure 400 {string} string "Payment not found" @Router /api/payments [get]

func GetProduct

func GetProduct(c *fiber.Ctx) error

Get product by id godoc @Summary Get product by id @Description Get product by id @Tags products @Accept json @Produce json @Param id path int true "Product ID" @Success 200 {object} Product @Failure 400 {string} string "Please ensure that :id is an integer" @Failure 400 {string} string "Product not found" @Router /api/products/{id} [get]

func GetProductId

func GetProductId(id int, product *models.Product) error

func GetProducts

func GetProducts(c *fiber.Ctx) error

Get all products godoc @Summary Get all products @Description Get all products @Tags products @Accept json @Produce json @Success 200 {object} []Product @Failure 400 {string} string "Product not found" @Router /api/products [get]

func GetStream

func GetStream(c *fiber.Ctx) error

func GetUser

func GetUser(c *fiber.Ctx) error

Get user godoc @Summary Get user @Description Get user @Tags users @Accept json @Produce json @Param id path int true "User ID" @Success 200 {object} User @Failure 404 {string} string "User not found" @Router /api/users/{id} [get]

func GetUserId

func GetUserId(id int, user *models.User) error

func GetUsers

func GetUsers(c *fiber.Ctx) error

Get users godoc @Summary Get users @Description Get users @Tags users @Accept json @Produce json @Success 200 {object} User @Failure 404 {string} string "User not found" @Router /api/users [get]

func Login

func Login(c *fiber.Ctx) error

func UpdatePayment

func UpdatePayment(c *fiber.Ctx) error

Update the payment with the given id godoc @Summary Update the payment with the given id @Description Update the payment with the given id @Tags payments @Accept json @Produce json @Param id path int true "Payment ID" @Param payment body Payment true "Payment" @Success 200 {object} Payment @Failure 400 {string} string "Payment not found" @Router /api/payments/{id} [put]

func UpdateProduct

func UpdateProduct(c *fiber.Ctx) error

Update product godoc @Summary Update product @Description Update product @Tags products @Accept json @Produce json @Param id path int true "Product ID" @Param product body Product true "Product" @Success 200 {object} Product @Failure 400 {string} string "Please ensure that :id is an integer" @Failure 400 {string} string "Product not found" @Failure 400 {string} string "Product name already taken" @Router /api/products/{id} [put]

func UpdateUser

func UpdateUser(c *fiber.Ctx) error

Update user godoc @Summary Update user @Description Update user @Tags users @Accept json @Produce json @Param id path int true "User ID" @Param user body User true "User" @Success 200 {object} User @Failure 400 {string} string "Invalid request" @Failure 404 {string} string "User not found" @Failure 500 {string} string "Error encrypting password" @Router /api/users/{id} [put]

Types

type Payment

type Payment struct {
	ID        uint `json:"id"`
	ProductId uint `json:"product_id"`
	Amount    uint `json:"amount"`
}

func CreateResponsePayment

func CreateResponsePayment(payment models.Payment) Payment

func CreateResponsePayments

func CreateResponsePayments(payments []models.Payment) []Payment

type Product

type Product struct {
	ID    uint   `json:"id"`
	Name  string `json:"name"`
	Price uint   `json:"price"`
}

func CreateResponseProduct

func CreateResponseProduct(product models.Product) Product

type Stream

type Stream struct {
	Notifier chan []models.Payment
}

type User

type User struct {
	ID        uint   `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Password  string `json:"password"`
}

func CreateResponseUser

func CreateResponseUser(user models.User) User

Jump to

Keyboard shortcuts

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