-
Notifications
You must be signed in to change notification settings - Fork 1
/
limit_profile.go
177 lines (154 loc) · 6.42 KB
/
limit_profile.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package monnify
import (
"fmt"
"net/http"
)
type (
// CreateLimitProfileReq request object
CreateLimitProfileReq struct {
LimitProfileName string `json:"limitProfileName"`
SingleTransactionValue string `json:"singleTransactionValue"`
DailyTransactionVolume string `json:"dailyTransactionVolume"`
DailyTransactionValue string `json:"dailyTransactionValue"`
LimitProfileCode string `json:"limitProfileCode"`
}
// CreateLimitProfileRes response object
CreateLimitProfileRes struct {
RequestSuccessful bool `json:"requestSuccessful"`
ResponseMessage string `json:"responseMessage"`
ResponseCode string `json:"responseCode"`
ResponseBody struct {
LimitProfileCode string `json:"limitProfileCode"`
LimitProfileName string `json:"limitProfileName"`
SingleTransactionValue string `json:"singleTransactionValue"`
DailyTransactionVolume string `json:"dailyTransactionVolume"`
DailyTransactionValue string `json:"dailyTransactionValue"`
DateCreated string `json:"dateCreated"`
LastModified string `json:"lastModified"`
} `json:"responseBody"`
}
// GetLimitProfilesRes response object
GetLimitProfilesRes struct {
RequestSuccessful bool `json:"requestSuccessful"`
ResponseMessage string `json:"responseMessage"`
ResponseCode string `json:"responseCode"`
ResponseBody []struct {
LimitProfileCode string `json:"limitProfileCode"`
LimitProfileName string `json:"limitProfileName"`
SingleTransactionValue string `json:"singleTransactionValue"`
DailyTransactionVolume string `json:"dailyTransactionVolume"`
DailyTransactionValue string `json:"dailyTransactionValue"`
DateCreated string `json:"dateCreated"`
LastModified string `json:"lastModified"`
} `json:"responseBody"`
}
// UpdateLimitProfileReq request object
UpdateLimitProfileReq struct {
LimitProfileName string `json:"limitProfileName"`
SingleTransactionValue string `json:"singleTransactionValue"`
DailyTransactionVolume string `json:"dailyTransactionVolume"`
DailyTransactionValue string `json:"dailyTransactionValue"`
LimitProfileCode string
}
// ReserveAcctWithLimitReq request object
ReserveAcctWithLimitReq struct {
ContractCode string `json:"contractCode"`
AccountName string `json:"accountName"`
CurrencyCode string `json:"currencyCode"`
AccountReference string `json:"accountReference"`
CustomerEmail string `json:"customerEmail"`
CustomerName string `json:"customerName"`
LimitProfileCode string `json:"limitProfileCode"`
}
// ReserveAcctWithLimitRes response object
ReserveAcctWithLimitRes struct {
RequestSuccessful bool `json:"requestSuccessful"`
ResponseMessage string `json:"responseMessage"`
ResponseCode string `json:"responseCode"`
ResponseBody struct {
ContractCode string `json:"contractCode"`
AccountReference string `json:"accountReference"`
AccountName string `json:"accountName"`
CurrencyCode string `json:"currencyCode"`
CustomerEmail string `json:"customerEmail"`
CustomerName string `json:"customerName"`
AccountNumber string `json:"accountNumber"`
BankName string `json:"bankName"`
BankCode string `json:"bankCode"`
ReservationReference string `json:"reservationReference"`
Status string `json:"status"`
CreatedOn string `json:"createdOn"`
LimitProfileConfig struct {
LimitProfileCode string `json:"limitProfileCode"`
SingleTransactionValue int `json:"singleTransactionValue"`
DailyTransactionVolume int `json:"dailyTransactionVolume"`
DailyTransactionValue int `json:"dailyTransactionValue"`
} `json:"limitProfileConfig"`
} `json:"responseBody"`
}
// UpdateReserveAcctWithLimitReq request object
UpdateReserveAcctWithLimitReq struct {
AccountReference string `json:"accountReference"`
LimitProfileCode string `json:"limitProfileCode"`
}
)
// CreateLimitProfile creates limit profiles on a customer's account
func (c *Client) CreateLimitProfile(payload CreateLimitProfileReq) (*CreateLimitProfileRes, error) {
url := fmt.Sprintf("%s/v1/limit-profile", c.baseURL)
c.isBasic = false
var response CreateLimitProfileRes
if err := c.newRequest(http.MethodPut, url, nil, response); err != nil {
if err = c.generateNewBearerToken(); err != nil {
return nil, err
}
}
return &response, nil
}
// GetLimitProfiles returns the list of all Limit Profiles that have been created for your customers
func (c *Client) GetLimitProfiles() (*GetLimitProfilesRes, error) {
url := fmt.Sprintf("%s/v1/limit-profile", c.baseURL)
c.isBasic = false
var response GetLimitProfilesRes
if err := c.newRequest(http.MethodPut, url, nil, response); err != nil {
if err = c.generateNewBearerToken(); err != nil {
return nil, err
}
}
return &response, nil
}
// UpdateLimitProfile updates the information on an existing Limit Profile
func (c *Client) UpdateLimitProfile(payload UpdateLimitProfileReq) (*CreateLimitProfileRes, error) {
url := fmt.Sprintf("%s/v1/limit-profile/%s", c.baseURL, payload.LimitProfileCode)
c.isBasic = false
var response CreateLimitProfileRes
if err := c.newRequest(http.MethodPut, url, payload, response); err != nil {
if err = c.generateNewBearerToken(); err != nil {
return nil, err
}
}
return &response, nil
}
// ReserveAcctWithLimit reserves an account for your customers with a transaction limit profile on it
func (c *Client) ReserveAcctWithLimit(payload ReserveAcctWithLimitReq) (*ReserveAcctWithLimitRes, error) {
url := fmt.Sprintf("%s/v1/bank-transfer/reserved-accounts/limit", c.baseURL)
c.isBasic = false
var response ReserveAcctWithLimitRes
if err := c.newRequest(http.MethodPost, url, payload, response); err != nil {
if err = c.generateNewBearerToken(); err != nil {
return nil, err
}
}
return &response, nil
}
// UpdateReserveAcctWithLimit updates the information on an existing Limit Profile for a Reserved Account
func (c *Client) UpdateReserveAcctWithLimit(payload UpdateReserveAcctWithLimitReq) (*ReserveAcctWithLimitRes, error) {
url := fmt.Sprintf("%s/v1/bank-transfer/reserved-accounts/limit", c.baseURL)
c.isBasic = false
var response ReserveAcctWithLimitRes
if err := c.newRequest(http.MethodPut, url, payload, response); err != nil {
if err = c.generateNewBearerToken(); err != nil {
return nil, err
}
}
return &response, nil
}