Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorForbidden = Response{Code: http.StatusForbidden, Message: "Forbidden"} ErrorRequiredField = Response{Code: http.StatusBadRequest, Message: "Required field"} ErrorInternal = Response{Code: http.StatusInternalServerError, Message: "Internal Server Error"} ErrorBadRequest = Response{Code: http.StatusBadRequest, Message: "Bad Request"} ErrorNoRecords = Response{Code: http.StatusOK, Message: "No records found"} ErrorNotFound = Response{Code: http.StatusNotFound, Message: "No records found"} ErrNotEnoughBalance = errors.New("not enough balance") ErrNoCurrencyOrUserRecorded = errors.New("no user or balance with requested currency") )
View Source
var ( SuccessCreateBalance = Response{Code: 200, Message: "Balance added successfully"} SuccessCreateTransaction = Response{Code: 200, Message: "Transaction successful"} Success = Response{Code: 200, Message: "success"} )
Functions ¶
This section is empty.
Types ¶
type CreateTransactionPayload ¶
type CreateTransactionPayload struct { RecipientBankAccountNumber string `json:"recipientBankAccountNumber"` RecipientBankName string `json:"recipientBankName"` Balances int `json:"balances"` FromCurrency string `json:"fromCurrency"` UserID string }
func (CreateTransactionPayload) Validate ¶
func (p CreateTransactionPayload) Validate() error
type CreateUserBalancePayload ¶
type CreateUserBalancePayload struct { SenderBankAccountNumber string `json:"senderBankAccountNumber"` SenderBankName string `json:"senderBankName"` AddedBalance int `json:"addedBalance"` Currency string `json:"currency"` TransferProofImg string `json:"transferProofImg"` UserID string }
func (CreateUserBalancePayload) Validate ¶
func (p CreateUserBalancePayload) Validate() error
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) ListTransaction ¶
func (h *Handler) ListTransaction(w http.ResponseWriter, r *http.Request)
func (*Handler) Transaction ¶
func (h *Handler) Transaction(w http.ResponseWriter, r *http.Request)
type ListUserBalancePayload ¶
type ListUserBalancePayload struct {
UserID string
}
type Repository ¶
type Repository interface { RecordBalance(ctx context.Context, payload CreateUserBalancePayload) error RecordTransaction(ctx context.Context, payload CreateTransactionPayload) error FindByUserID(ctx context.Context, userID string) ([]UserBalanceResponse, error) ListTransactions(ctx context.Context, payload ListUserTransactionPayload) ([]UserTransaction, *response.Pagination, error) }
func NewRepository ¶
func NewRepository(db *db.DB) Repository
type Service ¶
type Service interface { Create(ctx context.Context, req CreateUserBalancePayload) Response CreateTransaction(ctx context.Context, req CreateTransactionPayload) Response List(ctx context.Context, req ListUserBalancePayload) Response ListTransaction(ctx context.Context, req ListUserTransactionPayload) Response }
func NewService ¶
func NewService(repository Repository) Service
type UserBalance ¶
type UserBalanceResponse ¶
type UserTransaction ¶
type UserTransactionResponse ¶
type UserTransactionResponse struct { TransactionID string `json:"transactionId"` Balance int `json:"balance"` Currency string `json:"currency"` TransferProofImg string `json:"transferProofImg"` CreatedAt int64 `json:"createdAt"` Source struct { BankAccountNumber string `json:"bankAccountNumber"` BankName string `json:"bankName"` } `json:"source"` }
Click to show internal directories.
Click to hide internal directories.