@anitrack/patreon-wrapper 1.2.0 → 1.2.6

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,7 +71,10 @@ Clean Response Example
71
71
  note: '',
72
72
  currentEntitled: {
73
73
  status: 'active_patron',
74
- tierId: '12345678',
74
+ tier: {
75
+ id: '12345678',
76
+ title: 'Supporter 1'
77
+ },
75
78
  cents: 500, // 5 USD
76
79
  willPayCents: 500,
77
80
  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,C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Y,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;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;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O;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;;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.2.0",
3
+ "version": "1.2.6",
4
4
  "description": "Discord Patreon wrapper for AniTrack",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",
package/src/index.ts CHANGED
@@ -14,7 +14,10 @@ type PatronType = {
14
14
  note: string
15
15
  currentEntitled: {
16
16
  status: string
17
- tierId: number
17
+ tier: {
18
+ id: number
19
+ title: string
20
+ }
18
21
  cents: number
19
22
  willPayCents: number
20
23
  lifetimeCents: number
@@ -75,16 +78,26 @@ export class Patreon {
75
78
  const res: any = await this.FetchAPI(
76
79
  this.CleanQueryURL(
77
80
  `campaigns/${this._CampaignID}/` +
78
- `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`
79
82
  )
80
83
  )
81
84
 
82
85
  const Patrons: Array<PatronType> = []
83
86
 
84
87
  res.data.data.forEach((Patron: any) => {
85
- 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(
86
97
  (includePatron: any) =>
87
- includePatron.id == Patron.relationships.user.data.id
98
+ includePatron.id ==
99
+ Patron.relationships.currently_entitled_tiers?.data[0]
100
+ ?.id && includePatron.type === 'tier'
88
101
  )
89
102
 
90
103
  Patrons.push({
@@ -96,8 +109,10 @@ export class Patreon {
96
109
  note: Patron.attributes.note,
97
110
  currentEntitled: {
98
111
  status: Patron.attributes.patron_status,
99
- tierId: Patron.relationships.currently_entitled_tiers
100
- ?.data[0]?.id,
112
+ tier: {
113
+ id: tierInfo.id,
114
+ title: tierInfo.attributes.title,
115
+ },
101
116
  cents: Patron.attributes
102
117
  .currently_entitled_amount_cents,
103
118
  willPayCents: Patron.attributes.will_pay_amount_cents,
@@ -114,11 +129,11 @@ export class Patreon {
114
129
  url: Patron.relationships.user.links.related,
115
130
  },
116
131
  discord: {
117
- id: include.attributes.social_connections.discord
132
+ id: socialInfo.attributes.social_connections.discord
118
133
  .user_id,
119
134
  url:
120
135
  'https://discordapp.com/users/' +
121
- include.attributes.social_connections.discord
136
+ socialInfo.attributes.social_connections.discord
122
137
  .user_id,
123
138
  },
124
139
  },