-
Notifications
You must be signed in to change notification settings - Fork 3
/
member.go
74 lines (68 loc) · 2.8 KB
/
member.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 patreon
var (
// MemberDefaultIncludes specifies default includes for Member.
MemberDefaultIncludes = []string{"address", "campaign", "currently_entitled_tiers", "user"}
// MemberFields is all fields in the Member Attributes struct
MemberFields = getObjectFields(Member{}.Attributes)
)
// Member is the record of a user's membership to a campaign.
// Remains consistent across months of pledging.
type Member struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes MemberAttributes `json:"attributes"`
Relationships struct {
Address *AddressRelationship `json:"address,omitempty"`
Campaign *CampaignRelationship `json:"campaign,omitempty"`
CurrentlyEntitledTiers *TiersRelationship `json:"currently_entitled_tiers,omitempty"`
PledgeHistory *PledgeEventRelationship `json:"pledge_history,omitempty"`
User *UserRelationship `json:"user,omitempty"`
} `json:"relationships"`
}
// MemberAttributes is the attributes struct for Member
type MemberAttributes struct {
CampaignLifetimeSupportCents int `json:"campaign_lifetime_support_cents"`
CurrentlyEntitledAmountCents int `json:"currently_entitled_amount_cents"`
Email string `json:"email"`
FullName string `json:"full_name"`
IsFollower bool `json:"is_follower"`
LastChargeDate NullTime `json:"last_charge_date"`
LastChargeStatus string `json:"last_charge_status"`
LifetimeSupportCents int `json:"lifetime_support_cents"`
NextChargeDate NullTime `json:"next_charge_date"`
Note string `json:"note"`
PatronStatus string `json:"patron_status"`
PledgeCadence int `json:"pledge_cadence"`
PledgeRelationshipStart NullTime `json:"pledge_relationship_start"`
WillPayAmountCents int `json:"will_pay_amount_cents"`
}
// MemberResponse wraps Patreon's fetch benefit API response
type MemberResponse struct {
Data Member `json:"data"`
Included Includes `json:"included"`
Links struct {
Self string `json:"self"`
} `json:"links"`
}
// MembersResponse wraps Patreon's fetch benefit API response
type MembersResponse struct {
Data []Member `json:"data"`
Included Includes `json:"included"`
Links struct {
First string `json:"first"`
Last string `json:"last"`
Next string `json:"next"`
Prev string `json:"prev"`
} `json:"links"`
Meta struct {
Pagination struct {
Cursors struct {
First string `json:"first"`
Last string `json:"last"`
Next string `json:"next"`
Prev string `json:"prev"`
} `json:"cursors"`
} `json:"pagination"`
Count int `json:"count"`
} `json:"meta"`
}