@anitrack/patreon-wrapper 1.4.5 → 1.5.0
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/README.md +1 -1
- package/lib/index.d.ts +17 -17
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +80 -78
- package/lib/index.js.map +1 -1
- package/package.json +36 -36
- package/src/index.ts +139 -130
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
🌄 You can also simulates sandbox of fake Patrons for development and code testing purposes
|
|
6
6
|
|
|
7
|
-
🍊 This package was
|
|
7
|
+
🍊 This package was previously used in [AniTrack](https://anitrack.co) before switching to a real payment gateway
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
10
10
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export type PatronStatus = 'active_patron' | 'declined_patron' | 'former_patron';
|
|
2
|
+
export type PatronAPIAuth = {
|
|
2
3
|
AccessToken: string;
|
|
3
4
|
CampaignID: string;
|
|
4
5
|
};
|
|
5
|
-
|
|
6
|
+
export type PatronType = {
|
|
6
7
|
displayId: string;
|
|
7
8
|
displayName: string;
|
|
8
9
|
emailAddress: string;
|
|
@@ -10,7 +11,7 @@ declare type PatronType = {
|
|
|
10
11
|
subscription: {
|
|
11
12
|
note: string;
|
|
12
13
|
currentEntitled: {
|
|
13
|
-
status:
|
|
14
|
+
status: PatronStatus;
|
|
14
15
|
tier: {
|
|
15
16
|
id: string;
|
|
16
17
|
title: string;
|
|
@@ -29,12 +30,12 @@ declare type PatronType = {
|
|
|
29
30
|
url: string;
|
|
30
31
|
};
|
|
31
32
|
discord: {
|
|
32
|
-
id: string;
|
|
33
|
-
url: string;
|
|
33
|
+
id: string | null;
|
|
34
|
+
url: string | null;
|
|
34
35
|
};
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
+
export type SandboxOptions = {
|
|
38
39
|
displayId: string;
|
|
39
40
|
displayName: string;
|
|
40
41
|
emailAddress: string;
|
|
@@ -45,7 +46,7 @@ declare type SandboxOptions = {
|
|
|
45
46
|
cents: number;
|
|
46
47
|
willPayCents: number;
|
|
47
48
|
lifetimeCents: number;
|
|
48
|
-
patronStatus:
|
|
49
|
+
patronStatus: PatronStatus;
|
|
49
50
|
firstCharge: string;
|
|
50
51
|
nextCharge: string;
|
|
51
52
|
lastCharge: string;
|
|
@@ -55,8 +56,8 @@ declare type SandboxOptions = {
|
|
|
55
56
|
url: string;
|
|
56
57
|
};
|
|
57
58
|
discord: {
|
|
58
|
-
id: string;
|
|
59
|
-
url: string;
|
|
59
|
+
id: string | null;
|
|
60
|
+
url: string | null;
|
|
60
61
|
};
|
|
61
62
|
};
|
|
62
63
|
};
|
|
@@ -65,16 +66,15 @@ export declare class Patreon {
|
|
|
65
66
|
private static _AccessToken;
|
|
66
67
|
private static _CampaignID;
|
|
67
68
|
private static _SandboxPatrons;
|
|
68
|
-
static Authorization(
|
|
69
|
+
static Authorization(AuthCredentials: PatronAPIAuth): void;
|
|
69
70
|
private static FetchAPI;
|
|
70
|
-
private static
|
|
71
|
-
static FetchPatrons(filters?: Array<
|
|
72
|
-
protected static
|
|
73
|
-
protected static
|
|
71
|
+
private static CleanURL;
|
|
72
|
+
static FetchPatrons(filters?: Array<PatronStatus>, pageSize?: number): Promise<PatronType[]>;
|
|
73
|
+
protected static _SandboxAddPatron(Patron: SandboxOptions): void;
|
|
74
|
+
protected static _SandboxGetPatron(): SandboxOptions[];
|
|
74
75
|
}
|
|
75
76
|
export declare class Sandbox extends Patreon {
|
|
76
|
-
static
|
|
77
|
-
static
|
|
77
|
+
static GetSandboxPatrons(): SandboxOptions[];
|
|
78
|
+
static AddSandboxPatron(Patron: SandboxOptions): void;
|
|
78
79
|
}
|
|
79
|
-
export {};
|
|
80
80
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAClB,eAAe,GACf,iBAAiB,GACjB,eAAe,CAAC;AAEtB,MAAM,MAAM,aAAa,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE;YACb,MAAM,EAAE,YAAY,CAAC;YACrB,IAAI,EAAE;gBACF,EAAE,EAAE,MAAM,CAAC;gBACX,KAAK,EAAE,MAAM,CAAC;aACjB,CAAC;YACF,KAAK,EAAE,MAAM,CAAC;YACd,YAAY,EAAE,MAAM,CAAC;YACrB,aAAa,EAAE,MAAM,CAAC;YACtB,WAAW,EAAE,MAAM,CAAC;YACpB,UAAU,EAAE,MAAM,CAAC;YACnB,UAAU,EAAE,MAAM,CAAC;SACtB,CAAC;KACL,CAAC;IACF,eAAe,EAAE;QACb,OAAO,EAAE;YACL,EAAE,EAAE,MAAM,CAAC;YACX,GAAG,EAAE,MAAM,CAAC;SACf,CAAC;QACF,OAAO,EAAE;YACL,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;YAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;SACtB,CAAC;KACL,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE;QACF,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE;QACb,OAAO,EAAE;YACL,EAAE,EAAE,MAAM,CAAC;YACX,GAAG,EAAE,MAAM,CAAC;SACf,CAAC;QACF,OAAO,EAAE;YACL,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;YAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;SACtB,CAAC;KACL,CAAC;CACL,CAAC;AAEF,qBAAa,OAAO;IAChB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAoD;IAEvE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAS;IACnC,OAAO,CAAC,MAAM,CAAC,eAAe,CAA6B;WAE7C,aAAa,CAAC,eAAe,EAAE,aAAa;mBAWrC,QAAQ;IAe7B,OAAO,CAAC,MAAM,CAAC,QAAQ;WAOH,YAAY,CAC5B,OAAO,GAAE,KAAK,CAAC,YAAY,CAAqB,EAChD,QAAQ,GAAE,MAAY;IA8H1B,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc;IAIzD,SAAS,CAAC,MAAM,CAAC,iBAAiB;CAOrC;AAED,qBAAa,OAAQ,SAAQ,OAAO;WAClB,iBAAiB;WAIjB,gBAAgB,CAAC,MAAM,EAAE,cAAc;CAGxD"}
|
package/lib/index.js
CHANGED
|
@@ -6,16 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Sandbox = exports.Patreon = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
class Patreon {
|
|
9
|
-
static Authorization(
|
|
10
|
-
if (!
|
|
9
|
+
static Authorization(AuthCredentials) {
|
|
10
|
+
if (!AuthCredentials.AccessToken || !AuthCredentials.CampaignID) {
|
|
11
11
|
throw new Error('AccessToken and CampaignID are required on Authorization');
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error('Invalid input, not a type of String');
|
|
16
|
-
}
|
|
17
|
-
this._AccessToken = AuthInformation.AccessToken;
|
|
18
|
-
this._CampaignID = AuthInformation.CampaignID;
|
|
13
|
+
this._AccessToken = AuthCredentials.AccessToken;
|
|
14
|
+
this._CampaignID = AuthCredentials.CampaignID;
|
|
19
15
|
}
|
|
20
16
|
static async FetchAPI(URI) {
|
|
21
17
|
if (!this._AccessToken || !this._CampaignID) {
|
|
@@ -28,90 +24,96 @@ class Patreon {
|
|
|
28
24
|
throw new Error('Fetch API Failed...' + err);
|
|
29
25
|
});
|
|
30
26
|
}
|
|
31
|
-
static
|
|
27
|
+
static CleanURL(query) {
|
|
32
28
|
query = query.replaceAll('[', '%5B').replaceAll(']', '%5D');
|
|
33
29
|
query = query.replaceAll(' ', '');
|
|
34
30
|
return query;
|
|
35
31
|
}
|
|
36
32
|
static async FetchPatrons(filters = ['active_patron'], pageSize = 450) {
|
|
37
|
-
const
|
|
33
|
+
const { data } = await this.FetchAPI(this.CleanURL(`campaigns/${this._CampaignID}/` +
|
|
38
34
|
`members ? include = user, currently_entitled_tiers & page[count] = ${pageSize} & 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`));
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (res.data.data.length == 0)
|
|
35
|
+
const Patrons = [];
|
|
36
|
+
const PatreonAPIPatrons = data?.data || [];
|
|
37
|
+
if (PatreonAPIPatrons.length == 0)
|
|
43
38
|
return [];
|
|
44
|
-
//
|
|
45
|
-
this._SandboxPatrons.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
39
|
+
// Format Sandbox Patrons
|
|
40
|
+
for (let x = 0; x < this._SandboxPatrons.length; x++) {
|
|
41
|
+
const Patron = this._SandboxPatrons[x];
|
|
42
|
+
Patrons.push({
|
|
43
|
+
displayId: Patron.displayId,
|
|
44
|
+
displayName: Patron.displayName,
|
|
45
|
+
emailAddress: Patron.emailAddress,
|
|
46
|
+
isFollower: false,
|
|
47
|
+
subscription: {
|
|
48
|
+
note: 'Sandbox',
|
|
49
|
+
currentEntitled: {
|
|
50
|
+
status: Patron.patronStatus,
|
|
51
|
+
tier: {
|
|
52
|
+
id: Patron.tier.id,
|
|
53
|
+
title: Patron.tier.title,
|
|
54
|
+
},
|
|
55
|
+
cents: Patron.cents,
|
|
56
|
+
willPayCents: Patron.willPayCents,
|
|
57
|
+
lifetimeCents: Patron.lifetimeCents,
|
|
58
|
+
firstCharge: Patron.firstCharge,
|
|
59
|
+
nextCharge: Patron.nextCharge,
|
|
60
|
+
lastCharge: Patron.lastCharge,
|
|
57
61
|
},
|
|
58
|
-
cents: Patron.cents,
|
|
59
|
-
willPayCents: Patron.willPayCents,
|
|
60
|
-
lifetimeCents: Patron.lifetimeCents,
|
|
61
|
-
firstCharge: Patron.firstCharge,
|
|
62
|
-
nextCharge: Patron.nextCharge,
|
|
63
|
-
lastCharge: Patron.lastCharge,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
mediaConnection: {
|
|
67
|
-
patreon: {
|
|
68
|
-
id: Patron.mediaConnection.patreon.id,
|
|
69
|
-
url: Patron.mediaConnection.patreon.url,
|
|
70
62
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
mediaConnection: {
|
|
64
|
+
patreon: {
|
|
65
|
+
id: Patron.mediaConnection.patreon.id,
|
|
66
|
+
url: Patron.mediaConnection.patreon.url,
|
|
67
|
+
},
|
|
68
|
+
discord: {
|
|
69
|
+
id: Patron?.mediaConnection?.discord?.id
|
|
70
|
+
? Patron?.mediaConnection?.discord?.id
|
|
71
|
+
: null,
|
|
72
|
+
url: Patron?.mediaConnection?.discord?.url
|
|
73
|
+
? Patron?.mediaConnection?.discord?.id
|
|
74
|
+
: null,
|
|
75
|
+
},
|
|
74
76
|
},
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Format Real Patrons
|
|
80
|
+
for (let x = 0; x < PatreonAPIPatrons.length; x++) {
|
|
81
|
+
const Relationships = PatreonAPIPatrons[x].relationships;
|
|
82
|
+
const Attributes = PatreonAPIPatrons[x].attributes;
|
|
83
|
+
if (!filters.includes(Attributes.patron_status))
|
|
84
|
+
continue;
|
|
85
|
+
const socialInfo = data.included.find((patron) => patron.id == Relationships.user.data.id &&
|
|
86
|
+
patron.type === 'user');
|
|
87
|
+
const tierInfo = data.included.find((patron) => patron.id ==
|
|
88
|
+
Relationships.currently_entitled_tiers?.data[0]?.id &&
|
|
89
|
+
patron.type === 'tier');
|
|
86
90
|
Patrons.push({
|
|
87
|
-
displayId:
|
|
88
|
-
displayName:
|
|
89
|
-
emailAddress:
|
|
90
|
-
isFollower:
|
|
91
|
+
displayId: Relationships.user.data.id,
|
|
92
|
+
displayName: Attributes.full_name,
|
|
93
|
+
emailAddress: Attributes.email,
|
|
94
|
+
isFollower: Attributes.is_follower,
|
|
91
95
|
subscription: {
|
|
92
|
-
note:
|
|
96
|
+
note: Attributes.note,
|
|
93
97
|
currentEntitled: {
|
|
94
|
-
status:
|
|
98
|
+
status: Attributes.patron_status,
|
|
95
99
|
tier: {
|
|
96
100
|
id: tierInfo ? tierInfo.id : null,
|
|
97
|
-
title: tierInfo ? tierInfo.
|
|
101
|
+
title: tierInfo ? tierInfo.Attributes.title : null,
|
|
98
102
|
},
|
|
99
|
-
cents:
|
|
100
|
-
|
|
101
|
-
? Patron.attributes
|
|
102
|
-
.currently_entitled_amount_cents
|
|
103
|
+
cents: Attributes.currently_entitled_amount_cents != 0
|
|
104
|
+
? Attributes.currently_entitled_amount_cents
|
|
103
105
|
: null,
|
|
104
|
-
willPayCents:
|
|
105
|
-
lifetimeCents:
|
|
106
|
-
firstCharge:
|
|
107
|
-
nextCharge:
|
|
108
|
-
lastCharge:
|
|
106
|
+
willPayCents: Attributes.will_pay_amount_cents,
|
|
107
|
+
lifetimeCents: Attributes.lifetime_support_cents,
|
|
108
|
+
firstCharge: Attributes.pledge_relationship_start,
|
|
109
|
+
nextCharge: Attributes.next_charge_date,
|
|
110
|
+
lastCharge: Attributes.last_charge_date,
|
|
109
111
|
},
|
|
110
112
|
},
|
|
111
113
|
mediaConnection: {
|
|
112
114
|
patreon: {
|
|
113
|
-
id:
|
|
114
|
-
url:
|
|
115
|
+
id: Relationships.user.data.id,
|
|
116
|
+
url: Relationships.user.links.related,
|
|
115
117
|
},
|
|
116
118
|
discord: {
|
|
117
119
|
id: socialInfo?.attributes?.social_connections?.discord
|
|
@@ -128,13 +130,13 @@ class Patreon {
|
|
|
128
130
|
},
|
|
129
131
|
},
|
|
130
132
|
});
|
|
131
|
-
}
|
|
133
|
+
}
|
|
132
134
|
return Patrons;
|
|
133
135
|
}
|
|
134
|
-
static
|
|
136
|
+
static _SandboxAddPatron(Patron) {
|
|
135
137
|
this._SandboxPatrons.push(Patron);
|
|
136
138
|
}
|
|
137
|
-
static
|
|
139
|
+
static _SandboxGetPatron() {
|
|
138
140
|
return this._SandboxPatrons;
|
|
139
141
|
}
|
|
140
142
|
}
|
|
@@ -142,11 +144,11 @@ exports.Patreon = Patreon;
|
|
|
142
144
|
Patreon._URL = 'https://www.patreon.com/api/oauth2/v2/';
|
|
143
145
|
Patreon._SandboxPatrons = [];
|
|
144
146
|
class Sandbox extends Patreon {
|
|
145
|
-
static
|
|
146
|
-
return super.
|
|
147
|
+
static GetSandboxPatrons() {
|
|
148
|
+
return super._SandboxGetPatron();
|
|
147
149
|
}
|
|
148
|
-
static
|
|
149
|
-
super.
|
|
150
|
+
static AddSandboxPatron(Patron) {
|
|
151
|
+
super._SandboxAddPatron(Patron);
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
exports.Sandbox = Sandbox;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAwE1B,MAAa,OAAO;IAOT,MAAM,CAAC,aAAa,CAAC,eAA8B;QACtD,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;YAC7D,MAAM,IAAI,KAAK,CACX,0DAA0D,CAC7D,CAAC;SACL;QAED,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,WAAW,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,eAAe,CAAC,UAAU,CAAC;IAClD,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAW;QACrC,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACzC,MAAM,IAAI,KAAK,CACX,0DAA0D,CAC7D,CAAC;SACL;QAED,OAAO,MAAM,IAAA,eAAK,EAAC,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE;YAChC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,aAAa,EAAE,SAAS,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KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACJ;AARD,0BAQC"}
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@anitrack/patreon-wrapper",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Universal Patron API v2 wrapper that simplifies the API's response for easier usage and lower response complexity",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"types": "lib",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc -p .",
|
|
9
|
-
"dev": "tsc-watch --onSuccess \"node lib/devTEST.js\""
|
|
10
|
-
},
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git://github.com/AniTrack/patreon-wrapper.git"
|
|
14
|
-
},
|
|
15
|
-
"author": "AniTrack",
|
|
16
|
-
"keywords": [
|
|
17
|
-
"patreon",
|
|
18
|
-
"discord",
|
|
19
|
-
"api"
|
|
20
|
-
],
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"bugs": {
|
|
23
|
-
"url": "https://github.com/AniTrack/patreon-wrapper/issues"
|
|
24
|
-
},
|
|
25
|
-
"homepage": "https://github.com/AniTrack/patreon-wrapper#readme",
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"axios": "^0.27.2"
|
|
28
|
-
},
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"ts-node": "^10.7.0",
|
|
34
|
-
"typescript": "^4.6.4"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@anitrack/patreon-wrapper",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Universal Patron API v2 wrapper that simplifies the API's response for easier usage and lower response complexity",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p .",
|
|
9
|
+
"dev": "tsc-watch --onSuccess \"node lib/devTEST.js\""
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git://github.com/AniTrack/patreon-wrapper.git"
|
|
14
|
+
},
|
|
15
|
+
"author": "AniTrack",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"patreon",
|
|
18
|
+
"discord",
|
|
19
|
+
"api"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/AniTrack/patreon-wrapper/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/AniTrack/patreon-wrapper#readme",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"axios": "^0.27.2"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"ts-node": "^10.7.0",
|
|
34
|
+
"typescript": "^4.6.4"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,131 +1,135 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
1
|
+
import axios from 'axios';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export type PatronStatus =
|
|
4
|
+
| 'active_patron'
|
|
5
|
+
| 'declined_patron'
|
|
6
|
+
| 'former_patron';
|
|
7
|
+
|
|
8
|
+
export type PatronAPIAuth = {
|
|
9
|
+
AccessToken: string;
|
|
10
|
+
CampaignID: string;
|
|
11
|
+
};
|
|
7
12
|
|
|
8
|
-
type PatronType = {
|
|
9
|
-
displayId: string
|
|
10
|
-
displayName: string
|
|
11
|
-
emailAddress: string
|
|
12
|
-
isFollower: boolean
|
|
13
|
+
export type PatronType = {
|
|
14
|
+
displayId: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
emailAddress: string;
|
|
17
|
+
isFollower: boolean;
|
|
13
18
|
subscription: {
|
|
14
|
-
note: string
|
|
19
|
+
note: string;
|
|
15
20
|
currentEntitled: {
|
|
16
|
-
status:
|
|
21
|
+
status: PatronStatus;
|
|
17
22
|
tier: {
|
|
18
|
-
id: string
|
|
19
|
-
title: string
|
|
20
|
-
}
|
|
21
|
-
cents: number
|
|
22
|
-
willPayCents: number
|
|
23
|
-
lifetimeCents: number
|
|
24
|
-
firstCharge: string
|
|
25
|
-
nextCharge: string
|
|
26
|
-
lastCharge: string
|
|
27
|
-
}
|
|
28
|
-
}
|
|
23
|
+
id: string;
|
|
24
|
+
title: string;
|
|
25
|
+
};
|
|
26
|
+
cents: number;
|
|
27
|
+
willPayCents: number;
|
|
28
|
+
lifetimeCents: number;
|
|
29
|
+
firstCharge: string;
|
|
30
|
+
nextCharge: string;
|
|
31
|
+
lastCharge: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
29
34
|
mediaConnection: {
|
|
30
35
|
patreon: {
|
|
31
|
-
id: string
|
|
32
|
-
url: string
|
|
33
|
-
}
|
|
36
|
+
id: string;
|
|
37
|
+
url: string;
|
|
38
|
+
};
|
|
34
39
|
discord: {
|
|
35
|
-
id: string
|
|
36
|
-
url: string
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
+
id: string | null;
|
|
41
|
+
url: string | null;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
40
45
|
|
|
41
|
-
type SandboxOptions = {
|
|
42
|
-
displayId: string
|
|
43
|
-
displayName: string
|
|
44
|
-
emailAddress: string
|
|
46
|
+
export type SandboxOptions = {
|
|
47
|
+
displayId: string;
|
|
48
|
+
displayName: string;
|
|
49
|
+
emailAddress: string;
|
|
45
50
|
tier: {
|
|
46
|
-
id: string
|
|
47
|
-
title: string
|
|
48
|
-
}
|
|
49
|
-
cents: number
|
|
50
|
-
willPayCents: number
|
|
51
|
-
lifetimeCents: number
|
|
52
|
-
patronStatus:
|
|
53
|
-
firstCharge: string
|
|
54
|
-
nextCharge: string
|
|
55
|
-
lastCharge: string
|
|
51
|
+
id: string;
|
|
52
|
+
title: string;
|
|
53
|
+
};
|
|
54
|
+
cents: number;
|
|
55
|
+
willPayCents: number;
|
|
56
|
+
lifetimeCents: number;
|
|
57
|
+
patronStatus: PatronStatus;
|
|
58
|
+
firstCharge: string;
|
|
59
|
+
nextCharge: string;
|
|
60
|
+
lastCharge: string;
|
|
56
61
|
mediaConnection: {
|
|
57
62
|
patreon: {
|
|
58
|
-
id: string
|
|
59
|
-
url: string
|
|
60
|
-
}
|
|
61
|
-
discord: {
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
id: string;
|
|
64
|
+
url: string;
|
|
65
|
+
};
|
|
66
|
+
discord: {
|
|
67
|
+
id: string | null;
|
|
68
|
+
url: string | null;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
64
72
|
|
|
65
73
|
export class Patreon {
|
|
66
|
-
private static _URL: string = 'https://www.patreon.com/api/oauth2/v2/'
|
|
74
|
+
private static _URL: string = 'https://www.patreon.com/api/oauth2/v2/';
|
|
67
75
|
|
|
68
|
-
private static _AccessToken: string
|
|
69
|
-
private static _CampaignID: string
|
|
76
|
+
private static _AccessToken: string;
|
|
77
|
+
private static _CampaignID: string;
|
|
78
|
+
private static _SandboxPatrons: Array<SandboxOptions> = [];
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
public static Authorization(AuthInformation: Auth) {
|
|
74
|
-
if (!AuthInformation.AccessToken || !AuthInformation.CampaignID) {
|
|
80
|
+
public static Authorization(AuthCredentials: PatronAPIAuth) {
|
|
81
|
+
if (!AuthCredentials.AccessToken || !AuthCredentials.CampaignID) {
|
|
75
82
|
throw new Error(
|
|
76
83
|
'AccessToken and CampaignID are required on Authorization'
|
|
77
|
-
)
|
|
78
|
-
} else if (
|
|
79
|
-
typeof AuthInformation.AccessToken != 'string' ||
|
|
80
|
-
typeof AuthInformation.CampaignID != 'string'
|
|
81
|
-
) {
|
|
82
|
-
throw new Error('Invalid input, not a type of String')
|
|
84
|
+
);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
this._AccessToken =
|
|
86
|
-
this._CampaignID =
|
|
87
|
+
this._AccessToken = AuthCredentials.AccessToken;
|
|
88
|
+
this._CampaignID = AuthCredentials.CampaignID;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
private static async FetchAPI(URI: string) {
|
|
90
92
|
if (!this._AccessToken || !this._CampaignID) {
|
|
91
93
|
throw new Error(
|
|
92
94
|
'AccessToken and CampaignID are required on Authorization'
|
|
93
|
-
)
|
|
95
|
+
);
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
return await axios(this._URL + URI, {
|
|
97
99
|
method: 'GET',
|
|
98
100
|
headers: { Authorization: 'Bearer ' + this._AccessToken },
|
|
99
101
|
}).catch((err: Error) => {
|
|
100
|
-
throw new Error('Fetch API Failed...' + err)
|
|
101
|
-
})
|
|
102
|
+
throw new Error('Fetch API Failed...' + err);
|
|
103
|
+
});
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
private static
|
|
105
|
-
query = query.replaceAll('[', '%5B').replaceAll(']', '%5D')
|
|
106
|
-
query = query.replaceAll(' ', '')
|
|
106
|
+
private static CleanURL(query: string) {
|
|
107
|
+
query = query.replaceAll('[', '%5B').replaceAll(']', '%5D');
|
|
108
|
+
query = query.replaceAll(' ', '');
|
|
107
109
|
|
|
108
|
-
return query
|
|
110
|
+
return query;
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
public static async FetchPatrons(
|
|
112
|
-
filters: Array<
|
|
114
|
+
filters: Array<PatronStatus> = ['active_patron'],
|
|
113
115
|
pageSize: number = 450
|
|
114
116
|
) {
|
|
115
|
-
const
|
|
116
|
-
this.
|
|
117
|
+
const { data } = await this.FetchAPI(
|
|
118
|
+
this.CleanURL(
|
|
117
119
|
`campaigns/${this._CampaignID}/` +
|
|
118
120
|
`members ? include = user, currently_entitled_tiers & page[count] = ${pageSize} & 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`
|
|
119
121
|
)
|
|
120
|
-
)
|
|
122
|
+
);
|
|
121
123
|
|
|
122
|
-
|
|
124
|
+
const Patrons: Array<PatronType> = [];
|
|
125
|
+
const PatreonAPIPatrons = data?.data || [];
|
|
123
126
|
|
|
124
|
-
if (
|
|
125
|
-
|
|
127
|
+
if (PatreonAPIPatrons.length == 0) return [];
|
|
128
|
+
|
|
129
|
+
// Format Sandbox Patrons
|
|
130
|
+
for (let x = 0; x < this._SandboxPatrons.length; x++) {
|
|
131
|
+
const Patron = this._SandboxPatrons[x];
|
|
126
132
|
|
|
127
|
-
// Processing Fake Sandbox Patrons
|
|
128
|
-
this._SandboxPatrons.forEach((Patron: SandboxOptions) =>
|
|
129
133
|
Patrons.push({
|
|
130
134
|
displayId: Patron.displayId,
|
|
131
135
|
displayName: Patron.displayName,
|
|
@@ -153,61 +157,65 @@ export class Patreon {
|
|
|
153
157
|
url: Patron.mediaConnection.patreon.url,
|
|
154
158
|
},
|
|
155
159
|
discord: {
|
|
156
|
-
id: Patron
|
|
157
|
-
|
|
160
|
+
id: Patron?.mediaConnection?.discord?.id
|
|
161
|
+
? Patron?.mediaConnection?.discord?.id
|
|
162
|
+
: null,
|
|
163
|
+
url: Patron?.mediaConnection?.discord?.url
|
|
164
|
+
? Patron?.mediaConnection?.discord?.id
|
|
165
|
+
: null,
|
|
158
166
|
},
|
|
159
167
|
},
|
|
160
|
-
})
|
|
161
|
-
|
|
168
|
+
});
|
|
169
|
+
}
|
|
162
170
|
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
// Format Real Patrons
|
|
172
|
+
for (let x = 0; x < PatreonAPIPatrons.length; x++) {
|
|
173
|
+
const Relationships = PatreonAPIPatrons[x].relationships;
|
|
174
|
+
const Attributes = PatreonAPIPatrons[x].attributes;
|
|
166
175
|
|
|
167
|
-
|
|
168
|
-
(includePatron: any) =>
|
|
169
|
-
includePatron.id == Patron.relationships.user.data.id &&
|
|
170
|
-
includePatron.type === 'user'
|
|
171
|
-
)
|
|
176
|
+
if (!filters.includes(Attributes.patron_status)) continue;
|
|
172
177
|
|
|
173
|
-
|
|
174
|
-
(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
const socialInfo = data.included.find(
|
|
179
|
+
(patron: any) =>
|
|
180
|
+
patron.id == Relationships.user.data.id &&
|
|
181
|
+
patron.type === 'user'
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const tierInfo = data.included.find(
|
|
185
|
+
(patron: any) =>
|
|
186
|
+
patron.id ==
|
|
187
|
+
Relationships.currently_entitled_tiers?.data[0]?.id &&
|
|
188
|
+
patron.type === 'tier'
|
|
189
|
+
);
|
|
179
190
|
|
|
180
191
|
Patrons.push({
|
|
181
|
-
displayId:
|
|
182
|
-
displayName:
|
|
183
|
-
emailAddress:
|
|
184
|
-
isFollower:
|
|
192
|
+
displayId: Relationships.user.data.id,
|
|
193
|
+
displayName: Attributes.full_name,
|
|
194
|
+
emailAddress: Attributes.email,
|
|
195
|
+
isFollower: Attributes.is_follower,
|
|
185
196
|
subscription: {
|
|
186
|
-
note:
|
|
197
|
+
note: Attributes.note,
|
|
187
198
|
currentEntitled: {
|
|
188
|
-
status:
|
|
199
|
+
status: Attributes.patron_status,
|
|
189
200
|
tier: {
|
|
190
201
|
id: tierInfo ? tierInfo.id : null,
|
|
191
|
-
title: tierInfo ? tierInfo.
|
|
202
|
+
title: tierInfo ? tierInfo.Attributes.title : null,
|
|
192
203
|
},
|
|
193
204
|
cents:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
? Patron.attributes
|
|
197
|
-
.currently_entitled_amount_cents
|
|
205
|
+
Attributes.currently_entitled_amount_cents != 0
|
|
206
|
+
? Attributes.currently_entitled_amount_cents
|
|
198
207
|
: null,
|
|
199
|
-
willPayCents:
|
|
200
|
-
lifetimeCents:
|
|
201
|
-
firstCharge:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
lastCharge: Patron.attributes.last_charge_date,
|
|
208
|
+
willPayCents: Attributes.will_pay_amount_cents,
|
|
209
|
+
lifetimeCents: Attributes.lifetime_support_cents,
|
|
210
|
+
firstCharge: Attributes.pledge_relationship_start,
|
|
211
|
+
nextCharge: Attributes.next_charge_date,
|
|
212
|
+
lastCharge: Attributes.last_charge_date,
|
|
205
213
|
},
|
|
206
214
|
},
|
|
207
215
|
mediaConnection: {
|
|
208
216
|
patreon: {
|
|
209
|
-
id:
|
|
210
|
-
url:
|
|
217
|
+
id: Relationships.user.data.id,
|
|
218
|
+
url: Relationships.user.links.related,
|
|
211
219
|
},
|
|
212
220
|
discord: {
|
|
213
221
|
id: socialInfo?.attributes?.social_connections?.discord
|
|
@@ -224,17 +232,18 @@ export class Patreon {
|
|
|
224
232
|
: null,
|
|
225
233
|
},
|
|
226
234
|
},
|
|
227
|
-
})
|
|
228
|
-
}
|
|
229
|
-
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return Patrons;
|
|
230
239
|
}
|
|
231
240
|
|
|
232
|
-
protected static
|
|
233
|
-
this._SandboxPatrons.push(Patron)
|
|
241
|
+
protected static _SandboxAddPatron(Patron: SandboxOptions) {
|
|
242
|
+
this._SandboxPatrons.push(Patron);
|
|
234
243
|
}
|
|
235
244
|
|
|
236
|
-
protected static
|
|
237
|
-
return this._SandboxPatrons
|
|
245
|
+
protected static _SandboxGetPatron() {
|
|
246
|
+
return this._SandboxPatrons;
|
|
238
247
|
}
|
|
239
248
|
|
|
240
249
|
// public static FetchPatron() {}
|
|
@@ -243,11 +252,11 @@ export class Patreon {
|
|
|
243
252
|
}
|
|
244
253
|
|
|
245
254
|
export class Sandbox extends Patreon {
|
|
246
|
-
public static
|
|
247
|
-
return super.
|
|
255
|
+
public static GetSandboxPatrons() {
|
|
256
|
+
return super._SandboxGetPatron();
|
|
248
257
|
}
|
|
249
258
|
|
|
250
|
-
public static
|
|
251
|
-
super.
|
|
259
|
+
public static AddSandboxPatron(Patron: SandboxOptions) {
|
|
260
|
+
super._SandboxAddPatron(Patron);
|
|
252
261
|
}
|
|
253
262
|
}
|