@anitrack/patreon-wrapper 1.5.1 → 1.5.3
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 +50 -83
- package/lib/index.d.ts +79 -79
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +156 -154
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +49 -46
package/README.md
CHANGED
|
@@ -1,51 +1,35 @@
|
|
|
1
|
-
# Patreon Wrapper
|
|
1
|
+
# 🍊 Patreon Wrapper
|
|
2
2
|
|
|
3
|
-
💎
|
|
3
|
+
💎 Universal Patron API v2 wrapper that simplifies their API usage in JavaScript
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> This package was previously used on [AniTrack.co](https://anitrack.co) before switching to the payment gateway
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
# Table of Contents
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- [
|
|
12
|
-
- [Real usage example](#Usage%20Example)
|
|
13
|
-
- [Sandbox for development](#Sandboxing)
|
|
9
|
+
- [Install](#Install%20the%20package)
|
|
10
|
+
- [Getting Started](#Getting%20Started)
|
|
11
|
+
- [Sandbox for development](#Patreon%20Sandbox)
|
|
14
12
|
- [License](#license)
|
|
15
13
|
|
|
16
14
|
<br />
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Using NPM
|
|
16
|
+
# Install the package
|
|
21
17
|
|
|
22
18
|
```
|
|
23
19
|
$ npm install @anitrack/patreon-wrapper
|
|
24
20
|
```
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
$ yarn add @anitrack/patreon-wrapper
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Usage Example
|
|
33
|
-
|
|
34
|
-
### Importing
|
|
22
|
+
<br />
|
|
35
23
|
|
|
36
|
-
|
|
24
|
+
# Getting Started
|
|
37
25
|
|
|
38
26
|
```js
|
|
39
|
-
|
|
27
|
+
import { Patreon } from '@anitrack/patreon-wrapper';
|
|
40
28
|
```
|
|
41
29
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
import { Patreon } from '@anitrack/patreon-wrapper'
|
|
46
|
-
```
|
|
30
|
+
<br />
|
|
47
31
|
|
|
48
|
-
|
|
32
|
+
# API Authorization
|
|
49
33
|
|
|
50
34
|
> Where do I find Campaign ID? F12 your Patreon page and search for "campaign" then keep looking until you finds URL with campaign params that contains around 7 degits. That should be your Campaign ID
|
|
51
35
|
|
|
@@ -53,37 +37,30 @@ import { Patreon } from '@anitrack/patreon-wrapper'
|
|
|
53
37
|
Patreon.Authorization({
|
|
54
38
|
AccessToken: 'YOUR_API_V2_ACCESS_TOKEN',
|
|
55
39
|
CampaignID: 'YOUR_CAPAIGN_ID',
|
|
56
|
-
})
|
|
40
|
+
});
|
|
57
41
|
```
|
|
58
42
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Promies then catch
|
|
43
|
+
<br />
|
|
62
44
|
|
|
63
|
-
|
|
64
|
-
Patreon.FetchPatrons(['active_patron', 'declined_patron'])
|
|
65
|
-
.then((Patrons) => {
|
|
66
|
-
// Handle Patrons List
|
|
67
|
-
console.log(Patrons)
|
|
68
|
-
})
|
|
69
|
-
.catch((err) => {
|
|
70
|
-
// Handle Error
|
|
71
|
-
console.log(err)
|
|
72
|
-
})
|
|
73
|
-
```
|
|
45
|
+
# Package Usage
|
|
74
46
|
|
|
75
|
-
|
|
47
|
+
## Fetching every Patrons from the Campaign
|
|
76
48
|
|
|
77
49
|
```js
|
|
78
|
-
|
|
50
|
+
const Patrons = await Patreon.FetchPatrons([
|
|
51
|
+
'active_patron',
|
|
52
|
+
'declined_patron',
|
|
53
|
+
'former_patron',
|
|
54
|
+
]);
|
|
79
55
|
|
|
80
|
-
console.log(Patrons)
|
|
56
|
+
console.log(Patrons);
|
|
81
57
|
```
|
|
82
58
|
|
|
83
|
-
|
|
59
|
+
## Patron object example
|
|
60
|
+
|
|
61
|
+
console.log(Patrons) from above
|
|
84
62
|
|
|
85
63
|
```js
|
|
86
|
-
// Example response from fetching Patron list
|
|
87
64
|
[
|
|
88
65
|
{
|
|
89
66
|
displayId: '12345678',
|
|
@@ -98,10 +75,10 @@ Clean Response Example
|
|
|
98
75
|
id: '12345678',
|
|
99
76
|
title: 'My First Tier'
|
|
100
77
|
},
|
|
101
|
-
cents: 500,
|
|
78
|
+
cents: 500,
|
|
102
79
|
willPayCents: 500,
|
|
103
80
|
lifetimeCents: 1500,
|
|
104
|
-
firstCharge: '2022-01-15 15:00:00.000',
|
|
81
|
+
firstCharge: '2022-01-15 15:00:00.000',
|
|
105
82
|
nextCharge: '2022-05-15 15:00:00.000',
|
|
106
83
|
lastCharge: '2022-05-15 15:00:00.000'
|
|
107
84
|
}
|
|
@@ -117,33 +94,24 @@ Clean Response Example
|
|
|
117
94
|
}
|
|
118
95
|
}
|
|
119
96
|
},
|
|
120
|
-
{
|
|
121
|
-
...
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
97
|
...
|
|
125
|
-
}
|
|
126
98
|
]
|
|
127
99
|
```
|
|
128
100
|
|
|
129
101
|
<br />
|
|
130
102
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
> This is great for development and working with fake patrons users. The fake patrons object will be exactly the same as real ones!
|
|
103
|
+
# Patreon Sandbox
|
|
134
104
|
|
|
135
|
-
|
|
105
|
+
> This is great for development and working with sandbox patrons users. The sandbox patrons object will be exactly the same as real ones!
|
|
136
106
|
|
|
137
|
-
|
|
138
|
-
import { Patreon, Sandbox } from '@anitrack/patreon-wrapper'
|
|
139
|
-
```
|
|
107
|
+
## Adding Custom Patrons to the Sandbox
|
|
140
108
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
You can repeat this as much as you want
|
|
109
|
+
You can add as much sandbox patrons as you want
|
|
144
110
|
|
|
145
111
|
```js
|
|
146
|
-
Sandbox
|
|
112
|
+
import { Sandbox } from '@anitrack/patreon-wrapper';
|
|
113
|
+
|
|
114
|
+
Sandbox.AddPatron({
|
|
147
115
|
displayId: '123', // Patreon ID
|
|
148
116
|
displayName: '123', // Patreon Username
|
|
149
117
|
emailAddress: 'email@address.com', // Patreon Email
|
|
@@ -154,7 +122,7 @@ Sandbox.AppendPatron({
|
|
|
154
122
|
firstCharge: '2022-01-15 15:00:00.000', // ISO 8601 String date format
|
|
155
123
|
nextCharge: '2022-05-15 15:00:00.000',
|
|
156
124
|
lastCharge: '2022-04-15 15:00:00.000',
|
|
157
|
-
patronStatus: 'active_patron',
|
|
125
|
+
patronStatus: 'active_patron',
|
|
158
126
|
mediaConnection: {
|
|
159
127
|
patreon: {
|
|
160
128
|
id: '123',
|
|
@@ -162,29 +130,28 @@ Sandbox.AppendPatron({
|
|
|
162
130
|
},
|
|
163
131
|
discord: { id: '123', url: 'https://discord.com/users/user_id' },
|
|
164
132
|
},
|
|
165
|
-
})
|
|
166
|
-
```
|
|
133
|
+
});
|
|
167
134
|
|
|
168
|
-
|
|
135
|
+
const Patrons = Sandbox.GetPatrons();
|
|
169
136
|
|
|
170
|
-
|
|
171
|
-
Sandbox.GetFakePatrons()
|
|
137
|
+
console.log(Patrons);
|
|
172
138
|
```
|
|
173
139
|
|
|
174
|
-
|
|
140
|
+
## Get both Sandbox Patrons and Real Patrons
|
|
175
141
|
|
|
176
|
-
|
|
142
|
+
set second boolean argument "showSandboxPatrons" to true
|
|
177
143
|
|
|
178
144
|
```js
|
|
179
|
-
Patreon.FetchPatrons(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
})
|
|
145
|
+
const Patrons = await Patreon.FetchPatrons(
|
|
146
|
+
['active_patron', 'declined_patron', 'former_patron'],
|
|
147
|
+
true
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
console.log(Patrons);
|
|
186
151
|
```
|
|
187
152
|
|
|
188
|
-
|
|
153
|
+
<br />
|
|
154
|
+
|
|
155
|
+
# License
|
|
189
156
|
|
|
190
157
|
[MIT](LICENSE)
|
package/lib/index.d.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
export type PatronStatus = 'active_patron' | 'declined_patron' | 'former_patron';
|
|
2
|
-
export type PatronAPIAuth = {
|
|
3
|
-
AccessToken: string;
|
|
4
|
-
CampaignID: string;
|
|
5
|
-
};
|
|
6
|
-
export type PatronType = {
|
|
7
|
-
displayId: string;
|
|
8
|
-
displayName: string;
|
|
9
|
-
emailAddress: string;
|
|
10
|
-
isFollower: boolean;
|
|
11
|
-
subscription: {
|
|
12
|
-
note: string;
|
|
13
|
-
currentEntitled: {
|
|
14
|
-
status: PatronStatus;
|
|
15
|
-
tier: {
|
|
16
|
-
id: string;
|
|
17
|
-
title: string;
|
|
18
|
-
};
|
|
19
|
-
cents: number;
|
|
20
|
-
willPayCents: number;
|
|
21
|
-
lifetimeCents: number;
|
|
22
|
-
firstCharge: string;
|
|
23
|
-
nextCharge: string;
|
|
24
|
-
lastCharge: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
mediaConnection: {
|
|
28
|
-
patreon: {
|
|
29
|
-
id: string;
|
|
30
|
-
url: string;
|
|
31
|
-
};
|
|
32
|
-
discord: {
|
|
33
|
-
id: string | null;
|
|
34
|
-
url: string | null;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export type SandboxOptions = {
|
|
39
|
-
displayId: string;
|
|
40
|
-
displayName: string;
|
|
41
|
-
emailAddress: string;
|
|
42
|
-
tier: {
|
|
43
|
-
id: string;
|
|
44
|
-
title: string;
|
|
45
|
-
};
|
|
46
|
-
cents: number;
|
|
47
|
-
willPayCents: number;
|
|
48
|
-
lifetimeCents: number;
|
|
49
|
-
patronStatus: PatronStatus;
|
|
50
|
-
firstCharge: string;
|
|
51
|
-
nextCharge: string;
|
|
52
|
-
lastCharge: string;
|
|
53
|
-
mediaConnection: {
|
|
54
|
-
patreon: {
|
|
55
|
-
id: string;
|
|
56
|
-
url: string;
|
|
57
|
-
};
|
|
58
|
-
discord: {
|
|
59
|
-
id: string | null;
|
|
60
|
-
url: string | null;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
export declare class Patreon {
|
|
65
|
-
private static _URL;
|
|
66
|
-
private static _AccessToken;
|
|
67
|
-
private static _CampaignID;
|
|
68
|
-
private static _SandboxPatrons;
|
|
69
|
-
static Authorization(AuthCredentials: PatronAPIAuth): void;
|
|
70
|
-
private static FetchAPI;
|
|
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[];
|
|
75
|
-
}
|
|
76
|
-
export declare class Sandbox extends Patreon {
|
|
77
|
-
static
|
|
78
|
-
static
|
|
79
|
-
}
|
|
1
|
+
export type PatronStatus = 'active_patron' | 'declined_patron' | 'former_patron';
|
|
2
|
+
export type PatronAPIAuth = {
|
|
3
|
+
AccessToken: string;
|
|
4
|
+
CampaignID: string;
|
|
5
|
+
};
|
|
6
|
+
export type PatronType = {
|
|
7
|
+
displayId: string;
|
|
8
|
+
displayName: string;
|
|
9
|
+
emailAddress: string;
|
|
10
|
+
isFollower: boolean;
|
|
11
|
+
subscription: {
|
|
12
|
+
note: string;
|
|
13
|
+
currentEntitled: {
|
|
14
|
+
status: PatronStatus;
|
|
15
|
+
tier: {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
};
|
|
19
|
+
cents: number;
|
|
20
|
+
willPayCents: number;
|
|
21
|
+
lifetimeCents: number;
|
|
22
|
+
firstCharge: string;
|
|
23
|
+
nextCharge: string;
|
|
24
|
+
lastCharge: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
mediaConnection: {
|
|
28
|
+
patreon: {
|
|
29
|
+
id: string;
|
|
30
|
+
url: string;
|
|
31
|
+
};
|
|
32
|
+
discord: {
|
|
33
|
+
id: string | null;
|
|
34
|
+
url: string | null;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type SandboxOptions = {
|
|
39
|
+
displayId: string;
|
|
40
|
+
displayName: string;
|
|
41
|
+
emailAddress: string;
|
|
42
|
+
tier: {
|
|
43
|
+
id: string;
|
|
44
|
+
title: string;
|
|
45
|
+
};
|
|
46
|
+
cents: number;
|
|
47
|
+
willPayCents: number;
|
|
48
|
+
lifetimeCents: number;
|
|
49
|
+
patronStatus: PatronStatus;
|
|
50
|
+
firstCharge: string;
|
|
51
|
+
nextCharge: string;
|
|
52
|
+
lastCharge: string;
|
|
53
|
+
mediaConnection: {
|
|
54
|
+
patreon: {
|
|
55
|
+
id: string;
|
|
56
|
+
url: string;
|
|
57
|
+
};
|
|
58
|
+
discord: {
|
|
59
|
+
id: string | null;
|
|
60
|
+
url: string | null;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export declare class Patreon {
|
|
65
|
+
private static _URL;
|
|
66
|
+
private static _AccessToken;
|
|
67
|
+
private static _CampaignID;
|
|
68
|
+
private static _SandboxPatrons;
|
|
69
|
+
static Authorization(AuthCredentials: PatronAPIAuth): void;
|
|
70
|
+
private static FetchAPI;
|
|
71
|
+
private static CleanURL;
|
|
72
|
+
static FetchPatrons(filters?: Array<PatronStatus>, pageSize?: number, showSandboxPatrons?: boolean): Promise<PatronType[]>;
|
|
73
|
+
protected static _SandboxAddPatron(Patron: SandboxOptions): void;
|
|
74
|
+
protected static _SandboxGetPatron(): SandboxOptions[];
|
|
75
|
+
}
|
|
76
|
+
export declare class Sandbox extends Patreon {
|
|
77
|
+
static GetPatrons(): SandboxOptions[];
|
|
78
|
+
static AddPatron(Patron: SandboxOptions): void;
|
|
79
|
+
}
|
|
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,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,EAA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I,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,EACtB,kBAAkB,GAAE,OAAe;IAgIvC,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc;IAIzD,SAAS,CAAC,MAAM,CAAC,iBAAiB;CAOrC;AAED,qBAAa,OAAQ,SAAQ,OAAO;WAClB,UAAU;WAIV,SAAS,CAAC,MAAM,EAAE,cAAc;CAGjD"}
|
package/lib/index.js
CHANGED
|
@@ -1,155 +1,157 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Sandbox = exports.Patreon = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
class Patreon {
|
|
9
|
-
static Authorization(AuthCredentials) {
|
|
10
|
-
if (!AuthCredentials.AccessToken || !AuthCredentials.CampaignID) {
|
|
11
|
-
throw new Error('AccessToken and CampaignID are required on Authorization');
|
|
12
|
-
}
|
|
13
|
-
this._AccessToken = AuthCredentials.AccessToken;
|
|
14
|
-
this._CampaignID = AuthCredentials.CampaignID;
|
|
15
|
-
}
|
|
16
|
-
static async FetchAPI(URI) {
|
|
17
|
-
if (!this._AccessToken || !this._CampaignID) {
|
|
18
|
-
throw new Error('AccessToken and CampaignID are required on Authorization');
|
|
19
|
-
}
|
|
20
|
-
return await (0, axios_1.default)(this._URL + URI, {
|
|
21
|
-
method: 'GET',
|
|
22
|
-
headers: { Authorization: 'Bearer ' + this._AccessToken },
|
|
23
|
-
}).catch((err) => {
|
|
24
|
-
throw new Error('Fetch API Failed...' + err);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
static CleanURL(query) {
|
|
28
|
-
query = query.replaceAll('[', '%5B').replaceAll(']', '%5D');
|
|
29
|
-
query = query.replaceAll(' ', '');
|
|
30
|
-
return query;
|
|
31
|
-
}
|
|
32
|
-
static async FetchPatrons(filters = ['active_patron'], pageSize = 450) {
|
|
33
|
-
const { data } = await this.FetchAPI(this.CleanURL(`campaigns/${this._CampaignID}/` +
|
|
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`));
|
|
35
|
-
const Patrons = [];
|
|
36
|
-
const PatreonAPIPatrons = data?.data || [];
|
|
37
|
-
if (PatreonAPIPatrons.length == 0)
|
|
38
|
-
return [];
|
|
39
|
-
// Format
|
|
40
|
-
for (let x = 0; x <
|
|
41
|
-
const
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
?.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
Patreon
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Sandbox = exports.Patreon = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
class Patreon {
|
|
9
|
+
static Authorization(AuthCredentials) {
|
|
10
|
+
if (!AuthCredentials.AccessToken || !AuthCredentials.CampaignID) {
|
|
11
|
+
throw new Error('AccessToken and CampaignID are required on Authorization');
|
|
12
|
+
}
|
|
13
|
+
this._AccessToken = AuthCredentials.AccessToken;
|
|
14
|
+
this._CampaignID = AuthCredentials.CampaignID;
|
|
15
|
+
}
|
|
16
|
+
static async FetchAPI(URI) {
|
|
17
|
+
if (!this._AccessToken || !this._CampaignID) {
|
|
18
|
+
throw new Error('AccessToken and CampaignID are required on Authorization');
|
|
19
|
+
}
|
|
20
|
+
return await (0, axios_1.default)(this._URL + URI, {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
headers: { Authorization: 'Bearer ' + this._AccessToken },
|
|
23
|
+
}).catch((err) => {
|
|
24
|
+
throw new Error('Fetch API Failed...' + err);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
static CleanURL(query) {
|
|
28
|
+
query = query.replaceAll('[', '%5B').replaceAll(']', '%5D');
|
|
29
|
+
query = query.replaceAll(' ', '');
|
|
30
|
+
return query;
|
|
31
|
+
}
|
|
32
|
+
static async FetchPatrons(filters = ['active_patron'], pageSize = 450, showSandboxPatrons = false) {
|
|
33
|
+
const { data } = await this.FetchAPI(this.CleanURL(`campaigns/${this._CampaignID}/` +
|
|
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`));
|
|
35
|
+
const Patrons = [];
|
|
36
|
+
const PatreonAPIPatrons = data?.data || [];
|
|
37
|
+
if (PatreonAPIPatrons.length == 0)
|
|
38
|
+
return [];
|
|
39
|
+
// Format Real Patrons
|
|
40
|
+
for (let x = 0; x < PatreonAPIPatrons.length; x++) {
|
|
41
|
+
const Relationships = PatreonAPIPatrons[x].relationships;
|
|
42
|
+
const Attributes = PatreonAPIPatrons[x].attributes;
|
|
43
|
+
if (!filters.includes(Attributes.patron_status))
|
|
44
|
+
continue;
|
|
45
|
+
const socialInfo = data.included.find((patron) => patron.id == Relationships.user.data.id &&
|
|
46
|
+
patron.type === 'user');
|
|
47
|
+
const tierInfo = data.included.find((patron) => patron.id ==
|
|
48
|
+
Relationships.currently_entitled_tiers?.data[0]?.id &&
|
|
49
|
+
patron.type === 'tier');
|
|
50
|
+
Patrons.push({
|
|
51
|
+
displayId: Relationships.user.data.id,
|
|
52
|
+
displayName: Attributes.full_name,
|
|
53
|
+
emailAddress: Attributes.email,
|
|
54
|
+
isFollower: Attributes.is_follower,
|
|
55
|
+
subscription: {
|
|
56
|
+
note: Attributes.note,
|
|
57
|
+
currentEntitled: {
|
|
58
|
+
status: Attributes.patron_status,
|
|
59
|
+
tier: {
|
|
60
|
+
id: tierInfo ? tierInfo.id : null,
|
|
61
|
+
title: tierInfo ? tierInfo.attributes.title : null,
|
|
62
|
+
},
|
|
63
|
+
cents: Attributes.currently_entitled_amount_cents != 0
|
|
64
|
+
? Attributes.currently_entitled_amount_cents
|
|
65
|
+
: null,
|
|
66
|
+
willPayCents: Attributes.will_pay_amount_cents,
|
|
67
|
+
lifetimeCents: Attributes.lifetime_support_cents,
|
|
68
|
+
firstCharge: Attributes.pledge_relationship_start,
|
|
69
|
+
nextCharge: Attributes.next_charge_date,
|
|
70
|
+
lastCharge: Attributes.last_charge_date,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
mediaConnection: {
|
|
74
|
+
patreon: {
|
|
75
|
+
id: Relationships.user.data.id,
|
|
76
|
+
url: Relationships.user.links.related,
|
|
77
|
+
},
|
|
78
|
+
discord: {
|
|
79
|
+
id: socialInfo?.attributes?.social_connections?.discord
|
|
80
|
+
?.user_id
|
|
81
|
+
? socialInfo?.attributes?.social_connections
|
|
82
|
+
?.discord?.user_id
|
|
83
|
+
: null,
|
|
84
|
+
url: 'https://discordapp.com/users/' +
|
|
85
|
+
socialInfo?.attributes?.social_connections?.discord
|
|
86
|
+
?.user_id
|
|
87
|
+
? socialInfo?.attributes?.social_connections
|
|
88
|
+
?.discord?.user_id
|
|
89
|
+
: null,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (showSandboxPatrons) {
|
|
95
|
+
// Format Sandbox Patrons
|
|
96
|
+
for (let x = 0; x < this._SandboxPatrons.length; x++) {
|
|
97
|
+
const Patron = this._SandboxPatrons[x];
|
|
98
|
+
Patrons.push({
|
|
99
|
+
displayId: Patron.displayId,
|
|
100
|
+
displayName: Patron.displayName,
|
|
101
|
+
emailAddress: Patron.emailAddress,
|
|
102
|
+
isFollower: false,
|
|
103
|
+
subscription: {
|
|
104
|
+
note: 'Sandbox',
|
|
105
|
+
currentEntitled: {
|
|
106
|
+
status: Patron.patronStatus,
|
|
107
|
+
tier: {
|
|
108
|
+
id: Patron.tier.id,
|
|
109
|
+
title: Patron.tier.title,
|
|
110
|
+
},
|
|
111
|
+
cents: Patron.cents,
|
|
112
|
+
willPayCents: Patron.willPayCents,
|
|
113
|
+
lifetimeCents: Patron.lifetimeCents,
|
|
114
|
+
firstCharge: Patron.firstCharge,
|
|
115
|
+
nextCharge: Patron.nextCharge,
|
|
116
|
+
lastCharge: Patron.lastCharge,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
mediaConnection: {
|
|
120
|
+
patreon: {
|
|
121
|
+
id: Patron.mediaConnection.patreon.id,
|
|
122
|
+
url: Patron.mediaConnection.patreon.url,
|
|
123
|
+
},
|
|
124
|
+
discord: {
|
|
125
|
+
id: Patron?.mediaConnection?.discord?.id
|
|
126
|
+
? Patron?.mediaConnection?.discord?.id
|
|
127
|
+
: null,
|
|
128
|
+
url: Patron?.mediaConnection?.discord?.url
|
|
129
|
+
? Patron?.mediaConnection?.discord?.id
|
|
130
|
+
: null,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return Patrons;
|
|
137
|
+
}
|
|
138
|
+
static _SandboxAddPatron(Patron) {
|
|
139
|
+
this._SandboxPatrons.push(Patron);
|
|
140
|
+
}
|
|
141
|
+
static _SandboxGetPatron() {
|
|
142
|
+
return this._SandboxPatrons;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.Patreon = Patreon;
|
|
146
|
+
Patreon._URL = 'https://www.patreon.com/api/oauth2/v2/';
|
|
147
|
+
Patreon._SandboxPatrons = [];
|
|
148
|
+
class Sandbox extends Patreon {
|
|
149
|
+
static GetPatrons() {
|
|
150
|
+
return super._SandboxGetPatron();
|
|
151
|
+
}
|
|
152
|
+
static AddPatron(Patron) {
|
|
153
|
+
super._SandboxAddPatron(Patron);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.Sandbox = Sandbox;
|
|
155
157
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,CAAC;YAC9D,MAAM,IAAI,KAAK,CACX,0DAA0D,CAC7D,CAAC;QACN,CAAC;QAED,IAAI,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yBACb;qBACJ;iBACJ,CAAC,CAAC;YACP,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAES,MAAM,CAAC,iBAAiB,CAAC,MAAsB;QACrD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAES,MAAM,CAAC,iBAAiB;QAC9B,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;;AAjLL,0BAsLC;AArLkB,YAAI,GAAW,wCAAwC,CAAC;AAIxD,uBAAe,GAA0B,EAAE,CAAC;AAmL/D,MAAa,OAAQ,SAAQ,OAAO;IACzB,MAAM,CAAC,UAAU;QACpB,OAAO,KAAK,CAAC,iBAAiB,EAAE,CAAC;IACrC,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,MAAsB;QAC1C,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACJ;AARD,0BAQC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anitrack/patreon-wrapper",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Universal Patron API v2 wrapper that simplifies their API usage in JavaScript",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/AniTrack/patreon-wrapper#readme",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "^
|
|
27
|
+
"axios": "^1.6.8"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
"ts-node": "^10.7.0",
|
|
34
34
|
"typescript": "^4.6.4"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -112,7 +112,8 @@ export class Patreon {
|
|
|
112
112
|
|
|
113
113
|
public static async FetchPatrons(
|
|
114
114
|
filters: Array<PatronStatus> = ['active_patron'],
|
|
115
|
-
pageSize: number = 450
|
|
115
|
+
pageSize: number = 450,
|
|
116
|
+
showSandboxPatrons: boolean = false
|
|
116
117
|
) {
|
|
117
118
|
const { data } = await this.FetchAPI(
|
|
118
119
|
this.CleanURL(
|
|
@@ -126,48 +127,6 @@ export class Patreon {
|
|
|
126
127
|
|
|
127
128
|
if (PatreonAPIPatrons.length == 0) return [];
|
|
128
129
|
|
|
129
|
-
// Format Sandbox Patrons
|
|
130
|
-
for (let x = 0; x < this._SandboxPatrons.length; x++) {
|
|
131
|
-
const Patron = this._SandboxPatrons[x];
|
|
132
|
-
|
|
133
|
-
Patrons.push({
|
|
134
|
-
displayId: Patron.displayId,
|
|
135
|
-
displayName: Patron.displayName,
|
|
136
|
-
emailAddress: Patron.emailAddress,
|
|
137
|
-
isFollower: false,
|
|
138
|
-
subscription: {
|
|
139
|
-
note: 'Sandbox',
|
|
140
|
-
currentEntitled: {
|
|
141
|
-
status: Patron.patronStatus,
|
|
142
|
-
tier: {
|
|
143
|
-
id: Patron.tier.id,
|
|
144
|
-
title: Patron.tier.title,
|
|
145
|
-
},
|
|
146
|
-
cents: Patron.cents,
|
|
147
|
-
willPayCents: Patron.willPayCents,
|
|
148
|
-
lifetimeCents: Patron.lifetimeCents,
|
|
149
|
-
firstCharge: Patron.firstCharge,
|
|
150
|
-
nextCharge: Patron.nextCharge,
|
|
151
|
-
lastCharge: Patron.lastCharge,
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
mediaConnection: {
|
|
155
|
-
patreon: {
|
|
156
|
-
id: Patron.mediaConnection.patreon.id,
|
|
157
|
-
url: Patron.mediaConnection.patreon.url,
|
|
158
|
-
},
|
|
159
|
-
discord: {
|
|
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,
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
130
|
// Format Real Patrons
|
|
172
131
|
for (let x = 0; x < PatreonAPIPatrons.length; x++) {
|
|
173
132
|
const Relationships = PatreonAPIPatrons[x].relationships;
|
|
@@ -199,7 +158,7 @@ export class Patreon {
|
|
|
199
158
|
status: Attributes.patron_status,
|
|
200
159
|
tier: {
|
|
201
160
|
id: tierInfo ? tierInfo.id : null,
|
|
202
|
-
title: tierInfo ? tierInfo.
|
|
161
|
+
title: tierInfo ? tierInfo.attributes.title : null,
|
|
203
162
|
},
|
|
204
163
|
cents:
|
|
205
164
|
Attributes.currently_entitled_amount_cents != 0
|
|
@@ -235,6 +194,50 @@ export class Patreon {
|
|
|
235
194
|
});
|
|
236
195
|
}
|
|
237
196
|
|
|
197
|
+
if (showSandboxPatrons) {
|
|
198
|
+
// Format Sandbox Patrons
|
|
199
|
+
for (let x = 0; x < this._SandboxPatrons.length; x++) {
|
|
200
|
+
const Patron = this._SandboxPatrons[x];
|
|
201
|
+
|
|
202
|
+
Patrons.push({
|
|
203
|
+
displayId: Patron.displayId,
|
|
204
|
+
displayName: Patron.displayName,
|
|
205
|
+
emailAddress: Patron.emailAddress,
|
|
206
|
+
isFollower: false,
|
|
207
|
+
subscription: {
|
|
208
|
+
note: 'Sandbox',
|
|
209
|
+
currentEntitled: {
|
|
210
|
+
status: Patron.patronStatus,
|
|
211
|
+
tier: {
|
|
212
|
+
id: Patron.tier.id,
|
|
213
|
+
title: Patron.tier.title,
|
|
214
|
+
},
|
|
215
|
+
cents: Patron.cents,
|
|
216
|
+
willPayCents: Patron.willPayCents,
|
|
217
|
+
lifetimeCents: Patron.lifetimeCents,
|
|
218
|
+
firstCharge: Patron.firstCharge,
|
|
219
|
+
nextCharge: Patron.nextCharge,
|
|
220
|
+
lastCharge: Patron.lastCharge,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
mediaConnection: {
|
|
224
|
+
patreon: {
|
|
225
|
+
id: Patron.mediaConnection.patreon.id,
|
|
226
|
+
url: Patron.mediaConnection.patreon.url,
|
|
227
|
+
},
|
|
228
|
+
discord: {
|
|
229
|
+
id: Patron?.mediaConnection?.discord?.id
|
|
230
|
+
? Patron?.mediaConnection?.discord?.id
|
|
231
|
+
: null,
|
|
232
|
+
url: Patron?.mediaConnection?.discord?.url
|
|
233
|
+
? Patron?.mediaConnection?.discord?.id
|
|
234
|
+
: null,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
238
241
|
return Patrons;
|
|
239
242
|
}
|
|
240
243
|
|
|
@@ -252,11 +255,11 @@ export class Patreon {
|
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
export class Sandbox extends Patreon {
|
|
255
|
-
public static
|
|
258
|
+
public static GetPatrons() {
|
|
256
259
|
return super._SandboxGetPatron();
|
|
257
260
|
}
|
|
258
261
|
|
|
259
|
-
public static
|
|
262
|
+
public static AddPatron(Patron: SandboxOptions) {
|
|
260
263
|
super._SandboxAddPatron(Patron);
|
|
261
264
|
}
|
|
262
265
|
}
|