@anitrack/patreon-wrapper 1.0.3 → 1.2.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 +108 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +34 -2
package/README.md
CHANGED
|
@@ -1,2 +1,108 @@
|
|
|
1
|
-
#
|
|
2
|
-
Discord Patreon Wrapper for AniTrack
|
|
1
|
+
# Patreon Wrapper 🍊
|
|
2
|
+
Discord Patreon Wrapper for [AniTrack](https://anitrack.co) on node.js
|
|
3
|
+
|
|
4
|
+
## Table of Contents
|
|
5
|
+
- [Installing](#installing)
|
|
6
|
+
- [Example](#example)
|
|
7
|
+
- [License](#license)
|
|
8
|
+
|
|
9
|
+
## Installing
|
|
10
|
+
Using NPM
|
|
11
|
+
```
|
|
12
|
+
$ npm install @anitrack/patreon-wrapper
|
|
13
|
+
```
|
|
14
|
+
Using YARN
|
|
15
|
+
```
|
|
16
|
+
$ yarn add @anitrack/patreon-wrapper
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
### Importing
|
|
22
|
+
|
|
23
|
+
CommonJS
|
|
24
|
+
```js
|
|
25
|
+
const { Patreon } = require('@AniTrack/patreon-wrapper')
|
|
26
|
+
```
|
|
27
|
+
Typescript ES6
|
|
28
|
+
```js
|
|
29
|
+
import { Patreon } from '@AniTrack/patreon-wrapper'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Authorization
|
|
33
|
+
```js
|
|
34
|
+
Patreon.Authorization({
|
|
35
|
+
AccessToken: 'YOUR_API_V2_ACCESS_TOKEN',
|
|
36
|
+
CampaignID: 'YOUR_CAPAIGN_ID',
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Fetching every Patrons on the Campaign
|
|
41
|
+
|
|
42
|
+
Promies then catch
|
|
43
|
+
```js
|
|
44
|
+
Patreon.FetchPatrons()
|
|
45
|
+
.then((Patrons) => {
|
|
46
|
+
// Handle Patrons List
|
|
47
|
+
console.log(Patrons)
|
|
48
|
+
})
|
|
49
|
+
.catch((err) => {
|
|
50
|
+
// Handle Error
|
|
51
|
+
console.log(err)
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
Async/Await
|
|
55
|
+
```js
|
|
56
|
+
var Patrons = await Patreon.FetchPatrons()
|
|
57
|
+
|
|
58
|
+
console.log(Patrons)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Clean Response Example
|
|
62
|
+
```js
|
|
63
|
+
// Example response from fetching Patron list
|
|
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
|
+
tierId: '12345678',
|
|
75
|
+
cents: 500, // 5 USD
|
|
76
|
+
willPayCents: 500,
|
|
77
|
+
lifetimeCents: 0,
|
|
78
|
+
firstCharge: 'DATE',
|
|
79
|
+
nextCharge: 'DATE',
|
|
80
|
+
lastCharge: 'DATE'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
mediaConnection: {
|
|
84
|
+
patreon: {
|
|
85
|
+
id: '12345678',
|
|
86
|
+
url: 'https://www.patreon.com/api/oauth2/v2/user/12345678'
|
|
87
|
+
},
|
|
88
|
+
discord: {
|
|
89
|
+
id: 'DISCORD_USER_ID',
|
|
90
|
+
url: 'https://discordapp.com/users/DISCORD_USER_ID'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
...
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
...
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
...
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
[MIT](LICENSE)
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,aAAK,IAAI,GAAG;IACR,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,aAAK,IAAI,GAAG;IACR,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,qBAAa,OAAO;IAChB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAmD;IAEtE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAQ;IACnC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAQ;WAEpB,aAAa,CAAC,eAAe,EAAE,IAAI;mBAc5B,QAAQ;IAS7B,OAAO,CAAC,MAAM,CAAC,aAAa;WAOR,YAAY,CAAC,MAAM,GAAE,MAAM,EAAO;CAyDzD"}
|
package/lib/index.js
CHANGED
|
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Patreon = void 0;
|
|
6
7
|
const axios_1 = __importDefault(require("axios"));
|
|
7
|
-
class
|
|
8
|
+
class Patreon {
|
|
8
9
|
static Authorization(AuthInformation) {
|
|
9
10
|
if (!AuthInformation.AccessToken || !AuthInformation.CampaignID) {
|
|
10
11
|
throw new Error('Either Missing AccessToken or CampaignID');
|
|
@@ -71,6 +72,6 @@ class default_1 {
|
|
|
71
72
|
return Patrons;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
exports.
|
|
75
|
-
|
|
75
|
+
exports.Patreon = Patreon;
|
|
76
|
+
Patreon._URL = 'https://www.patreon.com/api/oauth2/v2/';
|
|
76
77
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAOzB,MAAa,OAAO;IAMT,MAAM,CAAC,aAAa,CAAC,eAAqB;QAC7C,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;YAC7D,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;SAC9D;aAAM,IACH,OAAO,eAAe,CAAC,WAAW,IAAI,QAAQ;YAC9C,OAAO,eAAe,CAAC,UAAU,IAAI,QAAQ,EAC/C;YACE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;SACzD;QAED,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,WAAW,CAAA;QAC/C,IAAI,CAAC,WAAW,GAAG,eAAe,CAAC,UAAU,CAAA;IACjD,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAW;QACrC,OAAO,MAAM,IAAA,eAAK,EAAC,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE;YAChC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE;SAC5D,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,GAAG,CAAC,CAAA;QAChD,CAAC,C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BACpC,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC,qBAAqB;wBACrD,aAAa,EAAE,MAAM,CAAC,UAAU,CAAC,sBAAsB;wBACvD,WAAW,EACP,MAAM,CAAC,UAAU,CAAC,yBAAyB;wBAC/C,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,gBAAgB;wBAC9C,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,gBAAgB;qBACjD;iBACJ;gBACD,eAAe,EAAE;oBACb,OAAO,EAAE;wBACL,EAAE,EAAE,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;wBACrC,GAAG,EAAE,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO;qBAC/C;oBACD,OAAO,EAAE;wBACL,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,OAAO;6BAC5C,OAAO;wBACZ,GAAG,EACC,+BAA+B;4BAC/B,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,OAAO;iCACxC,OAAO;qBACnB;iBACJ;aACJ,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QACF,OAAO,OAAO,CAAA;IAClB,CAAC;;AAxFL,0BA6FC;AA5FkB,YAAI,GAAW,wCAAwC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anitrack/patreon-wrapper",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Discord Patreon wrapper for AniTrack",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "git
|
|
12
|
+
"url": "git://github.com/AniTrack/patreon-wrapper.git"
|
|
13
13
|
},
|
|
14
14
|
"author": "AniTrack",
|
|
15
15
|
"license": "MIT",
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,37 @@ type Auth = {
|
|
|
5
5
|
CampaignID: string
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type PatronType = {
|
|
9
|
+
displayId: string
|
|
10
|
+
displayName: string
|
|
11
|
+
emailAddress: string
|
|
12
|
+
isFollower: boolean
|
|
13
|
+
subscription: {
|
|
14
|
+
note: string
|
|
15
|
+
currentEntitled: {
|
|
16
|
+
status: string
|
|
17
|
+
tierId: number
|
|
18
|
+
cents: number
|
|
19
|
+
willPayCents: number
|
|
20
|
+
lifetimeCents: number
|
|
21
|
+
firstCharge: Date
|
|
22
|
+
nextCharge: Date
|
|
23
|
+
lastCharge: Date
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
mediaConnection: {
|
|
27
|
+
patreon: {
|
|
28
|
+
id: string
|
|
29
|
+
url: string
|
|
30
|
+
}
|
|
31
|
+
discord: {
|
|
32
|
+
id: string
|
|
33
|
+
url: string
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class Patreon {
|
|
9
39
|
private static _URL: string = 'https://www.patreon.com/api/oauth2/v2/'
|
|
10
40
|
|
|
11
41
|
private static _AccessToken: string
|
|
@@ -49,7 +79,7 @@ export default class {
|
|
|
49
79
|
)
|
|
50
80
|
)
|
|
51
81
|
|
|
52
|
-
const Patrons:
|
|
82
|
+
const Patrons: Array<PatronType> = []
|
|
53
83
|
|
|
54
84
|
res.data.data.forEach((Patron: any) => {
|
|
55
85
|
var include = res.data.included.find(
|
|
@@ -66,6 +96,8 @@ export default class {
|
|
|
66
96
|
note: Patron.attributes.note,
|
|
67
97
|
currentEntitled: {
|
|
68
98
|
status: Patron.attributes.patron_status,
|
|
99
|
+
tierId: Patron.relationships.currently_entitled_tiers
|
|
100
|
+
?.data[0]?.id,
|
|
69
101
|
cents: Patron.attributes
|
|
70
102
|
.currently_entitled_amount_cents,
|
|
71
103
|
willPayCents: Patron.attributes.will_pay_amount_cents,
|