@anitrack/patreon-wrapper 1.1.5 → 1.2.5

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 CHANGED
@@ -71,6 +71,7 @@ Clean Response Example
71
71
  note: '',
72
72
  currentEntitled: {
73
73
  status: 'active_patron',
74
+ tierId: '12345678',
74
75
  cents: 500, // 5 USD
75
76
  willPayCents: 500,
76
77
  lifetimeCents: 0,
package/lib/index.d.ts CHANGED
@@ -2,6 +2,35 @@ declare type Auth = {
2
2
  AccessToken: string;
3
3
  CampaignID: string;
4
4
  };
5
+ declare type PatronType = {
6
+ displayId: string;
7
+ displayName: string;
8
+ emailAddress: string;
9
+ isFollower: boolean;
10
+ subscription: {
11
+ note: string;
12
+ currentEntitled: {
13
+ status: string;
14
+ tierId: number;
15
+ cents: number;
16
+ willPayCents: number;
17
+ lifetimeCents: number;
18
+ firstCharge: Date;
19
+ nextCharge: Date;
20
+ lastCharge: Date;
21
+ };
22
+ };
23
+ mediaConnection: {
24
+ patreon: {
25
+ id: string;
26
+ url: string;
27
+ };
28
+ discord: {
29
+ id: string;
30
+ url: string;
31
+ };
32
+ };
33
+ };
5
34
  export declare class Patreon {
6
35
  private static _URL;
7
36
  private static _AccessToken;
@@ -9,7 +38,7 @@ export declare class Patreon {
9
38
  static Authorization(AuthInformation: Auth): void;
10
39
  private static FetchAPI;
11
40
  private static CleanQueryURL;
12
- static FetchPatrons(filter?: string[]): Promise<any[]>;
41
+ static FetchPatrons(filter?: string[]): Promise<PatronType[]>;
13
42
  }
14
43
  export {};
15
44
  //# sourceMappingURL=index.d.ts.map
@@ -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,qBAAa,OAAO;IAChB,OAAO,CAAC,MAAM,CAA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;WAEpB,aAAa,CAAC,eAAe,EAAE,IAAI;mBAc5B,QAAQ;IAS7B,OAAO,CAAC,MAAM,CAAC,aAAa;WAOR,YAAY,CAAC,MAAM,GAAE,MAAM,EAAO;CA2DzD"}
package/lib/index.js CHANGED
@@ -45,6 +45,8 @@ class Patreon {
45
45
  note: Patron.attributes.note,
46
46
  currentEntitled: {
47
47
  status: Patron.attributes.patron_status,
48
+ tierId: Patron.relationships.currently_entitled_tiers
49
+ ?.data[0]?.id,
48
50
  cents: Patron.attributes
49
51
  .currently_entitled_amount_cents,
50
52
  willPayCents: Patron.attributes.will_pay_amount_cents,
package/lib/index.js.map CHANGED
@@ -1 +1 @@
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,E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,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,OAAO;iCACxC,OAAO;qBACnB;iBACJ;aACJ,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QACF,OAAO,OAAO,CAAA;IAClB,CAAC;;AA1FL,0BA+FC;AA9FkB,YAAI,GAAW,wCAAwC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anitrack/patreon-wrapper",
3
- "version": "1.1.5",
3
+ "version": "1.2.5",
4
4
  "description": "Discord Patreon wrapper for AniTrack",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",
package/src/index.ts CHANGED
@@ -5,6 +5,39 @@ type Auth = {
5
5
  CampaignID: string
6
6
  }
7
7
 
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
+ tier: {
18
+ id: number
19
+ title: string
20
+ }
21
+ cents: number
22
+ willPayCents: number
23
+ lifetimeCents: number
24
+ firstCharge: Date
25
+ nextCharge: Date
26
+ lastCharge: Date
27
+ }
28
+ }
29
+ mediaConnection: {
30
+ patreon: {
31
+ id: string
32
+ url: string
33
+ }
34
+ discord: {
35
+ id: string
36
+ url: string
37
+ }
38
+ }
39
+ }
40
+
8
41
  export class Patreon {
9
42
  private static _URL: string = 'https://www.patreon.com/api/oauth2/v2/'
10
43
 
@@ -45,16 +78,26 @@ export class Patreon {
45
78
  const res: any = await this.FetchAPI(
46
79
  this.CleanQueryURL(
47
80
  `campaigns/${this._CampaignID}/` +
48
- `members ? include = user, currently_entitled_tiers & 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`
81
+ `members ? include = user, currently_entitled_tiers & 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`
49
82
  )
50
83
  )
51
84
 
52
- const Patrons: any[] = []
85
+ const Patrons: Array<PatronType> = []
53
86
 
54
87
  res.data.data.forEach((Patron: any) => {
55
- var include = res.data.included.find(
88
+ // console.dir(Patron)
89
+
90
+ var socialInfo = res.data.included.find(
91
+ (includePatron: any) =>
92
+ includePatron.id == Patron.relationships.user.data.id &&
93
+ includePatron.type === 'user'
94
+ )
95
+
96
+ var tierInfo = res.data.included.find(
56
97
  (includePatron: any) =>
57
- includePatron.id == Patron.relationships.user.data.id
98
+ includePatron.id ==
99
+ Patron.relationships.currently_entitled_tiers?.data[0]
100
+ ?.id && includePatron.type === 'tier'
58
101
  )
59
102
 
60
103
  Patrons.push({
@@ -66,6 +109,10 @@ export class Patreon {
66
109
  note: Patron.attributes.note,
67
110
  currentEntitled: {
68
111
  status: Patron.attributes.patron_status,
112
+ tier: {
113
+ id: tierInfo.id,
114
+ title: tierInfo.attributes.title,
115
+ },
69
116
  cents: Patron.attributes
70
117
  .currently_entitled_amount_cents,
71
118
  willPayCents: Patron.attributes.will_pay_amount_cents,
@@ -82,11 +129,11 @@ export class Patreon {
82
129
  url: Patron.relationships.user.links.related,
83
130
  },
84
131
  discord: {
85
- id: include.attributes.social_connections.discord
132
+ id: socialInfo.attributes.social_connections.discord
86
133
  .user_id,
87
134
  url:
88
135
  'https://discordapp.com/users/' +
89
- include.attributes.social_connections.discord
136
+ socialInfo.attributes.social_connections.discord
90
137
  .user_id,
91
138
  },
92
139
  },