@anitrack/patreon-wrapper 1.5.3 → 1.5.4

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/.prettierrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "trailingComma": "es5",
3
+ "tabWidth": 4,
4
+ "semi": true,
5
+ "singleQuote": true
6
+ }
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 AniTrack
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 AniTrack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,157 +1,185 @@
1
- # 🍊 Patreon Wrapper
2
-
3
- 💎 Universal Patron API v2 wrapper that simplifies their API usage in JavaScript
4
-
5
- > This package was previously used on [AniTrack.co](https://anitrack.co) before switching to the payment gateway
6
-
7
- # Table of Contents
8
-
9
- - [Install](#Install%20the%20package)
10
- - [Getting Started](#Getting%20Started)
11
- - [Sandbox for development](#Patreon%20Sandbox)
12
- - [License](#license)
13
-
14
- <br />
15
-
16
- # Install the package
17
-
18
- ```
19
- $ npm install @anitrack/patreon-wrapper
20
- ```
21
-
22
- <br />
23
-
24
- # Getting Started
25
-
26
- ```js
27
- import { Patreon } from '@anitrack/patreon-wrapper';
28
- ```
29
-
30
- <br />
31
-
32
- # API Authorization
33
-
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
35
-
36
- ```js
37
- Patreon.Authorization({
38
- AccessToken: 'YOUR_API_V2_ACCESS_TOKEN',
39
- CampaignID: 'YOUR_CAPAIGN_ID',
40
- });
41
- ```
42
-
43
- <br />
44
-
45
- # Package Usage
46
-
47
- ## Fetching every Patrons from the Campaign
48
-
49
- ```js
50
- const Patrons = await Patreon.FetchPatrons([
51
- 'active_patron',
52
- 'declined_patron',
53
- 'former_patron',
54
- ]);
55
-
56
- console.log(Patrons);
57
- ```
58
-
59
- ## Patron object example
60
-
61
- console.log(Patrons) from above
62
-
63
- ```js
64
- [
65
- {
66
- displayId: '12345678',
67
- displayName: 'Username',
68
- emailAddress: 'email@address.com',
69
- isFollower: false,
70
- subscription: {
71
- note: '',
72
- currentEntitled: {
73
- status: 'active_patron',
74
- tier: {
75
- id: '12345678',
76
- title: 'My First Tier'
77
- },
78
- cents: 500,
79
- willPayCents: 500,
80
- lifetimeCents: 1500,
81
- firstCharge: '2022-01-15 15:00:00.000',
82
- nextCharge: '2022-05-15 15:00:00.000',
83
- lastCharge: '2022-05-15 15:00:00.000'
84
- }
85
- },
86
- mediaConnection: {
87
- patreon: {
88
- id: '12345678',
89
- url: 'https://www.patreon.com/api/oauth2/v2/user/12345678'
90
- },
91
- discord: {
92
- id: '12345678',
93
- url: 'https://discordapp.com/users/12345678'
94
- }
95
- }
96
- },
97
- ...
98
- ]
99
- ```
100
-
101
- <br />
102
-
103
- # Patreon Sandbox
104
-
105
- > This is great for development and working with sandbox patrons users. The sandbox patrons object will be exactly the same as real ones!
106
-
107
- ## Adding Custom Patrons to the Sandbox
108
-
109
- You can add as much sandbox patrons as you want
110
-
111
- ```js
112
- import { Sandbox } from '@anitrack/patreon-wrapper';
113
-
114
- Sandbox.AddPatron({
115
- displayId: '123', // Patreon ID
116
- displayName: '123', // Patreon Username
117
- emailAddress: 'email@address.com', // Patreon Email
118
- tier: { id: '123', title: 'Tier 1' }, // Current Tier
119
- cents: 500, // Current paying in cent 500 -> $5.00
120
- willPayCents: 500, // Next pay price
121
- lifetimeCents: 1500, // Total lifetime spent
122
- firstCharge: '2022-01-15 15:00:00.000', // ISO 8601 String date format
123
- nextCharge: '2022-05-15 15:00:00.000',
124
- lastCharge: '2022-04-15 15:00:00.000',
125
- patronStatus: 'active_patron',
126
- mediaConnection: {
127
- patreon: {
128
- id: '123',
129
- url: 'https://www.patreon.com/api/oauth2/v2/user/user_id',
130
- },
131
- discord: { id: '123', url: 'https://discord.com/users/user_id' },
132
- },
133
- });
134
-
135
- const Patrons = Sandbox.GetPatrons();
136
-
137
- console.log(Patrons);
138
- ```
139
-
140
- ## Get both Sandbox Patrons and Real Patrons
141
-
142
- set second boolean argument "showSandboxPatrons" to true
143
-
144
- ```js
145
- const Patrons = await Patreon.FetchPatrons(
146
- ['active_patron', 'declined_patron', 'former_patron'],
147
- true
148
- );
149
-
150
- console.log(Patrons);
151
- ```
152
-
153
- <br />
154
-
155
- # License
156
-
157
- [MIT](LICENSE)
1
+ # 🍊 Patreon Wrapper
2
+
3
+ 💎 Universal Patron API v2 wrapper that simplifies their API usage in JavaScript
4
+
5
+ > This package was previously used on [AniTrack.co](https://anitrack.co) before switching to the payment gateway
6
+
7
+ # Table of Contents
8
+
9
+ - [Install](#Install%20the%20package)
10
+ - [Getting Started](#Getting%20Started)
11
+ - [Sandbox for development](#Patreon%20Sandbox)
12
+ - [License](#license)
13
+
14
+ <br />
15
+
16
+ # Install the package
17
+
18
+ ```
19
+ $ npm install @anitrack/patreon-wrapper
20
+ ```
21
+
22
+ <br />
23
+
24
+ # Getting Started
25
+
26
+ ```js
27
+ import { Patreon } from '@anitrack/patreon-wrapper';
28
+ ```
29
+
30
+ <br />
31
+
32
+ # API Authorization
33
+
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
35
+
36
+ ```js
37
+ Patreon.Authorization({
38
+ AccessToken: 'YOUR_API_V2_ACCESS_TOKEN',
39
+ CampaignID: 'YOUR_CAPAIGN_ID',
40
+ });
41
+ ```
42
+
43
+ <br />
44
+
45
+ # Package Usage
46
+
47
+ ## Fetching Campaign Info
48
+
49
+ ```js
50
+ const Campaign = await Patreon.FetchCampaign();
51
+ console.log(Campaign);
52
+ ```
53
+
54
+ ## Campaign object example
55
+
56
+ ```js
57
+ {
58
+ id: '1234567',
59
+ name: 'My Campaign',
60
+ patronCount: 142,
61
+ currency: 'USD',
62
+ isMonthly: true,
63
+ isNsfw: false,
64
+ summary: 'Support my work.',
65
+ createdAt: '2022-01-15T15:00:00.000+00:00',
66
+ publishedAt: '2022-01-16T10:00:00.000+00:00',
67
+ imageUrl: 'https://example.url',
68
+ imageSmallUrl: 'https://example.url',
69
+ discordServerId: '1234567890'
70
+ }
71
+ ```
72
+
73
+ ## Fetching every Patrons from the Campaign
74
+
75
+ ```js
76
+ const Patrons = await Patreon.FetchPatrons([
77
+ 'active_patron',
78
+ 'declined_patron',
79
+ 'former_patron',
80
+ ]);
81
+
82
+ console.log(Patrons);
83
+ ```
84
+
85
+ ## Patron object example
86
+
87
+ console.log(Patrons) from above
88
+
89
+ ```js
90
+ [
91
+ {
92
+ displayId: '12345678',
93
+ displayName: 'Username',
94
+ emailAddress: 'email@address.com',
95
+ isFollower: false,
96
+ subscription: {
97
+ note: '',
98
+ currentEntitled: {
99
+ status: 'active_patron',
100
+ lastChargeStatus: 'Paid',
101
+ tier: {
102
+ id: '12345678',
103
+ title: 'My First Tier'
104
+ },
105
+ cents: 500,
106
+ willPayCents: 500,
107
+ lifetimeCents: 1500,
108
+ firstCharge: '2022-01-15 15:00:00.000',
109
+ nextCharge: '2022-05-15 15:00:00.000',
110
+ lastCharge: '2022-05-15 15:00:00.000'
111
+ }
112
+ },
113
+ mediaConnection: {
114
+ patreon: {
115
+ id: '12345678',
116
+ url: 'https://www.patreon.com/api/oauth2/v2/user/12345678'
117
+ },
118
+ discord: {
119
+ id: '12345678',
120
+ url: 'https://discord.com/users/12345678'
121
+ }
122
+ }
123
+ },
124
+ ...
125
+ ]
126
+ ```
127
+
128
+ <br />
129
+
130
+ # Patreon Sandbox
131
+
132
+ > This is great for development and working with sandbox patrons users. The sandbox patrons object will be exactly the same as real ones!
133
+
134
+ ## Adding Custom Patrons to the Sandbox
135
+
136
+ You can add as much sandbox patrons as you want
137
+
138
+ ```js
139
+ import { Sandbox } from '@anitrack/patreon-wrapper';
140
+
141
+ Sandbox.AddPatron({
142
+ displayId: '123', // Patreon ID
143
+ displayName: '123', // Patreon Username
144
+ emailAddress: 'email@address.com', // Patreon Email
145
+ tier: { id: '123', title: 'Tier 1' }, // Current Tier
146
+ cents: 500, // Current paying in cent 500 -> $5.00
147
+ willPayCents: 500, // Next pay price
148
+ lifetimeCents: 1500, // Total lifetime spent
149
+ firstCharge: '2022-01-15 15:00:00.000', // ISO 8601 String date format
150
+ nextCharge: '2022-05-15 15:00:00.000',
151
+ lastCharge: '2022-04-15 15:00:00.000',
152
+ patronStatus: 'active_patron',
153
+ mediaConnection: {
154
+ patreon: {
155
+ id: '123',
156
+ url: 'https://www.patreon.com/api/oauth2/v2/user/user_id',
157
+ },
158
+ discord: { id: '123', url: 'https://discord.com/users/user_id' },
159
+ },
160
+ });
161
+
162
+ const Patrons = Sandbox.GetPatrons();
163
+
164
+ console.log(Patrons);
165
+ ```
166
+
167
+ ## Get both Sandbox Patrons and Real Patrons
168
+
169
+ set third boolean argument "showSandboxPatrons" to true
170
+
171
+ ```js
172
+ const Patrons = await Patreon.FetchPatrons(
173
+ ['active_patron', 'declined_patron', 'former_patron'],
174
+ 450,
175
+ true
176
+ );
177
+
178
+ console.log(Patrons);
179
+ ```
180
+
181
+ <br />
182
+
183
+ # License
184
+
185
+ [MIT](LICENSE)
package/package.json CHANGED
@@ -1,36 +1,35 @@
1
- {
2
- "name": "@anitrack/patreon-wrapper",
3
- "version": "1.5.3",
4
- "description": "Universal Patron API v2 wrapper that simplifies their API usage in JavaScript",
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": "^1.6.8"
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.4",
4
+ "description": "Universal Patron API v2 wrapper that simplifies their API usage in JavaScript",
5
+ "main": "src/index.js",
6
+ "types": "lib",
7
+ "scripts": {
8
+ "build": "tsc -p ."
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git://github.com/AniTrack/patreon-wrapper.git"
13
+ },
14
+ "author": "AniTrack",
15
+ "keywords": [
16
+ "patreon",
17
+ "discord",
18
+ "api"
19
+ ],
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/AniTrack/patreon-wrapper/issues"
23
+ },
24
+ "homepage": "https://github.com/AniTrack/patreon-wrapper#readme",
25
+ "dependencies": {
26
+ "axios": "^1.17.0"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "devDependencies": {
32
+ "ts-node": "^10.9.2",
33
+ "typescript": "^6.0.3"
34
+ }
35
+ }
@@ -5,13 +5,14 @@ export type PatronAPIAuth = {
5
5
  };
6
6
  export type PatronType = {
7
7
  displayId: string;
8
- displayName: string;
9
- emailAddress: string;
8
+ displayName: string | null;
9
+ emailAddress: string | null;
10
10
  isFollower: boolean;
11
11
  subscription: {
12
12
  note: string;
13
13
  currentEntitled: {
14
14
  status: PatronStatus;
15
+ lastChargeStatus: string | null;
15
16
  tier: {
16
17
  id: string;
17
18
  title: string;
@@ -35,6 +36,20 @@ export type PatronType = {
35
36
  };
36
37
  };
37
38
  };
39
+ export type CampaignType = {
40
+ id: string;
41
+ name: string;
42
+ patronCount: number;
43
+ currency: string;
44
+ isMonthly: boolean;
45
+ isNsfw: boolean;
46
+ summary: string | null;
47
+ createdAt: string;
48
+ publishedAt: string | null;
49
+ imageUrl: string | null;
50
+ imageSmallUrl: string | null;
51
+ discordServerId: string | null;
52
+ };
38
53
  export type SandboxOptions = {
39
54
  displayId: string;
40
55
  displayName: string;
@@ -68,10 +83,11 @@ export declare class Patreon {
68
83
  private static _SandboxPatrons;
69
84
  static Authorization(AuthCredentials: PatronAPIAuth): void;
70
85
  private static FetchAPI;
71
- private static CleanURL;
86
+ private static BuildMembersURL;
72
87
  static FetchPatrons(filters?: Array<PatronStatus>, pageSize?: number, showSandboxPatrons?: boolean): Promise<PatronType[]>;
73
88
  protected static _SandboxAddPatron(Patron: SandboxOptions): void;
74
89
  protected static _SandboxGetPatron(): SandboxOptions[];
90
+ static FetchCampaign(): Promise<CampaignType>;
75
91
  }
76
92
  export declare class Sandbox extends Patreon {
77
93
  static GetPatrons(): SandboxOptions[];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE;YACb,MAAM,EAAE,YAAY,CAAC;YACrB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;YAChC,IAAI,EAAE;gBACF,EAAE,EAAE,MAAM,CAAC;gBACX,KAAK,EAAE,MAAM,CAAC;aACjB,CAAC;YACF,KAAK,EAAE,MAAM,CAAC;YACd,Y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