-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathbank.go
60 lines (52 loc) · 1.91 KB
/
bank.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
package paystack
import "fmt"
// BankService handles operations related to the bank
// For more details see https://developers.paystack.co/v1.0/reference#bank
type BankService service
// Bank represents a Paystack bank
type Bank struct {
ID int `json:"id,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
Name string `json:"name,omitempty"`
Slug string `json:"slug,omitempty"`
Code string `json:"code,omitempty"`
LongCode string `json:"long_code,omitempty"`
Gateway string `json:"gateway,omitempty"`
Active bool `json:"active,omitempty"`
IsDeleted bool `json:"is_deleted,omitempty"`
}
// BankList is a list object for banks.
type BankList struct {
Meta ListMeta
Values []Bank `json:"data,omitempty"`
}
// BVNResponse represents response from resolve_bvn endpoint
type BVNResponse struct {
Meta struct {
CallsThisMonth int `json:"calls_this_month,omitempty"`
FreeCallsLeft int `json:"free_calls_left,omitempty"`
}
BVN string
}
// List returns a list of all the banks.
// For more details see https://developers.paystack.co/v1.0/reference#list-banks
func (s *BankService) List() (*BankList, error) {
banks := &BankList{}
err := s.client.Call("GET", "/bank", nil, banks)
return banks, err
}
// ResolveBVN docs https://developers.paystack.co/v1.0/reference#resolve-bvn
func (s *BankService) ResolveBVN(bvn int) (*BVNResponse, error) {
u := fmt.Sprintf("/bank/resolve_bvn/%d", bvn)
resp := &BVNResponse{}
err := s.client.Call("GET", u, nil, resp)
return resp, err
}
// ResolveAccountNumber docs https://developers.paystack.co/v1.0/reference#resolve-account-number
func (s *BankService) ResolveAccountNumber(accountNumber, bankCode string) (Response, error) {
u := fmt.Sprintf("/bank/resolve?account_number=%s&bank_code=%s", accountNumber, bankCode)
resp := Response{}
err := s.client.Call("GET", u, nil, &resp)
return resp, err
}