mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-11-22 06:16:45 +01:00
Mohammed Sohail
eba329eefa
* All postgres related functions now live in internal/store. * Updated queries.sql file to match struct order (readibility) * Moved keystore -> store * Moved queries -> store * Removed pkg/postgres
44 lines
884 B
Go
44 lines
884 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/grassrootseconomics/cic-custodial/internal/custodial"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// HandleTxStatus route.
|
|
// GET: /api/track/:trackingId
|
|
// Route param:
|
|
// trackingId -> tracking UUID
|
|
// Returns array of tx status.
|
|
func HandleTrackTx(cu *custodial.Custodial) func(echo.Context) error {
|
|
return func(c echo.Context) error {
|
|
var (
|
|
txStatusRequest struct {
|
|
TrackingId string `param:"trackingId" validate:"required,uuid"`
|
|
}
|
|
)
|
|
|
|
if err := c.Bind(&txStatusRequest); err != nil {
|
|
return NewBadRequestError(err)
|
|
}
|
|
|
|
if err := c.Validate(txStatusRequest); err != nil {
|
|
return err
|
|
}
|
|
|
|
txs, err := cu.Store.GetTxStatus(c.Request().Context(), txStatusRequest.TrackingId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, OkResp{
|
|
Ok: true,
|
|
Result: H{
|
|
"transaction": txs,
|
|
},
|
|
})
|
|
}
|
|
}
|