@anitrack/patreon-wrapper 1.5.1 → 1.5.2
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 +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +45 -43
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +48 -45
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
|
@@ -69,12 +69,12 @@ export declare class Patreon {
|
|
|
69
69
|
static Authorization(AuthCredentials: PatronAPIAuth): void;
|
|
70
70
|
private static FetchAPI;
|
|
71
71
|
private static CleanURL;
|
|
72
|
-
static FetchPatrons(filters?: Array<PatronStatus>, pageSize?: number): Promise<PatronType[]>;
|
|
72
|
+
static FetchPatrons(filters?: Array<PatronStatus>, pageSize?: number, showSandboxPatrons?: boolean): Promise<PatronType[]>;
|
|
73
73
|
protected static _SandboxAddPatron(Patron: SandboxOptions): void;
|
|
74
74
|
protected static _SandboxGetPatron(): SandboxOptions[];
|
|
75
75
|
}
|
|
76
76
|
export declare class Sandbox extends Patreon {
|
|
77
|
-
static
|
|
78
|
-
static
|
|
77
|
+
static GetPatrons(): SandboxOptions[];
|
|
78
|
+
static AddPatron(Patron: SandboxOptions): void;
|
|
79
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;gB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AO;WAClB,UAAU;WAIV,SAAS,CAAC,MAAM,EAAE,cAAc;CAGjD"}
|
package/lib/index.js
CHANGED
|
@@ -29,53 +29,13 @@ class Patreon {
|
|
|
29
29
|
query = query.replaceAll(' ', '');
|
|
30
30
|
return query;
|
|
31
31
|
}
|
|
32
|
-
static async FetchPatrons(filters = ['active_patron'], pageSize = 450) {
|
|
32
|
+
static async FetchPatrons(filters = ['active_patron'], pageSize = 450, showSandboxPatrons = false) {
|
|
33
33
|
const { data } = await this.FetchAPI(this.CleanURL(`campaigns/${this._CampaignID}/` +
|
|
34
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
35
|
const Patrons = [];
|
|
36
36
|
const PatreonAPIPatrons = data?.data || [];
|
|
37
37
|
if (PatreonAPIPatrons.length == 0)
|
|
38
38
|
return [];
|
|
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,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
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
|
-
},
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
39
|
// Format Real Patrons
|
|
80
40
|
for (let x = 0; x < PatreonAPIPatrons.length; x++) {
|
|
81
41
|
const Relationships = PatreonAPIPatrons[x].relationships;
|
|
@@ -131,6 +91,48 @@ class Patreon {
|
|
|
131
91
|
},
|
|
132
92
|
});
|
|
133
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
|
+
}
|
|
134
136
|
return Patrons;
|
|
135
137
|
}
|
|
136
138
|
static _SandboxAddPatron(Patron) {
|
|
@@ -144,10 +146,10 @@ exports.Patreon = Patreon;
|
|
|
144
146
|
Patreon._URL = 'https://www.patreon.com/api/oauth2/v2/';
|
|
145
147
|
Patreon._SandboxPatrons = [];
|
|
146
148
|
class Sandbox extends Patreon {
|
|
147
|
-
static
|
|
149
|
+
static GetPatrons() {
|
|
148
150
|
return super._SandboxGetPatron();
|
|
149
151
|
}
|
|
150
|
-
static
|
|
152
|
+
static AddPatron(Patron) {
|
|
151
153
|
super._SandboxAddPatron(Patron);
|
|
152
154
|
}
|
|
153
155
|
}
|
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;YAC7D,MAAM,IAAI,KAAK,CACX,0DAA0D,CAC7D,CAAC;SACL;QAED,I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AC,CAAC;aACN;SACJ;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
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;
|
|
@@ -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
|
}
|