forked from ebhomengo/niki
1
0
Fork 0

Compare commits

..

19 Commits

Author SHA1 Message Date
Reza Mobaraki 92720e143f
add benefactor kind box tests
Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-09-02 21:55:16 +03:30
Reza Mobaraki a43e973b01
fix
Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-28 01:57:16 +03:30
Reza Mobaraki 73af8d30f9
add all test in one branch
Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-28 01:53:01 +03:30
Reza Mobaraki 096b4dbf69
Merge branch 'stage/rezoo/e2e-test/benefator-address' into stage/rezoo/e2e-test/benefactor-kind-box-req 2024-08-28 00:28:06 +03:30
Reza Mobaraki 7c1d93e1da
Chore(e2e.benefactor-address-test): all tests are applied
resolve #138

Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-26 17:02:26 +03:30
Reza Mobaraki 68d6aebb3b
Fix(e2e.benefactor-address-test): fix isolation
Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-26 16:58:55 +03:30
Reza Mobaraki d8bf950a89
Chore(e2e.benefactor-address-test): some changes
Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-26 16:42:54 +03:30
Reza Mobaraki 17d3502854
Chore(e2e.benefactor-address-test): add tests added
Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-26 16:29:53 +03:30
Reza Mobaraki c58cc2789a
Chore(e2e.benefactor-address-test): add base
Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-26 00:43:45 +03:30
Reza Mobaraki 99f710c41d
Fix(benefactor-kindBoxReqs-test): delete test assertion
Addressed #140

Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-24 14:29:46 +03:30
Reza Mobaraki 38677a0128
Refactor(benefactor-kindBoxReqs-test): use more feature of suit
Addressed #140

Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-24 14:11:08 +03:30
Reza Mobaraki ceab112d0e
Refactor(benefactor-kindBoxReqs-test): use more feature of suit
Addressed #140

Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-24 14:03:16 +03:30
Reza Mobaraki 79b054e09f
Refactor(benefactor-kindBoxReqs-test): move data to setupTest
Addressed #140

Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-24 13:46:44 +03:30
Reza Mobaraki ae4854070c
Merge branch 'develop' into stage/rezoo/benefactor/test-e2e-kind-box-req 2024-08-24 12:21:01 +03:30
Reza Mobaraki 1c3156fe3a
Chore(benefactor-kindBoxReqs-test): add testify/suit in order to handle
Resolves #140

Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-23 19:14:54 +03:30
Reza Mobaraki b132249ffc
Chore(benefactor-kindBoxReqs-test): add testify/suit in order to handle
- test Update benefactorKindBoxReqs

Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-23 19:05:30 +03:30
Reza Mobaraki 15f37001db
Chore(benefactor-kindBoxReqs-test): make it cleaner
Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-23 17:58:44 +03:30
Reza Mobaraki 6c78c8098a
Chore(benefactor-kindBoxReqs-test): add tests
- Get_Success
- GetAll_Success
- Create_Success

Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-23 15:54:27 +03:30
Reza Mobaraki 16f37c0f64
Chore(MakeFile): add .PHONY
Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
2024-08-22 18:32:36 +03:30
1945 changed files with 4966 additions and 578004 deletions

2
.gitignore vendored
View File

@ -18,9 +18,9 @@ activate.mise.toml
*.out
# Dependency directories (remove the comment below to include it)
vendor/
.idea
bin
tmp
#.env
*.env

View File

@ -1,29 +1,37 @@
# Build Stage
FROM golang:1.23.0-alpine AS builder
# First pull Golang image
FROM golang:1.21.3-alpine as builder
# Set environment variable
ENV APP_NAME niki
ENV CMD_PATH main.go
# Add a work directory
WORKDIR /$APP_NAME
## Cache and install dependencies
#COPY go.mod go.sum ./
#RUN go mod download
# Copy app files
COPY . .
# Budild application
RUN CGO_ENABLED=0 go build -mod=vendor -v -o $APP_NAME .
RUN CGO_ENABLED=0 go build -mod=mod -v -o $APP_NAME .
# Run Stage
FROM alpine:3.20 AS runtime
# Copy the binary from the builder stage
COPY --from=builder /niki/niki .
# Copy migration files
COPY --from=builder /niki/repository/mysql/migration ./repository/mysql/migration
FROM alpine:3.18 as development
# Set environment variable
ENV APP_NAME niki
# Copy only required data into this image
COPY --from=builder /$APP_NAME .
# Expose application port
EXPOSE 8313
# Start the application
CMD ["./niki", "--migrate"]
EXPOSE 1313
# Start app
CMD ./$APP_NAME

View File

@ -1,7 +1,9 @@
// TODO: add commands for build and run in dev/produciton mode
# TODO: add commands for build and run in dev/produciton mode
ROOT=$(realpath $(dir $(lastword $(MAKEFILE_LIST))))
.PHONY: help confirm lint test format build run docker swagger watch migrate/status migrate/new migrate/up migrate/down
confirm:
@echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ]
@ -16,7 +18,7 @@ format:
@which gofumpt || (go install mvdan.cc/gofumpt@latest)
@gofumpt -l -w $(ROOT)
@which gci || (go install github.com/daixiang0/gci@latest)
@gci write $(ROOT) --skip-generated --skip-vendor
@gci write $(ROOT)
@which golangci-lint || (go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.0)
@golangci-lint run --fix

View File

@ -20,6 +20,10 @@ redis:
password: ""
db: 0
sms_provider:
host: localhost
port: 443
benefactor_service:
length_of_otp_code: 5

View File

