-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsvc_paymentcard.go
88 lines (70 loc) · 2.6 KB
/
svc_paymentcard.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
package lokalise
import (
"fmt"
)
const (
pathPaymentCards = "payment_cards"
)
type PaymentCardService struct {
BaseService
}
type PaymentCard struct {
WithCreationTime
CardId int64 `json:"card_id"`
Last4 string `json:"last4"`
Brand string `json:"brand"`
}
// ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
// Service request/response objects
// _____________________________________________________________________________________________________________________
type CreatePaymentCard struct {
Number string `json:"number"`
CVC string `json:"cvc"`
ExpMonth int64 `json:"exp_month"`
ExpYear int64 `json:"exp_year"`
}
type PaymentCardsResponse struct {
Paged
WithUserID
Cards []PaymentCard `json:"payment_cards"`
}
type PaymentCardResponse struct {
WithUserID
Card PaymentCard `json:"payment_card"`
}
type DeletePaymentCardResponse struct {
CardID int64 `json:"card_id"`
Deleted bool `json:"card_deleted"`
}
// ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
// Service methods
// _____________________________________________________________________________________________________________________
func (c *PaymentCardService) Create(card CreatePaymentCard) (r PaymentCard, err error) {
resp, err := c.post(c.Ctx(), pathPaymentCards, &r, card)
if err != nil {
return
}
return r, apiError(resp)
}
func (c *PaymentCardService) List() (r PaymentCardsResponse, err error) {
resp, err := c.getWithOptions(c.Ctx(), pathPaymentCards, &r, c.PageOpts())
if err != nil {
return
}
applyPaged(resp, &r.Paged)
return r, apiError(resp)
}
func (c *PaymentCardService) Retrieve(cardID int64) (r PaymentCardResponse, err error) {
resp, err := c.get(c.Ctx(), fmt.Sprintf("%s/%d", pathPaymentCards, cardID), &r)
if err != nil {
return
}
return r, apiError(resp)
}
func (c *PaymentCardService) Delete(cardID int64) (r DeletePaymentCardResponse, err error) {
resp, err := c.delete(c.Ctx(), fmt.Sprintf("%s/%d", pathPaymentCards, cardID), &r)
if err != nil {
return
}
return r, apiError(resp)
}