forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapability.go
92 lines (79 loc) · 3.51 KB
/
capability.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
package stripe
import "encoding/json"
// CapabilityDisabledReason describes why a capability is disabled.
type CapabilityDisabledReason string
// List of values that CapabilityDisabledReason can take.
const (
CapabilityDisabledReasonPendingOnboarding CapabilityDisabledReason = "pending.onboarding"
CapabilityDisabledReasonPendingReview CapabilityDisabledReason = "pending.review"
CapabilityDisabledReasonRejectedFraud CapabilityDisabledReason = "rejected_fraud"
CapabilityDisabledReasonRejectedListed CapabilityDisabledReason = "rejected.listed"
CapabilityDisabledReasonRejectedOther CapabilityDisabledReason = "rejected.other"
CapabilityDisabledReasonRequirementsFieldsNeeded CapabilityDisabledReason = "requirement.fields_needed"
)
// CapabilityStatus describes the different statuses for a capability's status.
type CapabilityStatus string
// List of values that CapabilityStatus can take.
const (
CapabilityStatusActive CapabilityStatus = "active"
CapabilityStatusInactive CapabilityStatus = "inactive"
CapabilityStatusPending CapabilityStatus = "pending"
CapabilityStatusUnrequested CapabilityStatus = "unrequested"
)
// CapabilityParams is the set of parameters that can be used when updating a capability.
// For more details see https://stripe.com/docs/api/capabilities/update
type CapabilityParams struct {
Params `form:"*"`
Account *string `form:"-"` // Included in URL
Requested *bool `form:"requested"`
}
// CapabilityListParams is the set of parameters that can be used when listing capabilities.
// For more detail see https://stripe.com/docs/api/capabilities/list
type CapabilityListParams struct {
ListParams `form:"*"`
Account *string `form:"-"` // Included in URL
}
// CapabilityRequirements represents information that needs to be collected for a capability.
type CapabilityRequirements struct {
CurrentDeadline int64 `json:"current_deadline"`
CurrentlyDue []string `json:"currently_due"`
DisabledReason CapabilityDisabledReason `json:"disabled_reason"`
Errors []*AccountRequirementsError `json:"errors"`
EventuallyDue []string `json:"eventually_due"`
PastDue []string `json:"past_due"`
PendingVerification []string `json:"pending_verification"`
}
// Capability is the resource representing a Stripe capability.
// For more details see https://stripe.com/docs/api/capabilities
type Capability struct {
APIResource
Account *Account `json:"account"`
ID string `json:"id"`
Object string `json:"object"`
Requested bool `json:"requested"`
RequestedAt int64 `json:"requested_at"`
Requirements *CapabilityRequirements `json:"requirements"`
Status CapabilityStatus `json:"status"`
}
// CapabilityList is a list of capabilities as retrieved from a list endpoint.
type CapabilityList struct {
APIResource
ListMeta
Data []*Capability `json:"data"`
}
// UnmarshalJSON handles deserialization of a Capability.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (c *Capability) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type capability Capability
var v capability
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Capability(v)
return nil
}