@ -10,12 +10,7 @@ import (
)
type HTTPServer struct {
Port int `koanf:"port"`
Cors Cors `koanf:"cors"`
}
type Cors struct {
AllowOrigins []string `koanf:"allow_origins"`
Port int `koanf:"port"`
}
type Config struct {

View File

@ -10,7 +10,7 @@ import (
// LoginByPhoneNumber godoc
// @Summary Admin login by PhoneNumber
// @Tags Admins
// @Tags Admin
// @Accept json
// @Produce json
// @Param Request body adminserviceparam.LoginWithPhoneNumberRequest true "Admin login request body"

View File

@ -1,37 +0,0 @@
package adminhandler
import (
adminserviceparam "git.gocasts.ir/ebhomengo/niki/param/admin/admin"
"net/http"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
"github.com/labstack/echo/v4"
)
// RefreshAccess godoc
// @Summary Get a new access token by providing a refresh token
// @Tags Admins
// @Accept json
// @Produce json
// @Param Request body adminserviceparam.RefreshAccessRequest true "Refresh access request body"
// @Success 200 {object} adminserviceparam.RefreshAccessResponse
// @Failure 400 {string} "Bad Request"
// @Failure 422 {string} "invalid or expired jwt"
// @Failure 500 {string} "something went wrong"
// @Router /admins/refresh-access [post].
func (h Handler) RefreshAccess(c echo.Context) error {
var req adminserviceparam.RefreshAccessRequest
if err := c.Bind(&req); err != nil {
return echo.NewHTTPError(http.StatusBadRequest)
}
resp, err := h.adminSvc.RefreshAccess(c.Request().Context(), req)
if err != nil {
msg, code := httpmsg.Error(err)
return echo.NewHTTPError(code, msg)
}
return c.JSON(http.StatusOK, resp)
}

View File

@ -10,7 +10,7 @@ import (
// Register godoc
// @Summary Register an admin by super-admin
// @Tags Admins
// @Tags Admin
// @Accept json
// @Produce json
// @Param Request body adminserviceparam.RegisterRequest true "Admin Register Request Body"

View File

@ -13,7 +13,6 @@ func (h Handler) SetRoutes(e *echo.Echo) {
//r.POST("/", h.Add).Name = "admin-addkindboxreq"
r.POST("/register", h.Register, middleware.Auth(h.authSvc), middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminAdminRegisterPermission))
r.POST("/login-by-phone", h.LoginByPhoneNumber)
r.POST("/refresh-access", h.RefreshAccess)
//nolint:gocritic
//r.PATCH("/:id", h.Update).Name = "admin-updatekindboxreq"
}

View File

@ -10,7 +10,7 @@ import (
// GetAllAgent godoc
// @Summary Get all agents by admin
// @Tags Admins
// @Tags Admin
// @Accept json
// @Produce json
// @Success 200 {object} adminagentparam.GetAllAgentResponse

View File

@ -11,7 +11,7 @@ import (
// AssignReceiverAgent godoc
// @Summary Admin assign receiver agent to kindbox
// @Tags Admins KindBoxes
// @Tags KindBox
// @Accept json
// @Produce json
// @Param id path int true "KindBox ID"
@ -19,7 +19,7 @@ import (
// @Success 204
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /admins/kindboxes/{id}/assign-receiver-agent [patch].
// @Router /admin/kindboxes/assign-receiver-agent/{id} [patch].
func (h Handler) AssignReceiverAgent(c echo.Context) error {
var req param.AssignReceiverRequest

View File

@ -11,7 +11,7 @@ import (
// Enumerate godoc
// @Summary Admin enumerate kindbox
// @Tags Admins KindBoxes
// @Tags KindBox
// @Accept json
// @Produce json
// @Param id path int true "KindBox ID"
@ -23,7 +23,7 @@ import (
// @Failure 422 {object} httpmsg.ErrorResponse
// @Failure 500 {string} "something went wrong"
// @Security AuthBearerAdmin
// @Router /admins/kindboxes/{id}/enumerate [patch].
// @Router /admin/kindboxes/{id}/enumerate [patch].
func (h Handler) Enumerate(c echo.Context) error {
var req param.EnumerateKindBoxRequest

View File

@ -11,14 +11,14 @@ import (
// Get godoc
// @Summary Get a specific kind box by admin
// @Description This endpoint retrieves a specific kind box by admin
// @Tags Admins KindBoxes
// @Tags KindBox
// @Accept json
// @Produce json
// @Param id path int true "Kind box ID"
// @Success 200 {object} param.KindBoxGetResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /admins/kindboxes/{id} [get].
// @Router /admin/kindboxes/{id} [get].
func (h Handler) Get(c echo.Context) error {
var req param.KindBoxGetRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -12,7 +12,7 @@ import (
// GetAll godoc
// @Summary Get all KindBoxes by admin
// @Description Retrieves a list of all KindBoxes with filtering, sorting, and pagination options
// @Tags Admins KindBoxes
// @Tags KindBox
// @Accept json
// @Produce json
// @Param filter_id query int false "Filter by ID"
@ -39,7 +39,7 @@ import (
// @Success 200 {object} param.KindBoxGetAllResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /admins/kindboxes [get].
// @Router /admin/kindboxes [get].
func (h Handler) GetAll(c echo.Context) error {
var req param.KindBoxGetAllRequest

View File

@ -7,13 +7,12 @@ import (
)
func (h Handler) SetRoutes(e *echo.Echo) {
r := e.Group("/admins/kindboxes")
r := e.Group("/admin/kindboxes")
r.Use(middleware.Auth(h.authSvc))
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetPermission))
r.PATCH("/:id/assign-receiver-agent", h.AssignReceiverAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxAssignReceiverAgentPermission))
r.PATCH("/assign-receiver-agent/:id", h.AssignReceiverAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxAssignReceiverAgentPermission))
r.GET("", h.GetAll, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetAllPermission))
r.PATCH("/:id/enumerate", h.Enumerate, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxEnumeratePermission))
r.PUT("/update/:id", h.Update, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxUpdatePermission))
}

View File

@ -1,50 +0,0 @@
package adminkindboxhandler
import (
"net/http"
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
"github.com/labstack/echo/v4"
)
// Update godoc
// @Summary Update kind Box by admin
// @Tags Admins KindBoxes
// @Accept json
// @Produce json
// @Param id path int true "Kind Box ID"
// @Param Request body param.KindBoxUpdateRequest true "Update KindBox Request Body"
// @Success 204
// @Failure 400 {string} "Bad Request"
// @Failure 401 {string} "invalid or expired jwt"
// @Failure 403 {string} "user not allowed"
// @Failure 422 {object} httpmsg.ErrorResponse
// @Failure 500 {string} "something went wrong"
// @Security AuthBearerAdmin
// @Router /admins/kindboxes/update/{id} [put].
func (h Handler) Update(c echo.Context) error {
var req param.KindBoxUpdateRequest
if bErr := c.Bind(&req); bErr != nil {
return c.JSON(http.StatusBadRequest, httpmsg.ErrorResponse{
Message: "Invalid request body",
})
}
resp, sErr := h.adminKindBoxSvc.Update(c.Request().Context(), req)
if sErr != nil {
msg, code := httpmsg.Error(sErr)
if resp.FieldErrors != nil {
return c.JSON(code, echo.Map{
"message": msg,
"errors": resp.FieldErrors,
})
}
return echo.NewHTTPError(code, msg)
}
return c.JSON(http.StatusNoContent, nil)
}

View File

@ -13,7 +13,7 @@ import (
// Accept godoc
// @Summary Accept kind box request by admin
// @Tags Admins KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "KindBoxReq ID"
@ -21,7 +21,7 @@ import (
// @Success 200 {object} param.KindBoxReqAcceptResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /admins/kindboxreqs/{id}/accept-kind-box-req [patch].
// @Router /admin/kindboxreqs/accept-kind-box-req/{id} [patch].
func (h Handler) Accept(c echo.Context) error {
var req param.KindBoxReqAcceptRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -11,14 +11,14 @@ import (
// AddKindBoxReq godoc
// @Summary Add a new kind box request for a benefactor by admin
// @Tags Admins KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param Request body param.KindBoxReqAddRequest true "New kind box request details"
// @Success 200 {object} param.KindBoxReqAddResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /admins/kindboxreqs [post].
// @Router /admin/kindboxreqs [post].
func (h Handler) AddKindBoxReq(c echo.Context) error {
req := param.KindBoxReqAddRequest{}
if err := c.Bind(&req); err != nil {

View File

@ -13,7 +13,7 @@ import (
// AssignSenderAgent godoc
// @Summary Admin Assign Sender Agent to kindboxreq
// @Tags Admins KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "KindBoxReq ID"
@ -21,7 +21,7 @@ import (
// @Success 200 {object} param.AssignSenderResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /admins/kindboxreqs/{id}/assign-sender-agent [patch].
// @Router /admin/kindboxreqs/assign-sender-agent/{id} [patch].
func (h Handler) AssignSenderAgent(c echo.Context) error {
var req param.AssignSenderRequest

View File

@ -1,11 +1,10 @@
package agentkindboxreqhandler
package adminkindboxreqhandler
import (
"context"
params "git.gocasts.ir/ebhomengo/niki/param"
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
"net/http"
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
querier "git.gocasts.ir/ebhomengo/niki/pkg/query_transaction/sql"
@ -13,8 +12,8 @@ import (
)
// Deliver godoc
// @Summary Agent deliver a kindboxreq
// @Tags Agents KindBoxReqs
// @Summary Admin deliver a kindboxreq
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "KindBoxReq ID"
@ -22,7 +21,7 @@ import (
// @Success 200 {object} param.DeliverKindBoxReqResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /agents/kindboxreqs/{id}/deliver-kind-box-req [patch].
// @Router /admin/kindboxreqs/deliver-kind-box-req/{id} [patch].
func (h Handler) Deliver(c echo.Context) error {
var req param.DeliverKindBoxReqRequest
@ -32,7 +31,7 @@ func (h Handler) Deliver(c echo.Context) error {
q := querier.GetQuerierFromContextOrNew(c.Request().Context()).Begin()
ctx := context.WithValue(c.Request().Context(), querier.QuerierContextKey, q)
resp, sErr := h.agentKindBoxReqSvc.Deliver(ctx, req)
resp, sErr := h.adminKindBoxReqSvc.Deliver(ctx, req)
if sErr != nil {
msg, code := httpmsg.Error(sErr)
if resp.FieldErrors != nil {
@ -53,9 +52,5 @@ func (h Handler) Deliver(c echo.Context) error {
return echo.NewHTTPError(http.StatusInternalServerError, errmsg.ErrorMsgSomethingWentWrong)
}
go h.notificationSvc.KindBoxReqDelivered(params.NotificationKindBoxReqDelivered{
KindBoxReqID: req.KindBoxReqID,
})
return c.JSON(http.StatusOK, resp)
}

View File

@ -10,7 +10,7 @@ import (
// Get godoc
// @Summary Get a specific kind box req by ID
// @Tags Admins KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "KindBoxReq ID"

View File

@ -12,7 +12,7 @@ import (
// GetAll godoc
// @Summary Admin get all kindboxreq
// @Description Retrieves a list of all KindBox requests with filtering, sorting, and pagination options
// @Tags Admins KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param filter_id query int false "Filter by ID"

View File

@ -1,10 +1,10 @@
package agentkindboxreqhandler
package adminkindboxreqhandler
import (
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
"net/http"
"git.gocasts.ir/ebhomengo/niki/entity"
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
queryparam "git.gocasts.ir/ebhomengo/niki/pkg/query_param"
@ -14,7 +14,7 @@ import (
// GetAllAwaitingDelivery godoc
// @Summary Get all awaiting delivery KindBox requests
// @Description Retrieves a list of all awaiting KindBox requests with filtering, sorting, and pagination options
// @Tags Agents KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param filter_id query int false "Filter by ID"
@ -32,7 +32,7 @@ import (
// @Success 200 {object} param.DeliveryAwaitingGetAllResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /agents/kindboxreqs/awaiting-delivery [get].
// @Router /admin/kindboxreqs/awaiting-delivery [get].
func (h Handler) GetAllAwaitingDelivery(c echo.Context) error {
var req param.DeliveryAwaitingGetAllRequest
@ -42,7 +42,7 @@ func (h Handler) GetAllAwaitingDelivery(c echo.Context) error {
req.Filter = queryparam.GetFilterParams(c)
req.Filter["sender_agent_id"] = claim.GetClaimsFromEchoContext(c).UserID
req.Filter["status"] = entity.KindBoxReqAssignedSenderAgentStatus
resp, sErr := h.agentKindBoxReqSvc.GetAllAwaitingDelivery(c.Request().Context(), req)
resp, sErr := h.adminKindBoxReqSvc.GetAllAwaitingDelivery(c.Request().Context(), req)
if sErr != nil {
msg, code := httpmsg.Error(sErr)
if resp.FieldErrors != nil {

View File

@ -1,9 +1,9 @@
package agentkindboxreqhandler
package adminkindboxreqhandler
import (
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
"net/http"
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
"github.com/labstack/echo/v4"
@ -11,14 +11,14 @@ import (
// GetAwaitingDelivery godoc
// @Summary Get a kind box reqs that is awaiting delivery by agent
// @Tags Agents KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "KindBoxReq ID"
// @Success 200 {object} param.DeliveryAwaitingGetResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /agents/kindboxreqs/awaiting-delivery/{id} [get].
// @Router /admin/kindboxreqs/awaiting-delivery/{id} [get].
func (h Handler) GetAwaitingDelivery(c echo.Context) error {
var req param.DeliveryAwaitingGetRequest
if bErr := c.Bind(&req); bErr != nil {
@ -28,7 +28,7 @@ func (h Handler) GetAwaitingDelivery(c echo.Context) error {
claims := claim.GetClaimsFromEchoContext(c)
req.AgentID = claims.UserID
resp, sErr := h.agentKindBoxReqSvc.GetAwaitingDelivery(c.Request().Context(), req)
resp, sErr := h.adminKindBoxReqSvc.GetAwaitingDelivery(c.Request().Context(), req)
if sErr != nil {
msg, code := httpmsg.Error(sErr)
if resp.FieldErrors != nil {

View File

@ -13,7 +13,7 @@ import (
// Reject godoc
// @Summary Reject a kindboxreq by admin
// @Tags Admins KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "KindBoxReq id"
@ -21,7 +21,7 @@ import (
// @Success 200 {object} param.KindBoxReqRejectResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /admins/kindboxreqs/{id}/reject-kind-box-req [patch].
// @Router /admin/kindboxreqs/reject-kind-box-req/{id} [patch].
func (h Handler) Reject(c echo.Context) error {
var req param.KindBoxReqRejectRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -11,10 +11,13 @@ func (h Handler) SetRoutes(e *echo.Echo) {
r.Use(middleware.Auth(h.authSvc))
r.POST("", h.AddKindBoxReq, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAddPermission))
r.PATCH("/:id/accept-kind-box-req", h.Accept, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAcceptPermission))
r.PATCH("/:id/reject-kind-box-req", h.Reject, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqRejectPermission))
r.PATCH("/:id/assign-sender-agent", h.AssignSenderAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAssignSenderAgentPermission))
r.PATCH("/accept-kind-box-req/:id", h.Accept, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAcceptPermission))
r.PATCH("/reject-kind-box-req/:id", h.Reject, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqRejectPermission))
r.PATCH("/deliver-kind-box-req/:id", h.Deliver, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqDeliverPermission))
r.PATCH("/assign-sender-agent/:id", h.AssignSenderAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAssignSenderAgentPermission))
r.GET("", h.GetAll, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAllPermission))
r.GET("/awaiting-delivery/:id", h.GetAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
r.GET("/awaiting-delivery", h.GetAllAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
r.PUT("/:id", h.Update, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqUpdatePermission))
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetPermission))
}

View File

@ -10,7 +10,7 @@ import (
// Update godoc
// @Summary Update kind box request by admin
// @Tags Admins KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "KindBoxReq ID"
@ -18,7 +18,7 @@ import (
// @Success 204
// @Failure 400 {string} "Bad request"
// @Security AuthBearerAdmin
// @Router /admins/kindboxreqs/{id} [put].
// @Router /admin/kindboxreqs/{id} [put].
func (h Handler) Update(c echo.Context) error {
var req param.KindBoxReqUpdateRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -11,7 +11,7 @@ import (
// Get godoc
// @Summary Get a kind box that is awaiting return by agent
// @Tags Agents KindBoxes
// @Tags KindBox
// @Accept json
// @Produce json
// @Param id path int true "KindBox ID"

View File

@ -14,7 +14,7 @@ import (
// GetAll godoc
// @Summary Get all awaiting return KindBoxes by agent
// @Description Retrieves a list of all awaiting return KindBoxes for agent with filtering, sorting, and pagination options
// @Tags Agents KindBoxes
// @Tags KindBox
// @Accept json
// @Produce json
// @Param filter_id query int false "Filter by ID"

View File

@ -4,25 +4,21 @@ import (
adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
agentkindboxservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box"
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
"git.gocasts.ir/ebhomengo/niki/service/notification"
)
type Handler struct {
authSvc authservice.Service
agentKindBoxSvc agentkindboxservice.Service
adminAuthorizeSvc adminauthorizationservice.Service
notificationSvc notification.Service
}
func New(authSvc authservice.Service,
agentKindBoxSvc agentkindboxservice.Service,
adminAuthorizeSvc adminauthorizationservice.Service,
notificationSvc notification.Service,
) Handler {
return Handler{
authSvc: authSvc,
agentKindBoxSvc: agentKindBoxSvc,
adminAuthorizeSvc: adminAuthorizeSvc,
notificationSvc: notificationSvc,
}
}

View File

@ -3,7 +3,6 @@ package agentkindboxhandler
import (
"net/http"
params "git.gocasts.ir/ebhomengo/niki/param"
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box"
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
@ -12,7 +11,7 @@ import (
// Return godoc
// @Summary Return KindBox from benefactor by agent
// @Tags Agents KindBoxes
// @Tags KindBox
// @Accept json
// @Produce json
// @Param id path int true "KindBox ID"
@ -24,7 +23,7 @@ import (
// @Failure 422 {object} httpmsg.ErrorResponse
// @Failure 500 {string} "something went wrong"
// @Security AuthBearerAdmin
// @Router /agents/kindboxes/{id}/return [patch].
// @Router /agents/kindboxes/return/{id} [patch].
func (h Handler) Return(c echo.Context) error {
var req param.ReturnKindBoxRequest
if err := c.Bind(&req); err != nil {
@ -47,9 +46,5 @@ func (h Handler) Return(c echo.Context) error {
return echo.NewHTTPError(code, msg)
}
go h.notificationSvc.KindBoxReturned(params.NotificationKindBoxReturned{
KindBoxID: req.KindBoxID,
})
return c.NoContent(http.StatusNoContent)
}

View File

@ -13,5 +13,5 @@ func (h Handler) SetRoutes(e *echo.Echo) {
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetAwaitingReturnPermission))
r.GET("", h.GetAll, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetAwaitingReturnPermission))
r.PATCH("/:id/return", h.Return, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReturnPermission))
r.PATCH("/return/:id", h.Return, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReturnPermission))
}

View File

@ -1,28 +0,0 @@
package agentkindboxreqhandler
import (
adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
agentkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box_req"
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
"git.gocasts.ir/ebhomengo/niki/service/notification"
)
type Handler struct {
authSvc authservice.Service
agentKindBoxReqSvc agentkindboxreqservice.Service
adminAuthorizeSvc adminauthorizationservice.Service
notificationSvc notification.Service
}
func New(authSvc authservice.Service,
agentKindBoxReqSvc agentkindboxreqservice.Service,
adminAuthorizeSvc adminauthorizationservice.Service,
notificationSvc notification.Service,
) Handler {
return Handler{
authSvc: authSvc,
agentKindBoxReqSvc: agentKindBoxReqSvc,
adminAuthorizeSvc: adminAuthorizeSvc,
notificationSvc: notificationSvc,
}
}

View File

@ -1,16 +0,0 @@
package agentkindboxreqhandler
import (
"git.gocasts.ir/ebhomengo/niki/delivery/http_server/middleware"
"git.gocasts.ir/ebhomengo/niki/entity"
"github.com/labstack/echo/v4"
)
func (h Handler) SetRoutes(e *echo.Echo) {
r := e.Group("/agents/kindboxreqs")
r.Use(middleware.Auth(h.authSvc))
r.GET("/awaiting-delivery/:id", h.GetAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
r.GET("/awaiting-delivery", h.GetAllAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
r.PATCH("/:id/deliver-kind-box-req", h.Deliver, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqDeliverPermission))
}

View File

@ -12,14 +12,14 @@ import (
// AddAddress godoc
// @Summary Add a new address for a benefactor
// @Description This endpoint allows an authenticated benefactor to add a new address to their account.
// @Tags Benefactors Addresses
// @Tags Address
// @Accept json
// @Produce json
// @Param Request body param.BenefactorAddAddressRequest true "New address details"
// @Success 201 {object} param.BenefactorAddAddressResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/addresses [post].
// @Security AuthBearerBenefactor
// @Router /address/ [post].
func (h Handler) AddAddress(c echo.Context) error {
req := param.BenefactorAddAddressRequest{}
if bErr := c.Bind(&req); bErr != nil {

View File

@ -12,12 +12,12 @@ import (
// DeleteAddress godoc
// @Summary Delete address by benefactor
// @Description This endpoint is used to delete an address by benefactor
// @Tags Benefactors Addresses
// @Tags Address
// @Param id path int true "Address ID"
// @Success 204
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/addresses/{id} [delete].
// @Router /address/{id} [delete].
func (h Handler) DeleteAddress(c echo.Context) error {
var req param.DeleteAddressRequest

View File

@ -11,14 +11,14 @@ import (
// GetAddress godoc
// @Summary Get a benefactor address
// @Tags Benefactors Addresses
// @Tags Address
// @Accept json
// @Produce json
// @Param id path int true "Address ID"
// @Success 200 {object} param.GetAddressResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/addresses/{id} [get].
// @Router /address/{id} [get].
func (h Handler) GetAddress(c echo.Context) error {
var req param.GetAddressRequest
if bErr := echo.PathParamsBinder(c).Uint("id", &req.AddressID).BindError(); bErr != nil {

View File

@ -11,13 +11,13 @@ import (
// GetAddresses godoc
// @Summary Get all benefactor addresses
// @Tags Benefactors Addresses
// @Tags Address
// @Accept json
// @Produce json
// @Success 200 {object} param.GetAllAddressesResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/addresses [get].
// @Router /address/ [get].
func (h Handler) GetAddresses(c echo.Context) error {
var req param.GetAllAddressesRequest

View File

@ -10,12 +10,12 @@ import (
// GetAllCities godoc
// @Summary Get all cities
// @Tags Benefactors Addresses
// @Tags Address
// @Accept json
// @Produce json
// @Success 200 {object} addressparam.GetAllCitiesResponse
// @Failure 400 {string} "Bad request"
// @Router /benefactors/addresses/cities [get].
// @Router /address/cities [get].
func (h Handler) GetAllCities(c echo.Context) error {
var req addressparam.GetAllCitiesRequest

View File

@ -10,12 +10,12 @@ import (
// GetAllProvinces godoc
// @Summary Get all provinces
// @Tags Benefactors Addresses
// @Tags Address
// @Accept json
// @Produce json
// @Success 200 {object} addressparam.GetAllProvincesResponse
// @Failure 400 {string} "Bad request"
// @Router /benefactors/addresses/provinces [get].
// @Router /address/provinces [get].
func (h Handler) GetAllProvinces(c echo.Context) error {
var req addressparam.GetAllProvincesRequest

View File

@ -7,18 +7,18 @@ import (
)
func (h Handler) SetRoutes(e *echo.Echo) {
r := e.Group("/benefactors/addresses")
r := e.Group("/address")
r.GET("/provinces", h.GetAllProvinces)
r.GET("/cities", h.GetAllCities)
r.POST("", h.AddAddress, middleware.Auth(h.authSvc),
r.POST("/", h.AddAddress, middleware.Auth(h.authSvc),
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
r.GET("/:id", h.GetAddress, middleware.Auth(h.authSvc),
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
r.GET("", h.GetAddresses, middleware.Auth(h.authSvc),
r.GET("/", h.GetAddresses, middleware.Auth(h.authSvc),
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
r.DELETE("/:id", h.DeleteAddress, middleware.Auth(h.authSvc),
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
r.PUT("/:id", h.UpdateAddress, middleware.Auth(h.authSvc),
r.PATCH("/:id", h.UpdateAddress, middleware.Auth(h.authSvc),
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
}

View File

@ -10,8 +10,8 @@ import (
)
// UpdateAddress godoc
// @Summary Update benefactor address
// @Tags Benefactors Addresses
// @Summary Edit benefactor address
// @Tags Address
// @Accept json
// @Produce json
// @Param id path int true "Address ID"
@ -19,7 +19,7 @@ import (
// @Success 204
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/addresses/{id} [put].
// @Router /address/{id} [patch].
func (h Handler) UpdateAddress(c echo.Context) error {
var req param.UpdateAddressRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -11,13 +11,13 @@ import (
// loginOrRegister godoc
// @Summary Login or register a benefactor
// @Description This endpoint is used to authenticate an existing benefactor account or register a new one.
// @Tags Benefactors
// @Tags Benefactor
// @Accept json
// @Produce json
// @Param Request body benefactoreparam.LoginOrRegisterRequest true "Login or register request details"
// @Success 200 {object} benefactoreparam.LoginOrRegisterResponse
// @Failure 400 {string} "Bad request"
// @Router /benefactors/login-register [post].
// @Router /benefactor/login-register [post].
func (h Handler) loginOrRegister(c echo.Context) error {
var req benefactoreparam.LoginOrRegisterRequest

View File

@ -1,36 +0,0 @@
package benefactorhandler
import (
benefactorparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/benefactor"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
"net/http"
"github.com/labstack/echo/v4"
)
// RefreshAccess godoc
// @Summary Get a new access token by providing your refresh token
// @Tags Benefactors
// @Accept json
// @Produce json
// @Param Request body benefactorparam.RefreshAccessRequest true "Refresh access token request body"
// @Success 200 {object} benefactorparam.RefreshAccessResponse
// @Failure 400 {string} "Bad Request"
// @Failure 500 {string} "something went wrong"
// @Router /benefactors/refresh-access [post].
func (h Handler) RefreshAccess(c echo.Context) error {
var req benefactorparam.RefreshAccessRequest
if err := c.Bind(&req); err != nil {
return echo.NewHTTPError(http.StatusBadRequest)
}
resp, err := h.benefactorSvc.RefreshAccess(c.Request().Context(), req)
if err != nil {
msg, code := httpmsg.Error(err)
return echo.NewHTTPError(code, msg)
}
return c.JSON(http.StatusOK, resp)
}

View File

@ -5,9 +5,8 @@ import (
)
func (h Handler) SetRoutes(e *echo.Echo) {
r := e.Group("/benefactors")
r := e.Group("/benefactor")
r.POST("/send-otp", h.SendOtp)
r.POST("/login-register", h.loginOrRegister)
r.POST("/refresh-access", h.RefreshAccess)
}

View File

@ -11,13 +11,13 @@ import (
// SendOtp godoc
// @Summary Send OTP to benefactor
// @Description This endpoint sends an OTP to the benefactor's phone number for verification purposes.
// @Tags Benefactors
// @Tags Benefactor
// @Accept json
// @Produce json
// @Param Request body benefactoreparam.SendOtpRequest true "Send OTP request details"
// @Success 200 {object} benefactoreparam.SendOtpResponse
// @Failure 400 {string} "Bad request"
// @Router /benefactors/send-otp [post].
// @Router /benefactor/send-otp [post].
func (h Handler) SendOtp(c echo.Context) error {
var req benefactoreparam.SendOtpRequest

View File

@ -11,14 +11,14 @@ import (
// Get godoc
// @Summary Get a specific kind box for a benefactor
// @Description This endpoint retrieves a specific kind box associated with an authenticated benefactor.
// @Tags Benefactors KindBoxes
// @Tags KindBox
// @Accept json
// @Produce json
// @Param id path int true "Kind box ID"
// @Success 200 {object} param.KindBoxGetResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/kindboxes/{id} [get].
// @Router /benefactor/kindboxes/{id} [get].
func (h Handler) Get(c echo.Context) error {
var req param.KindBoxGetRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -13,7 +13,7 @@ import (
// GetAll godoc
// @Summary Get all KindBoxes by benefactor
// @Description Retrieves a list of all KindBoxes with filtering, sorting, and pagination options
// @Tags Benefactors KindBoxes
// @Tags KindBox
// @Accept json
// @Produce json
// @Param filter_id query int false "Filter by ID"
@ -40,7 +40,7 @@ import (
// @Success 200 {object} param.KindBoxGetAllResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/kindboxes [get].
// @Router /benefactor/kindboxes [get].
func (h Handler) GetAll(c echo.Context) error {
var req param.KindBoxGetAllRequest

View File

@ -12,7 +12,7 @@ import (
// RegisterEmptyingRequest godoc
// @Summary Register a new emptying request for a kind box by benefactor
// @Tags Benefactors KindBoxes
// @Tags Benefactor
// @Accept json
// @Produce json
// @Param id path int true "KindBox ID"
@ -20,7 +20,7 @@ import (
// @Success 204 {string} "No content"
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/kindboxes/{id}/emptying-requests [patch].
// @Router /benefactor/kindboxes/{id}/emptying-requests [patch].
func (h Handler) RegisterEmptyingRequest(c echo.Context) error {
var req param.KindBoxRegisterEmptyingRequest
if bErr := c.Bind(&req); bErr != nil {
@ -44,7 +44,7 @@ func (h Handler) RegisterEmptyingRequest(c echo.Context) error {
}
go h.notificationSvc.KindBoxRegisteredEmptyingRequest(params.NotificationKindBoxRegisteredEmptyingRequest{
KindBoxID: resp.Data.ID,
KindBoxID: resp.ID,
})
return c.JSON(http.StatusNoContent, nil)

View File

@ -7,7 +7,7 @@ import (
)
func (h Handler) SetRoutes(e *echo.Echo) {
r := e.Group("/benefactors/kindboxes")
r := e.Group("/benefactor/kindboxes")
r.Use(
middleware.Auth(h.authSvc),

View File

@ -13,14 +13,14 @@ import (
// Add godoc
// @Summary Add a new kind box request for a benefactor
// @Tags Benefactors KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param Request body param.KindBoxReqAddRequest true "New kind box request details"
// @Success 200 {object} param.KindBoxReqAddResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/kindboxreqs [post].
// @Router /benefactor/kindboxreqs/ [post].
func (h Handler) Add(c echo.Context) error {
req := param.KindBoxReqAddRequest{}
if err := c.Bind(&req); err != nil {
@ -46,7 +46,7 @@ func (h Handler) Add(c echo.Context) error {
}
go h.notificationSvc.KindBoxReqAdded(params.NotificationKindBoxReqAdded{
KindBoxReqID: resp.Data.ID,
KindBoxReqID: resp.KindBoxReq.ID,
})
return c.JSON(http.StatusCreated, resp)

View File

@ -9,17 +9,17 @@ import (
"github.com/labstack/echo/v4"
)
// Delete godoc
// @Summary Delete kindboxreq by benefactor
// delete godoc
// @Summary delete kindboxreq by benefactor
// @Description This endpoint is used to delete benefactor's kindboxreq at pending status
// @Tags Benefactors KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "Kind box request ID"
// @Success 200 {object} param.KindBoxReqDeleteResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/kindboxreqs/{id} [delete].
// @Router /benefactor/kindboxreqs/{id} [delete].
func (h Handler) Delete(c echo.Context) error {
req := param.KindBoxReqDeleteRequest{}
if bErr := echo.PathParamsBinder(c).Uint("id", &req.KindBoxReqID).BindError(); bErr != nil {

View File

@ -11,14 +11,14 @@ import (
// Get godoc
// @Summary Get a kind box request for a benefactor
// @Tags Benefactors KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "Kind box request ID"
// @Success 200 {object} param.KindBoxReqGetResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/kindboxreqs/{id} [get].
// @Router /benefactor/kindboxreqs/{id} [get].
func (h Handler) Get(c echo.Context) error {
var req param.KindBoxReqGetRequest
if bErr := echo.PathParamsBinder(c).Uint("id", &req.KindBoxReqID).BindError(); bErr != nil {

View File

@ -13,7 +13,7 @@ import (
// GetAll godoc
// @Summary Get all KindBox requests
// @Description Retrieves a list of all KindBox requests with filtering, sorting, and pagination options
// @Tags Benefactors KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param filter_id query int false "Filter by ID"
@ -32,7 +32,7 @@ import (
// @Success 200 {object} param.GetAllResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
// @Router /benefactors/kindboxreqs [get].
// @Router /benefactor/kindboxreqs/ [get].
func (h Handler) GetAll(c echo.Context) error {
var req param.GetAllRequest

View File

@ -7,16 +7,16 @@ import (
)
func (h Handler) SetRoutes(e *echo.Echo) {
r := e.Group("/benefactors/kindboxreqs")
r := e.Group("/benefactor/kindboxreqs")
r.Use(
middleware.Auth(h.authSvc),
middleware.BenefactorAuthorization(entity.UserBenefactorRole),
)
r.POST("", h.Add)
r.POST("/", h.Add)
r.GET("/:id", h.Get)
r.DELETE("/:id", h.Delete)
r.GET("", h.GetAll)
r.GET("/", h.GetAll)
r.PUT("/:id", h.Update)
}

View File

@ -11,7 +11,7 @@ import (
// Update godoc
// @Summary Update kind box request by benefactor
// @Tags Benefactors KindBoxReqs
// @Tags KindBoxReq
// @Accept json
// @Produce json
// @Param id path int true "KindBoxReq ID"
@ -23,7 +23,7 @@ import (
// @Failure 422 {object} httpmsg.ErrorResponse
// @Failure 500 {string} "something went wrong"
// @Security AuthBearerBenefactor
// @Router /benefactors/kindboxreqs/{id} [put].
// @Router /benefactor/kindboxreqs/{id} [put].
func (h Handler) Update(c echo.Context) error {
var req param.KindBoxReqUpdateRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -0,0 +1,172 @@
//go:build end2end
package end2end
import (
"context"
"encoding/json"
"fmt"
"git.gocasts.ir/ebhomengo/niki/delivery/http_server/end2end/setup"
"git.gocasts.ir/ebhomengo/niki/entity"
addressparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
"github.com/stretchr/testify/suite"
"net/http"
"testing"
)
type BenefactorAddressTestSuit struct {
suite.Suite
benefactorPhone string
benefactorID uint
addressID uint
getAllExpected map[string]interface{}
getExpected addressparam.GetAddressResponse
createData addressparam.BenefactorAddAddressRequest
updateData addressparam.UpdateAddressRequest
teardown func()
}
func TestBenefactorAddressTestSuit(t *testing.T) {
suite.Run(t, new(BenefactorAddressTestSuit))
}
// SetupTest runs before each test in the suite
func (suite *BenefactorAddressTestSuit) SetupTest() {
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
suite.T().Cleanup(teardown)
suite.benefactorPhone = "09384664404"
suite.benefactorID = 1
suite.addressID = 1
suite.getAllExpected = map[string]interface{}{
"count": 1,
}
suite.getExpected = addressparam.GetAddressResponse{
Address: entity.Address{
ID: suite.addressID,
PostalCode: "3719655861",
Address: "tehran sare koche 1",
Lat: 35.632508,
Lon: 51.452859,
Name: "home1",
CityID: 8,
BenefactorID: suite.benefactorID,
},
}
suite.createData = addressparam.BenefactorAddAddressRequest{
PostalCode: "3719655861",
Address: "create shiraz kaf sharo",
Lat: 29.62949,
Lon: 52.497287,
CityID: 194,
Name: "create shiraz",
}
suite.updateData = addressparam.UpdateAddressRequest{
PostalCode: "3719655861",
Address: "update shiraz kaf sharo",
Lat: 29.62949,
Lon: 52.497287,
CityID: 194,
Name: "update shiraz",
}
}
// TestBenefactorAddressGet tests the GET /address/:id endpoint
func (suite *BenefactorAddressTestSuit) TestBenefactorAddressGet() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/address/%d", suite.addressID)
responseRecord := CreateRequest("GET", url, token, nil)
suite.Require().Equal(http.StatusOK, responseRecord.Code)
var response addressparam.GetAddressResponse
err := json.NewDecoder(responseRecord.Body).Decode(&response)
suite.Require().NoError(err, "could not decode response body")
suite.Require().Equal(suite.addressID, response.Address.ID)
suite.Require().Equal(suite.benefactorID, response.Address.BenefactorID)
suite.Require().Equal(suite.getExpected.Address.PostalCode, response.Address.PostalCode)
suite.Require().Equal(suite.getExpected.Address.Address, response.Address.Address)
// TODO: Fix
//suite.Require().Equal(suite.getExpected.Address.Lat, response.Address.Lat)
//suite.Require().Equal(suite.getExpected.Address.Lon, response.Address.Lon)
suite.Require().Equal(suite.getExpected.Address.Name, response.Address.Name)
suite.Require().Equal(suite.getExpected.Address.CityID, response.Address.CityID)
}
// TestBenefactorAddressGetAll tests the GET /address/ endpoint
func (suite *BenefactorAddressTestSuit) TestBenefactorAddressGetAll() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/address/")
responseRecord := CreateRequest("GET", url, token, nil)
suite.Require().Equal(http.StatusOK, responseRecord.Code)
var response addressparam.GetAllAddressesResponse
err := json.NewDecoder(responseRecord.Body).Decode(&response)
suite.Require().NoError(err, "could not decode response body")
suite.Require().Equal(suite.getAllExpected["count"], len(response.AllAddresses))
}
// TestBenefactorAddressCreate tests the POST /address/ endpoint
func (suite *BenefactorAddressTestSuit) TestBenefactorAddressCreate() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/address/")
responseRecord := CreateRequest("POST", url, token, suite.createData)
suite.Require().Equal(http.StatusCreated, responseRecord.Code)
var response addressparam.BenefactorAddAddressResponse
err := json.NewDecoder(responseRecord.Body).Decode(&response)
suite.Require().NoError(err, "could not decode response body")
suite.Require().Equal(suite.benefactorID, response.Address.BenefactorID)
suite.Require().Equal(suite.createData.Address, response.Address.Address)
suite.Require().Equal(suite.createData.PostalCode, response.Address.PostalCode)
suite.Require().Equal(suite.createData.Name, response.Address.Name)
suite.Require().Equal(suite.createData.CityID, response.Address.CityID)
}
// TestBenefactorAddressUpdate tests the PUT /address/:id endpoint
func (suite *BenefactorAddressTestSuit) TestBenefactorAddressUpdate() {
// TODO: check Method is patch, however, all fields are required
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/address/%d", suite.addressID)
responseRecord := CreateRequest("PATCH", url, token, suite.updateData)
suite.Require().Equal(http.StatusNoContent, responseRecord.Code)
updatedAddress, sErr := services.BenefactorAddressSvc.Get(context.Background(),
addressparam.GetAddressRequest{
AddressID: suite.addressID,
BenefactorID: suite.benefactorID,
})
suite.Require().NoError(sErr, "failed to get benefactor address")
suite.Require().Equal(suite.updateData.PostalCode, updatedAddress.Address.PostalCode)
suite.Require().Equal(suite.updateData.Address, updatedAddress.Address.Address)
suite.Require().Equal(suite.updateData.Name, updatedAddress.Address.Name)
suite.Require().Equal(suite.updateData.CityID, updatedAddress.Address.CityID)
// TODO Fixing floating-point comparison with tolerance
//suite.Require().Equal(suite.updateData.Lat, updatedAddress.Address.Lat)
//suite.Require().Equal(suite.updateData.Lon, updatedAddress.Address.Lon)
}
// TestBenefactorAddressDelete tests the DELETE /address/:id endpoint
func (suite *BenefactorAddressTestSuit) TestBenefactorAddressDelete() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/address/%d", suite.addressID)
responseRecord := CreateRequest("DELETE", url, token, nil)
suite.Require().Equal(http.StatusNoContent, responseRecord.Code)
_, err := services.BenefactorAddressSvc.Get(context.Background(),
addressparam.GetAddressRequest{
AddressID: suite.addressID,
BenefactorID: suite.benefactorID,
},
)
message, code := httpmsg.Error(err)
suite.Require().Error(err)
suite.Equal(http.StatusNotFound, code)
suite.Equal(errmsg.ErrorMsgNotFound, message)
}

View File

@ -0,0 +1,119 @@
//go:build end2end
package end2end
import (
"encoding/json"
"fmt"
"git.gocasts.ir/ebhomengo/niki/delivery/http_server/end2end/setup"
"git.gocasts.ir/ebhomengo/niki/entity"
benefactorkindboxparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box"
"github.com/stretchr/testify/suite"
"net/http"
"testing"
"time"
)
type BenefactorKindBoxTestSuite struct {
suite.Suite
benefactorPhone string
benefactorID uint
kindBoxID uint
kindBboxGetAllExpected map[string]interface{}
kindBoxGetExpected benefactorkindboxparam.KindBoxGetResponse
}
func TestBenefactorKindBoxTestSuite(t *testing.T) {
suite.Run(t, new(BenefactorKindBoxTestSuite))
}
func (suite *BenefactorKindBoxTestSuite) SetupTest() {
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
suite.T().Cleanup(teardown)
suite.benefactorPhone = "09384664404"
suite.kindBoxID = 1
suite.kindBboxGetAllExpected = map[string]interface{}{
"count": 1,
}
/*
"ID" : 1,
"KindBoxReqID" : 1,
"BenefactorID" : 1,
"KindBoxType" : "on-table",
"Amount" : 0,
"SerialNumber" : "serial-1",
"Status" : "delivered",
"DeliverReferTimeID" : 1,
"DeliverReferDate" : "2024-08-26T18:19:26Z",
"DeliverAddressID" : 1,
"SenderAgentID" : 1,
"DeliveredAt" : "2024-09-02T18:19:26Z",
"ReturnReferTimeID" : 0,
"ReturnReferDate" : "0001-01-01T00:00:00Z",
"ReturnAddressID" : 0,
"ReceiverAgentID" : 0,
"ReturnedAt" : "0001-01-01T00:00:00Z"
*/
suite.kindBoxGetExpected = benefactorkindboxparam.KindBoxGetResponse{
KindBox: entity.KindBox{
ID: suite.kindBoxID,
KindBoxReqID: 1,
BenefactorID: 1,
KindBoxType: "on-table",
Amount: 0,
SerialNumber: "serial-1",
Status: "delivered",
DeliverReferTimeID: 1,
DeliverReferDate: time.Now().AddDate(0, 0, 7).UTC(),
DeliverAddressID: 1,
SenderAgentID: 1,
DeliveredAt: time.Now().AddDate(0, 0, 7).UTC(),
ReturnReferTimeID: 0,
ReturnReferDate: time.Time{},
ReturnAddressID: 0,
ReceiverAgentID: 0,
ReturnedAt: time.Time{},
},
}
}
func (suite *BenefactorKindBoxTestSuite) TestBenefactorKindBoxGetAll() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/benefactor/kindboxes")
responseRecord := CreateRequest("GET", url, token, nil)
suite.Require().Equal(http.StatusOK, responseRecord.Code)
var response benefactorkindboxparam.KindBoxGetAllResponse
err := json.NewDecoder(responseRecord.Body).Decode(&response)
suite.Require().NoError(err)
suite.Require().Equal(suite.kindBboxGetAllExpected["count"], len(response.AllKindBox))
}
func (suite *BenefactorKindBoxTestSuite) TestBenefactorKindBoxGet() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/benefactor/kindboxes/%d", suite.kindBoxID)
responseRecord := CreateRequest("GET", url, token, nil)
suite.Require().Equal(http.StatusOK, responseRecord.Code)
var response benefactorkindboxparam.KindBoxGetResponse
err := json.NewDecoder(responseRecord.Body).Decode(&response)
suite.Require().NoError(err)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.ID, response.KindBox.ID)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.KindBoxReqID, response.KindBox.KindBoxReqID)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.BenefactorID, response.KindBox.BenefactorID)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.KindBoxType, response.KindBox.KindBoxType)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.Amount, response.KindBox.Amount)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.SerialNumber, response.KindBox.SerialNumber)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.Status, response.KindBox.Status)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.DeliverReferTimeID, response.KindBox.DeliverReferTimeID)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.DeliverReferDate.Format("2006-01-02"), response.KindBox.DeliverReferDate.Format("2006-01-02"))
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.DeliverAddressID, response.KindBox.DeliverAddressID)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.SenderAgentID, response.KindBox.SenderAgentID)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.DeliveredAt.Format("2006-01-02"), response.KindBox.DeliveredAt.Format("2006-01-02"))
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.ReturnReferTimeID, response.KindBox.ReturnReferTimeID)
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.ReturnReferDate.Format("2006-01-02"), response.KindBox.ReturnReferDate.Format("2006-01-02"))
suite.Require().Equal(suite.kindBoxGetExpected.KindBox.ReturnAddressID, response.KindBox.ReturnAddressID)
}

View File

@ -0,0 +1,173 @@
//go:build end2end
package end2end
import (
"context"
"encoding/json"
"fmt"
"git.gocasts.ir/ebhomengo/niki/delivery/http_server/end2end/setup"
"git.gocasts.ir/ebhomengo/niki/entity"
benefactorkindboxreqparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"net/http"
"testing"
"time"
)
// BenefactorKindBoxReqsTestSuite defines the suite for testing Benefactor Kind Box Requests
type BenefactorKindBoxReqsTestSuite struct {
suite.Suite
benefactorPhone string
benefactorID uint
kindBoxReqID uint
getAllExpected map[string]interface{}
getExpected map[string]interface{}
createData benefactorkindboxreqparam.KindBoxReqAddRequest
updateData benefactorkindboxreqparam.KindBoxReqUpdateRequest
}
// TestBenefactorKindBoxReqsTestSuite is the entry point for the test suite
func TestBenefactorKindBoxReqsTestSuite(t *testing.T) {
suite.Run(t, new(BenefactorKindBoxReqsTestSuite))
}
// SetupTest runs before each test in the suite
func (suite *BenefactorKindBoxReqsTestSuite) SetupTest() {
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
suite.T().Cleanup(teardown)
suite.benefactorPhone = "09384664404"
suite.benefactorID = uint(1)
suite.kindBoxReqID = uint(1)
suite.getAllExpected = map[string]interface{}{
"count": 5,
}
suite.getExpected = map[string]interface{}{
"kind_box_type": entity.KindBoxOnTable,
"deliver_address": uint(1),
"deliver_refer_date": time.Now().AddDate(0, 0, 7).UTC(),
"deliver_refer_time": uint(1),
}
suite.createData = benefactorkindboxreqparam.KindBoxReqAddRequest{
KindBoxType: entity.KindBoxCylindrical,
DeliverAddressID: uint(1),
DeliverReferDate: time.Now().AddDate(0, 0, 7).UTC(),
DeliverReferTimeID: uint(1),
CountRequested: uint(5),
}
suite.updateData = benefactorkindboxreqparam.KindBoxReqUpdateRequest{
KindBoxType: entity.KindBoxCylindrical,
CountRequested: uint(10),
Description: "updated description",
DeliverReferTimeID: uint(1),
DeliverReferDate: time.Now().AddDate(0, 0, 7).UTC(),
DeliverAddressID: uint(1),
}
}
// TestBenefactorKindBoxReqs_GetAll_Success tests retrieving all kind box requests
func (suite *BenefactorKindBoxReqsTestSuite) TestBenefactorKindBoxReqs_GetAll_Success() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/benefactor/kindboxreqs/")
responseRecord := CreateRequest(http.MethodGet, url, token, nil)
suite.Require().Equal(http.StatusOK, responseRecord.Code)
var response benefactorkindboxreqparam.GetAllResponse
err := json.NewDecoder(responseRecord.Body).Decode(&response)
suite.Require().NoError(err, "failed to decode response body")
assert.Equal(suite.T(), suite.getAllExpected["count"], len(response.AllKindBoxReq))
}
// TestBenefactorKindBoxReqs_Get_Success tests retrieving a specific kind box request by ID
func (suite *BenefactorKindBoxReqsTestSuite) TestBenefactorKindBoxReqs_Get_Success() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/benefactor/kindboxreqs/%d", suite.kindBoxReqID)
responseRecord := CreateRequest(http.MethodGet, url, token, nil)
suite.Require().Equal(http.StatusOK, responseRecord.Code)
var response benefactorkindboxreqparam.KindBoxReqGetResponse
err := json.NewDecoder(responseRecord.Body).Decode(&response)
suite.Require().NoError(err, "failed to decode response body")
assert.Equal(suite.T(), suite.kindBoxReqID, response.KindBoxReq.ID)
assert.Equal(suite.T(), suite.getExpected["kind_box_type"], response.KindBoxReq.KindBoxType)
assert.Equal(suite.T(), suite.getExpected["deliver_address"], response.KindBoxReq.DeliverAddressID)
assert.Equal(
suite.T(),
suite.getExpected["deliver_refer_date"].(time.Time).Format("2006-01-02"),
response.KindBoxReq.DeliverReferDate.Format("2006-01-02"),
)
assert.Equal(suite.T(), suite.getExpected["deliver_refer_time"], response.KindBoxReq.DeliverReferTimeID)
}
// TestBenefactorKindBoxReqs_Create_Success tests creating a kind box request
func (suite *BenefactorKindBoxReqsTestSuite) TestBenefactorKindBoxReqs_Create_Success() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/benefactor/kindboxreqs/")
rec := CreateRequest(http.MethodPost, url, token, suite.createData)
suite.Require().Equal(http.StatusCreated, rec.Code)
var response benefactorkindboxreqparam.KindBoxReqAddResponse
err := json.NewDecoder(rec.Body).Decode(&response)
suite.Require().NoError(err, "failed to decode response body")
assert.Equal(suite.T(), suite.createData.KindBoxType, response.KindBoxReq.KindBoxType)
assert.Equal(suite.T(), suite.createData.DeliverAddressID, response.KindBoxReq.DeliverAddressID)
assert.Equal(suite.T(), suite.createData.DeliverReferDate, response.KindBoxReq.DeliverReferDate)
assert.Equal(suite.T(), suite.createData.CountRequested, response.KindBoxReq.CountRequested)
}
// TestBenefactorKindBoxReqs_Update_Success tests updating a kind box request
func (suite *BenefactorKindBoxReqsTestSuite) TestBenefactorKindBoxReqs_Update_Success() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/benefactor/kindboxreqs/%d", suite.kindBoxReqID)
rec := CreateRequest(http.MethodPut, url, token, suite.updateData)
suite.Require().Equal(http.StatusNoContent, rec.Code)
kindBoxReq, err := services.BenefactorKindBoxReqSvc.Get(context.Background(),
benefactorkindboxreqparam.KindBoxReqGetRequest{
BenefactorID: suite.benefactorID,
KindBoxReqID: suite.kindBoxReqID,
},
)
suite.Require().NoError(err, "failed to get kind box request")
assert.Equal(suite.T(), suite.updateData.KindBoxType, kindBoxReq.KindBoxType)
assert.Equal(suite.T(), suite.updateData.CountRequested, kindBoxReq.CountRequested)
assert.Equal(suite.T(), suite.updateData.Description, kindBoxReq.Description)
assert.Equal(suite.T(), suite.updateData.DeliverReferTimeID, kindBoxReq.DeliverReferTimeID)
assert.Equal(
suite.T(),
suite.updateData.DeliverReferDate.Format("2006-01-02"),
kindBoxReq.DeliverReferDate.Format("2006-01-02"),
)
assert.Equal(suite.T(), suite.updateData.DeliverAddressID, kindBoxReq.DeliverAddressID)
}
// TestBenefactorKindBoxReqs_Delete_Success tests deleting a kind box request
func (suite *BenefactorKindBoxReqsTestSuite) TestBenefactorKindBoxReqs_Delete_Success() {
token := LoginBenefactor(suite.benefactorPhone)
url := fmt.Sprintf("/benefactor/kindboxreqs/%d", suite.kindBoxReqID)
rec := CreateRequest(http.MethodDelete, url, token, nil)
suite.Require().Equal(http.StatusOK, rec.Code)
_, err := services.BenefactorKindBoxReqSvc.Get(context.Background(),
benefactorkindboxreqparam.KindBoxReqGetRequest{
BenefactorID: suite.benefactorID,
KindBoxReqID: suite.kindBoxReqID,
},
)
message, code := httpmsg.Error(err)
suite.Require().Error(err)
assert.Equal(suite.T(), http.StatusNotFound, code)
assert.Equal(suite.T(), errmsg.ErrorMsgNotFound, message)
}

View File

@ -0,0 +1,53 @@
//go:build end2end
package end2end
import (
"bytes"
"context"
"encoding/json"
"fmt"
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/benefactor"
"github.com/labstack/echo/v4"
"log"
"net/http/httptest"
)
// CreateRequest is a utility function to create and send HTTP requests
func CreateRequest(method, url, token string, body interface{}) *httptest.ResponseRecorder {
var buf bytes.Buffer
if body != nil {
err := json.NewEncoder(&buf).Encode(body)
if err != nil {
log.Fatalf("could not encode body: %v", err)
}
}
req := httptest.NewRequest(method, url, &buf)
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", token))
rec := httptest.NewRecorder()
testServer.Serve(rec, req)
return rec
}
// LoginBenefactor is a utility function to login a benefactor and return the access token
func LoginBenefactor(phoneNumber string) string {
sendOTPRes, err := services.BenefactorSvc.SendOtp(context.Background(), param.SendOtpRequest{
PhoneNumber: phoneNumber,
})
if err != nil {
log.Fatalf("failed to send OTP: %v", err)
}
registerRes, err := services.BenefactorSvc.LoginOrRegister(context.Background(), param.LoginOrRegisterRequest{
PhoneNumber: phoneNumber,
VerificationCode: sendOTPRes.Code,
})
if err != nil {
log.Fatalf("failed to register: %v", err)
}
return registerRes.Tokens.AccessToken
}

View File

@ -1,12 +1,12 @@
package setup
import (
"github.com/labstack/echo/v4"
"net/http"
"git.gocasts.ir/ebhomengo/niki/config"
httpserver "git.gocasts.ir/ebhomengo/niki/delivery/http_server"
"git.gocasts.ir/ebhomengo/niki/service"
"github.com/labstack/echo/v4"
)
type TestServer struct {

View File

@ -14,7 +14,7 @@ func Auth(service authservice.Service) echo.MiddlewareFunc {
// TODO - as sign method string to config
SigningMethod: "HS256",
ParseTokenFunc: func(c echo.Context, auth string) (interface{}, error) {
claims, err := service.ParseBearerToken(auth)
claims, err := service.ParseToken(auth)
if err != nil {
return nil, err
}

View File

@ -9,7 +9,7 @@ import (
"github.com/labstack/echo/v4"
)
// nolint
//nolint
func BenefactorAuthorization(role entity.UserRole) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {

View File

@ -2,7 +2,6 @@ package httpserver
import (
"fmt"
agentkindboxreqhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/agent/kind_box_req"
"git.gocasts.ir/ebhomengo/niki/config"
adminhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/admin"
@ -29,7 +28,6 @@ type Server struct {
adminKindBoxHandler adminKindBoxHandler.Handler
adminAgentHandler adminagenthandler.Handler
agentKindBoxHandler agentkindboxhandler.Handler
agentKindBoxReqHandler agentkindboxreqhandler.Handler
benefactorHandler benefactorhandler.Handler
benefactorKindBoxReqHandler benefactorkindboxreqhandler.Handler
benefactorAddressHandler benefactoraddresshandler.Handler
@ -47,8 +45,7 @@ func New(
adminKindBoxReqHandler: adminkindboxreqhandler.New(svc.AdminAuthSvc, svc.AdminKindBoxReqSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
adminKindBoxHandler: adminKindBoxHandler.New(svc.AdminAuthSvc, svc.AdminKindBoxSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
adminAgentHandler: adminagenthandler.New(svc.AdminAuthSvc, svc.AdminAgentSvc, svc.AdminAuthorizeSvc),
agentKindBoxHandler: agentkindboxhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
agentKindBoxReqHandler: agentkindboxreqhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxReqSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
agentKindBoxHandler: agentkindboxhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxSvc, svc.AdminAuthorizeSvc),
benefactorHandler: benefactorhandler.New(svc.BenefactorAuthSvc, svc.BenefactorSvc),
benefactorKindBoxReqHandler: benefactorkindboxreqhandler.New(svc.BenefactorAuthSvc, svc.BenefactorKindBoxReqSvc, svc.NotificationSvc),
benefactorAddressHandler: benefactoraddresshandler.New(svc.BenefactorAuthSvc, svc.BenefactorAddressSvc),
@ -70,10 +67,7 @@ func (s Server) Serve() {
func (s Server) RegisterRoutes() {
s.Router.Use(middleware.RequestID())
s.Router.Use(middleware.Recover())
s.Router.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: s.config.HTTPServer.Cors.AllowOrigins,
}))
registerSwagger(s.Router)
registerSwagger(s.Router, s.config)
// Routes
s.Router.GET("/health-check", s.healthCheck)
@ -82,18 +76,17 @@ func (s Server) RegisterRoutes() {
s.benefactorAddressHandler.SetRoutes(s.Router)
s.benefactorKindBoxHandler.SetRoutes(s.Router)
s.adminHandler.SetRoutes(s.Router)
s.adminAgentHandler.SetRoutes(s.Router)
s.adminKindBoxReqHandler.SetRoutes(s.Router)
s.adminKindBoxHandler.SetRoutes(s.Router)
s.agentKindBoxHandler.SetRoutes(s.Router)
s.agentKindBoxReqHandler.SetRoutes(s.Router)
}
func registerSwagger(s *echo.Echo) {
func registerSwagger(s *echo.Echo, c config.Config) {
// TODO: move this to a better place and make it more dynamic and configurable
docs.SwaggerInfo.Title = "NIKI API"
docs.SwaggerInfo.Description = "This is the API documentation for the NIKI project"
docs.SwaggerInfo.Version = "1.0.0"
docs.SwaggerInfo.Host = fmt.Sprintf("localhost:%d", c.HTTPServer.Port)
s.GET("/swagger/*any", echoSwagger.WrapHandler)
}

View File

@ -1,11 +0,0 @@
COMPOSE_MARIADB_PORT=3306
COMPOSE_MARIADB_DATABASE=niki_db
COMPOSE_MARIADB_USER=niki
COMPOSE_MARIADB_UR_PASSWORD=n0ki2agd23
COMPOSE_REDIS_PORT=6379
COMPOSE_REDIS_DB=0
COMPOSE_REDIS_PASSWORD=n0ki2agd23
COMPOSE_AUTH_SIGN_KEY=jwt_secret_stage_nik
COMPOSE_ADMIN_AUTH_SIGN_KEY=admin-jwt_secret_stage_nik

View File

@ -1,15 +0,0 @@
---
type: yml
http_server:
port: 1313
cors:
allow_origins:
- "*"
benefactor_service:
length_of_otp_code: 5
kavenegar_sms_provider:
api_key: insert_your_api_key
sender: insert_sender_number

View File

@ -1,26 +1,12 @@
version: '3.9'
version: '3.7'
services:
niki_app_stage:
image: niki:${STAGE_NIKI_IMAGE_VERSION?error}
image: niki:${STAGE_NIKI_IMAGE_VERSION}
container_name: niki_app_stage
environment:
EB_MARIADB__HOST: niki_stage_mariadb
EB_MARIADB__PORT: ${COMPOSE_MARIADB_PORT?error}
EB_MARIADB__DB_NAME: ${COMPOSE_MARIADB_DATABASE?error}
EB_MARIADB__USERNAME: ${COMPOSE_MARIADB_USER?error}
EB_MARIADB__PASSWORD: ${COMPOSE_MARIADB_UR_PASSWORD?error}
EB_REDIS__HOST: niki_stage_redis
EB_REDIS__PORT: ${COMPOSE_REDIS_PORT?error}
EB_REDIS__DB: ${COMPOSE_REDIS_DB?error}
EB_REDIS__PASSWORD: ${COMPOSE_REDIS_PASSWORD?error}
EB_AUTH__SIGN_KEY: ${COMPOSE_AUTH_SIGN_KEY?error}
EB_ADMIN_AUTH__SIGN_KEY: ${COMPOSE_ADMIN_AUTH_SIGN_KEY?error}
restart: always
ports:
- "127.0.0.1:8313:1313"
- '127.0.0.1:8198:1313'
networks:
- niki-stage
volumes:

36
deploy/stage/config.yml Normal file
View File

@ -0,0 +1,36 @@
---
type: yml
auth:
sign_key: jwt_secret_stage_nik
http_server:
port: 1313
mysql:
port: 3306
host: niki_stage_mariadb
db_name: niki_db
username: niki
password: n0ki2agd23
redis:
port: 6379
host: niki_stage_redis
password: ""
db: 0
sms_provider:
host: localhost
port: 443
benefactor_service:
length_of_otp_code: 5
kavenegar_sms_provider:
api_key: insert_your_api_key
otp_template_new_user: ebhomeverify
otp_template_registered_user: ebhomeverify
admin_auth:
sign_key: admin-jwt_secret_test_nik

View File

@ -1,4 +0,0 @@
COMPOSE_MARIADB_DATABASE=niki_db
COMPOSE_MARIADB_USER=niki
COMPOSE_MARIADB_UR_PASSWORD=n0ki2agd23
COMPOSE_MARIADB_RT_PASSWORD=n0ki2agd23

View File

@ -1,22 +1,22 @@
version: '3.9'
version: '3.1'
services:
niki_stage_mariadb:
image: docker.io/bitnami/mariadb:11.1
container_name: niki_stage_mariadb
restart: always
ports:
- '127.0.0.1:3429:3306'
networks:
- niki-stage
expose:
- "3306"
volumes:
- 'niki_stage_mariadb_data:/bitnami/mariadb'
environment:
MARIADB_USER: ${COMPOSE_MARIADB_USER?error}
MARIADB_PASSWORD: ${COMPOSE_MARIADB_UR_PASSWORD?error}
MARIADB_DATABASE: ${COMPOSE_MARIADB_DATABASE?error}
MARIADB_ROOT_PASSWORD: ${COMPOSE_MARIADB_RT_PASSWORD?error}
ALLOW_EMPTY_PASSWORD: no
- MARIADB_USER=niki
- MARIADB_PASSWORD=${NIKI_STAGE_MARIADB_UR_PASSWORD}
- MARIADB_DATABASE=niki_db
- MARIADB_ROOT_PASSWORD=${NIKI_STAGE_MARIADB_RT_PASSWORD}
- ALLOW_EMPTY_PASSWORD=no
healthcheck:
test: ['CMD', '/opt/bitnami/scripts/mariadb/healthcheck.sh']
interval: 15s

View File

@ -1 +0,0 @@
COMPOSE_REDIS_PASSWORD=n0ki2agd23

View File

@ -1,17 +1,18 @@
version: '3.9'
version: '3.1'
services:
niki_stage_redis:
image: bitnami/redis:6.2
container_name: niki_stage_redis
restart: always
command: redis-server --loglevel warning --protected-mode no
ports:
- '127.0.0.1:6380:6379'
# TODO - remove `--save "" --appendonly no` from command to persist data
command: redis-server --loglevel warning --protected-mode no --save "" --appendonly no
environment:
REDIS_PASSWORD: ${COMPOSE_REDIS_PASSWORD?error}
- ALLOW_EMPTY_PASSWORD=yes
networks:
- niki-stage
expose:
- "6379"
- core
volumes:
- niki__stage_redis_data:/data

40
docker-compose.dev.yaml Normal file
View File

@ -0,0 +1,40 @@
version: '3.9'
services:
mysqltest:
image: mysql:8.0
ports:
- "3305:3306"
container_name: niki-database-test
volumes:
- dbdatatest:/var/lib/mysql
restart: always
command: [ 'mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci' ]
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: test_db
MYSQL_USER: testuser
MYSQL_PASSWORD: test1234
niki-redis-test:
image: bitnami/redis:6.2
container_name: niki-redis-test
restart: always
ports:
- '6381:6379'
# TODO - remove `--save "" --appendonly no` from command to persist data
command: redis-server --loglevel warning --protected-mode no --save "" --appendonly no
environment:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- niki-redis-data-test:/data
volumes:
dbdatatest:
niki-redis-data-test:
# docker-compose -f docker-compose.dev.yaml up -d

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -20,5 +20,4 @@ const (
AdminKindBoxGetAwaitingReturnPermission = AdminPermission("kindbox-get_awaiting_return")
AdminKindBoxReturnPermission = AdminPermission("kindbox-return")
AdminKindBoxEnumeratePermission = AdminPermission("kindbox-enumerate")
AdminKindBoxUpdatePermission = AdminPermission("kindbox-update")
)

View File

@ -12,5 +12,4 @@ type Benefactor struct {
Gender Gender
BirthDate time.Time
Role UserRole
Status BenefactorStatus
}

View File

@ -1,19 +0,0 @@
package entity
type BenefactorStatus string
const (
BenefactorActiveStatus = BenefactorStatus("active")
BenefactorInactiveStatus = BenefactorStatus("inactive")
)
var BenefactorStatusStrings = map[BenefactorStatus]string{
BenefactorActiveStatus: "active",
BenefactorInactiveStatus: "inactive",
}
func (b BenefactorStatus) IsValid() bool {
_, ok := BenefactorStatusStrings[b]
return ok
}

4
go.mod
View File

@ -1,6 +1,8 @@
module git.gocasts.ir/ebhomengo/niki
go 1.23
go 1.22
toolchain go1.22.4
require (
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible

View File

@ -1,15 +0,0 @@
package adminserviceparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type Data struct {
ID uint `json:"id" example:"1"`
FirstName string `json:"first_name" example:"John"`
LastName string `json:"last_name" example:"Doe"`
PhoneNumber string `json:"phone_number" example:"09123456789"`
Role entity.AdminRole `json:"role" example:"2"`
Description string `json:"description" example:"This is a description"`
Email string `json:"email" example:"example@gmail.com"`
Gender entity.Gender `json:"gender" example:"male"`
Status entity.AdminStatus `json:"status" example:"active"`
}

View File

@ -1,12 +1,26 @@
package adminserviceparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type LoginWithPhoneNumberRequest struct {
PhoneNumber string `json:"phone_number" example:"09123456789"`
Password string `json:"password" example:"password123"`
}
type LoginWithPhoneNumberResponse struct {
Data Data `json:"data"`
AdminInfo AdminInfo `json:"admin_info"`
Tokens Tokens `json:"tokens"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}
type AdminInfo struct {
ID uint `json:"id" example:"1"`
FirstName string `json:"first_name" example:"John"`
LastName string `json:"last_name" example:"Doe"`
PhoneNumber string `json:"phone_number" example:"09123456789"`
Role entity.AdminRole `json:"role" example:"2"`
Description string `json:"description" example:"This is a description"`
Email string `json:"email" example:"example@gmail.com"`
Gender entity.Gender `json:"gender" example:"male"`
Status entity.AdminStatus `json:"status" example:"active"`
}

View File

@ -1,9 +0,0 @@
package adminserviceparam
type RefreshAccessRequest struct {
RefreshToken string `json:"refresh_token"`
}
type RefreshAccessResponse struct {
AccessToken string `json:"access_token"`
}

View File

@ -15,6 +15,6 @@ type RegisterRequest struct {
}
type RegisterResponse struct {
Data Data `json:"data"`
Admin entity.Admin `json:"admin"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -1,10 +1,10 @@
package adminagentparam
type GetAllAgentResponse struct {
Data []Data `json:"data"`
Agents []Agent `json:"agents"`
}
type Data struct {
type Agent struct {
ID uint `json:"id" example:"1"`
FirstName string `json:"first_name" example:"John"`
LastName string `json:"last_name" example:"Doe"`

View File

@ -1,4 +1,4 @@
package agentkindboxparam
package adminkindboxparam
import (
"time"

View File

@ -1,27 +0,0 @@
package adminkindboxparam
import (
"time"
"git.gocasts.ir/ebhomengo/niki/entity"
)
type Data struct {
ID uint `json:"id"`
KindBoxReqID uint `json:"kind_box_req_id"`
BenefactorID uint `json:"benefactor_id"`
KindBoxType entity.KindBoxType `json:"kind_box_type"`
Amount uint `json:"amount"`
SerialNumber string `json:"serial_number"`
Status entity.KindBoxStatus `json:"status"`
DeliverReferTimeID uint `json:"deliver_refer_time_id"`
DeliverReferDate time.Time `json:"deliver_refer_date"`
DeliverAddressID uint `json:"deliver_address_id"`
SenderAgentID uint `json:"sender_agent_id"`
DeliveredAt time.Time `json:"delivered_at"`
ReturnReferTimeID uint `json:"return_refer_time_id"`
ReturnReferDate time.Time `json:"return_refer_date"`
ReturnAddressID uint `json:"return_address_id"`
ReceiverAgentID uint `json:"receiver_agent_id"`
ReturnedAt time.Time `json:"returned_at"`
}

View File

@ -1,10 +1,12 @@
package adminkindboxparam
import entity "git.gocasts.ir/ebhomengo/niki/entity"
type KindBoxGetRequest struct {
KindBoxID uint `param:"id"`
}
type KindBoxGetResponse struct {
Data Data `json:"data"`
entity.KindBox
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -1,6 +1,7 @@
package adminkindboxparam
import (
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/param"
)
@ -11,7 +12,7 @@ type KindBoxGetAllRequest struct {
}
type KindBoxGetAllResponse struct {
Data []Data `json:"data"`
AllKindBox []entity.KindBox `json:"all_kind_box"`
Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -1,20 +1,17 @@
package adminkindboxparam
import (
"time"
)
import entity "git.gocasts.ir/ebhomengo/niki/entity"
//when kindbox creates, which fields are
type KindBoxUpdateRequest struct {
KindBoxID uint `json:"-" param:"id" example:"1"` // ID is passed in the URL path
BenefactorID uint `json:"benefactor_id" example:"1"`
ReturnReferTimeID uint `json:"return_refere_time_id" example:"3"`
ReturnReferDate time.Time `json:"return_refer_date" example:"2025-01-02T15:04:05Z"`
ReturnAddressID uint `json:"return_address_id" example:"1"`
ReceiverAgentID uint `json:"receiver_agent_id" example:"23"`
Amount uint `json:"amount" example:"3"`
BenefactorID uint
KindBoxID uint
Amount uint
ReceiverAgentID uint
SenderAgentID uint
SerialNumber string
Status entity.KindBoxStatus
}
type KindBoxUpdateResponse struct {
FieldErrors map[string]string `json:"field_errors,omitempty"`
KindBox entity.KindBox
}

View File

@ -1,11 +1,22 @@
package adminkindboxreqparam
import (
"time"
"git.gocasts.ir/ebhomengo/niki/entity"
)
type KindBoxReqAcceptRequest struct {
ID uint `json:"-"`
CountAccepted uint `json:"count_accepted"`
}
type KindBoxReqAcceptResponse struct {
Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
KindBoxReqID uint `json:"kind_box_req_id"`
KindBoxReqStatus entity.KindBoxReqStatus `json:"kind_box_req_status"`
CountRequested uint `json:"count_requested"`
CountAccepted uint `json:"count_accepted"`
DeliverReferDate time.Time `json:"deliver_refer_date"`
DeliverAddressID uint `json:"deliver_address_id"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -1,20 +1,16 @@
package adminkindboxreqparam
import (
entity "git.gocasts.ir/ebhomengo/niki/entity"
"time"
)
import entity "git.gocasts.ir/ebhomengo/niki/entity"
type KindBoxReqAddRequest struct {
BenefactorID uint `json:"benefactor_id" example:"1"`
KindBoxType entity.KindBoxType `json:"kind_box_type" example:"on-table"`
DeliverAddressID uint `json:"deliver_address_id" example:"1"`
DeliverReferDate time.Time `json:"deliver_refer_date" example:"2025-01-02T15:04:05Z"`
DeliverReferTimeID uint `json:"deliver_refer_time_id" example:"1"`
CountRequested uint `json:"count_requested" example:"2"`
BenefactorID uint `json:"benefactor_id" example:"1"`
KindBoxType entity.KindBoxType `json:"kind_box_type" example:"on-table"`
DeliverAddressID uint `json:"deliver_address_id" example:"1"`
DeliverReferDate string `json:"deliver_refer_date" example:"2025-01-02 15:04:05"`
CountRequested uint `json:"count_requested" example:"2"`
}
type KindBoxReqAddResponse struct {
Data Data `json:"data"`
KindBoxReq entity.KindBoxReq
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -1,22 +0,0 @@
package adminkindboxreqparam
import (
"time"
"git.gocasts.ir/ebhomengo/niki/entity"
)
type Data struct {
ID uint `json:"id"`
BenefactorID uint `json:"benefactor_id"`
KindBoxType entity.KindBoxType `json:"kind_box_type"`
CountRequested uint `json:"count_requested"`
CountAccepted uint `json:"count_accepted"`
Description string `json:"description"`
Status entity.KindBoxReqStatus `json:"status"`
DeliverReferTimeID uint `json:"deliver_refer_time_id"`
DeliverReferDate time.Time `json:"deliver_refer_date"`
DeliverAddressID uint `json:"deliver_address_id"`
SenderAgentID uint `json:"sender_agent_id"`
DeliveredAt time.Time `json:"delivered_at"`
}

View File

@ -1,4 +1,4 @@
package agentkindboxreqparam
package adminkindboxreqparam
type DeliverKindBoxReqRequest struct {
KindBoxReqID uint `json:"-" param:"id"`

View File

@ -1,10 +1,12 @@
package adminkindboxreqparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type GetKindBoxReqRequest struct {
KindBoxID uint `param:"id"`
}
type GetKindBoxReqResponse struct {
Data Data `json:"data"`
entity.KindBoxReq
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -1,6 +1,7 @@
package adminkindboxreqparam
import (
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/param"
)
@ -11,7 +12,7 @@ type KindBoxReqGetAllRequest struct {
}
type KindBoxReqGetAllResponse struct {
Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
AllKindBoxReq []entity.KindBoxReq `json:"all_awaiting_kind_box_req"`
Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -0,0 +1,18 @@
package adminkindboxreqparam
import (
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/param"
)
type DeliveryAwaitingGetAllRequest struct {
Pagination param.PaginationRequest
Sort param.SortRequest
Filter param.FilterRequest
}
type DeliveryAwaitingGetAllResponse struct {
AllAwaitingKindBoxReq []entity.KindBoxReq `json:"all_awaiting_kind_box_req"`
Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -1,4 +1,6 @@
package agentkindboxreqparam
package adminkindboxreqparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type DeliveryAwaitingGetRequest struct {
KindBoxReqID uint `param:"id"`
@ -6,6 +8,6 @@ type DeliveryAwaitingGetRequest struct {
}
type DeliveryAwaitingGetResponse struct {
Data Data `json:"data"`
entity.KindBoxReq
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -1,11 +1,24 @@
package adminkindboxreqparam
import (
"time"
"git.gocasts.ir/ebhomengo/niki/entity"
)
type KindBoxReqRejectRequest struct {
ID uint `json:"-"`
Description string `json:"description" example:"description"`
}
type KindBoxReqRejectResponse struct {
Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
ID uint `json:"id" example:"1"`
KindBoxType entity.KindBoxType `json:"kind_box_type" example:"on-table"`
CountRequested uint `json:"count_requested" example:"1"`
BenefactorID uint `json:"benefactor_id" example:"1"`
Status entity.KindBoxReqStatus `json:"status" example:"pending"`
Description string `json:"description" example:"description"`
DeliverReferDate time.Time `json:"deliver_refer_date" example:"2025-01-02 15:04:05"`
DeliverAddressID uint `json:"deliver_address_id" example:"1"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -1,27 +0,0 @@
package agentkindboxparam
import (
"time"
"git.gocasts.ir/ebhomengo/niki/entity"
)
type Data struct {
ID uint `json:"id"`
KindBoxReqID uint `json:"kind_box_req_id"`
BenefactorID uint `json:"benefactor_id"`
KindBoxType entity.KindBoxType `json:"kind_box_type"`
Amount uint `json:"amount"`
SerialNumber string `json:"serial_number"`
Status entity.KindBoxStatus `json:"status"`
DeliverReferTimeID uint `json:"deliver_refer_time_id"`
DeliverReferDate time.Time `json:"deliver_refer_date"`
DeliverAddressID uint `json:"deliver_address_id"`
SenderAgentID uint `json:"sender_agent_id"`
DeliveredAt time.Time `json:"delivered_at"`
ReturnReferTimeID uint `json:"return_refer_time_id"`
ReturnReferDate time.Time `json:"return_refer_date"`
ReturnAddressID uint `json:"return_address_id"`
ReceiverAgentID uint `json:"receiver_agent_id"`
ReturnedAt time.Time `json:"returned_at"`
}

Some files were not shown because too many files have changed in this diff Show More