-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallet.go
39 lines (32 loc) · 887 Bytes
/
wallet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package dto
import (
"time"
"github.com/elojah/wallet/pkg/errors"
"github.com/oklog/ulid"
)
// PostResp response format for POST /wallet
type PostResp struct {
ID string `json:"id"`
}
// PostHistoryReq request format for POST /wallet-history
type PostHistoryReq struct {
WalletID string `json:"wallet_id"`
StartDate time.Time `json:"start_date"`
EndDate time.Time `json:"end_date"`
}
// Check checks params validity.
func (req PostHistoryReq) Check() error {
if _, err := ulid.Parse(req.WalletID); err != nil {
return errors.ErrInvalidField{Field: "wallet_id", Value: req.WalletID}
}
return nil
}
// Wallet represents wallet domain type for API.
type Wallet struct {
Date time.Time `json:"date"`
Amount string `json:"amount"`
}
// PostHistoryResp response format for POST /wallet-history
type PostHistoryResp struct {
History []Wallet `json:"history"`
}