@anitrack/patreon-wrapper 1.2.1 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +23 -8
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -14,7 +14,10 @@ type PatronType = {
|
|
|
14
14
|
note: string
|
|
15
15
|
currentEntitled: {
|
|
16
16
|
status: string
|
|
17
|
-
|
|
17
|
+
tier: {
|
|
18
|
+
id: number
|
|
19
|
+
title: string
|
|
20
|
+
}
|
|
18
21
|
cents: number
|
|
19
22
|
willPayCents: number
|
|
20
23
|
lifetimeCents: number
|
|
@@ -75,16 +78,26 @@ export class Patreon {
|
|
|
75
78
|
const res: any = await this.FetchAPI(
|
|
76
79
|
this.CleanQueryURL(
|
|
77
80
|
`campaigns/${this._CampaignID}/` +
|
|
78
|
-
`members ? include = user, currently_entitled_tiers & fields[member] = campaign_lifetime_support_cents, currently_entitled_amount_cents, email, full_name, is_follower, last_charge_date, last_charge_status, lifetime_support_cents, next_charge_date, note, patron_status, pledge_cadence, pledge_relationship_start, will_pay_amount_cents & fields[user] = social_connections`
|
|
81
|
+
`members ? include = user, currently_entitled_tiers & fields[member] = campaign_lifetime_support_cents, currently_entitled_amount_cents, email, full_name, is_follower, last_charge_date, last_charge_status, lifetime_support_cents, next_charge_date, note, patron_status, pledge_cadence, pledge_relationship_start, will_pay_amount_cents & fields[user] = social_connections & fields[tier] = title`
|
|
79
82
|
)
|
|
80
83
|
)
|
|
81
84
|
|
|
82
85
|
const Patrons: Array<PatronType> = []
|
|
83
86
|
|
|
84
87
|
res.data.data.forEach((Patron: any) => {
|
|
85
|
-
|
|
88
|
+
// console.dir(Patron)
|
|
89
|
+
|
|
90
|
+
var socialInfo = res.data.included.find(
|
|
91
|
+
(includePatron: any) =>
|
|
92
|
+
includePatron.id == Patron.relationships.user.data.id &&
|
|
93
|
+
includePatron.type === 'user'
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
var tierInfo = res.data.included.find(
|
|
86
97
|
(includePatron: any) =>
|
|
87
|
-
includePatron.id ==
|
|
98
|
+
includePatron.id ==
|
|
99
|
+
Patron.relationships.currently_entitled_tiers?.data[0]
|
|
100
|
+
?.id && includePatron.type === 'tier'
|
|
88
101
|
)
|
|
89
102
|
|
|
90
103
|
Patrons.push({
|
|
@@ -96,8 +109,10 @@ export class Patreon {
|
|
|
96
109
|
note: Patron.attributes.note,
|
|
97
110
|
currentEntitled: {
|
|
98
111
|
status: Patron.attributes.patron_status,
|
|
99
|
-
|
|
100
|
-
|
|
112
|
+
tier: {
|
|
113
|
+
id: tierInfo.id,
|
|
114
|
+
title: tierInfo.attributes.title,
|
|
115
|
+
},
|
|
101
116
|
cents: Patron.attributes
|
|
102
117
|
.currently_entitled_amount_cents,
|
|
103
118
|
willPayCents: Patron.attributes.will_pay_amount_cents,
|
|
@@ -114,11 +129,11 @@ export class Patreon {
|
|
|
114
129
|
url: Patron.relationships.user.links.related,
|
|
115
130
|
},
|
|
116
131
|
discord: {
|
|
117
|
-
id:
|
|
132
|
+
id: socialInfo.attributes.social_connections.discord
|
|
118
133
|
.user_id,
|
|
119
134
|
url:
|
|
120
135
|
'https://discordapp.com/users/' +
|
|
121
|
-
|
|
136
|
+
socialInfo.attributes.social_connections.discord
|
|
122
137
|
.user_id,
|
|
123
138
|
},
|
|
124
139
|
},
|