-
Notifications
You must be signed in to change notification settings - Fork 0
/
source.go
74 lines (63 loc) · 2.68 KB
/
source.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
package zoop
import "fmt"
const (
sourcePath = "marketplaces/%s/sources"
sourcePathId = "marketplaces/%s/sources/%s"
)
// Get sources's detail
func (c *Client) GetSource(id string) (*Source, error) {
model := new(Source)
err := c.Get(fmt.Sprintf(sourcePathId, c.MarketplaceId, id), nil, nil, model)
return model, err
}
// Create a new source
func (c *Client) NewSource(params *SourceParams) (*Source, error) {
model := new(Source)
err := c.Post(fmt.Sprintf(sourcePath, c.MarketplaceId), params, nil, model)
return model, err
}
// Delete source by ID
func (c *Client) DelSource(id string) (*DeleteResponse, error) {
del := new(DeleteResponse)
err := c.Delete(fmt.Sprintf(sourcePathId, c.MarketplaceId, id), nil, nil, del)
return del, err
}
type Source struct {
}
type SourceParams struct {
Usage UsageType `json:"usage,omitempty"`
Amount int `json:"amount,omitempty"`
Currency string `json:"currency,omitempty"`
Description string `json:"description,omitempty"`
Type SourceType `json:"type,omitempty"`
Capture bool `json:"capture,omitempty"`
OnBehalfOf string `json:"on_behalf_of,omitempty"`
ReferenceId string `json:"reference_id,omitempty"`
StatementDescriptor string `json:"statement_descriptor,omitempty"`
Card *SourceCardParams `json:"card,omitempty"`
Customer *SourceCustomerParams `json:"customer,omitempty"`
Token *SourceTokenParams `json:"token,omitempty"`
InstallmentPlan *InstallmentPlanParams `json:"installment_plan,omitempty"`
Metadata interface{} `json:"metadata,omitempty"`
}
type SourceCardParams struct {
CardId string `json:"card.id,omitempty"`
CardHolderName string `json:"card.holder_name,omitempty"`
CardExpirationMonth string `json:"card.expiration_month,omitempty"`
CardExpirationYear string `json:"card.expiration_year,omitempty"`
CardCardNumber string `json:"card.card_number,omitempty"`
CardSecurityCode string `json:"card.security_code,omitempty"`
CardAmount int `json:"card.amount,omitempty"`
}
type InstallmentPlanParams struct {
Mode InstallmentPlanType `json:"mode,omitempty"`
NumberInstallments int `json:"number_installments,omitempty"`
}
type SourceCustomerParams struct {
CustomerId string `json:"id,omitempty"`
CustomerAmount int `json:"amount,omitempty"`
}
type SourceTokenParams struct {
TokenId string `json:"id,omitempty"`
TokenAmount int `json:"amount,omitempty"`
}