glitch-javascript-sdk 3.0.1 → 3.0.3

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/dist/index.d.ts CHANGED
@@ -2324,6 +2324,24 @@ declare class Users {
2324
2324
  title?: string;
2325
2325
  content: string;
2326
2326
  }): AxiosPromise<Response<T>>;
2327
+ /**
2328
+ * List all gifts purchased by the current user.
2329
+ *
2330
+ * @see https://api.glitch.fun/api/documentation#/Users%20Route/userSentGifts
2331
+ *
2332
+ * @param params Optional filters: title_id, status, gift_type, min_amount, max_amount, start_date, end_date, sort_by, sort_order.
2333
+ * @returns promise
2334
+ */
2335
+ static sentGifts<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
2336
+ /**
2337
+ * List all gifts received by the current user.
2338
+ *
2339
+ * @see https://api.glitch.fun/api/documentation#/Users%20Route/userReceivedGifts
2340
+ *
2341
+ * @param params Optional filters: title_id, status, start_date, sort_by.
2342
+ * @returns promise
2343
+ */
2344
+ static receivedGifts<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
2327
2345
  }
2328
2346
 
2329
2347
  declare class Events {
@@ -3219,6 +3237,26 @@ declare class Posts {
3219
3237
  * @returns Promise
3220
3238
  */
3221
3239
  static toggleInteraction<T>(post_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
3240
+ /**
3241
+ * Join a Play Together session.
3242
+ */
3243
+ static joinSession<T>(post_id: string, data?: object): AxiosPromise<Response<T>>;
3244
+ /**
3245
+ * Follow a bug report for updates.
3246
+ */
3247
+ static followBug<T>(post_id: string, data?: object): AxiosPromise<Response<T>>;
3248
+ /**
3249
+ * Update notification preferences for a post.
3250
+ */
3251
+ static updatePreferences<T>(post_id: string, data: object): AxiosPromise<Response<T>>;
3252
+ /**
3253
+ * Leave a session or unfollow a bug.
3254
+ */
3255
+ static leave<T>(post_id: string): AxiosPromise<Response<T>>;
3256
+ /**
3257
+ * Mark a bug as resolved (Admin only).
3258
+ */
3259
+ static resolveBug<T>(post_id: string): AxiosPromise<Response<T>>;
3222
3260
  }
3223
3261
 
3224
3262
  declare class Social {
@@ -5422,6 +5460,34 @@ declare class Subscriptions {
5422
5460
  * Request a refund for a premium purchase.
5423
5461
  */
5424
5462
  static refundLicense<T>(license_id: string): AxiosPromise<Response<T>>;
5463
+ /**
5464
+ * Purchase a game or subscription as a gift for another user.
5465
+ *
5466
+ * @see https://api.glitch.fun/api/documentation#/Subscriptions/purchaseGift
5467
+ *
5468
+ * @param data { gift_type: 'premium'|'rental'|'subscription', payment_method_id: string, title_id?: string, recipient_id?: string, recipient_email?: string, recipient_name?: string }
5469
+ * @returns promise
5470
+ */
5471
+ static purchaseGift<T>(data: object): AxiosPromise<Response<T>>;
5472
+ /**
5473
+ * Redeem a gift code to grant access to a game or subscription.
5474
+ *
5475
+ * @see https://api.glitch.fun/api/documentation#/Subscriptions/redeemGift
5476
+ *
5477
+ * @param redemption_code The unique GLITCH-XXXX-XXXX code.
5478
+ * @returns promise
5479
+ */
5480
+ static redeemGift<T>(redemption_code: string): AxiosPromise<Response<T>>;
5481
+ /**
5482
+ * Cancel an unredeemed gift and trigger a refund.
5483
+ * Only the user who purchased the gift (the giver) can perform this action.
5484
+ *
5485
+ * @see https://api.glitch.fun/api/documentation#/Subscriptions/cancelGift
5486
+ *
5487
+ * @param gift_id The UUID of the gift to cancel.
5488
+ * @returns promise
5489
+ */
5490
+ static cancelGift<T>(gift_id: string): AxiosPromise<Response<T>>;
5425
5491
  }
5426
5492
 
5427
5493
  declare class Messages {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
package/src/api/Posts.ts CHANGED
@@ -172,6 +172,41 @@ class Posts {
172
172
  return Requests.processRoute(PostsRoute.routes.toggleInteraction, data, { post_id: post_id }, params);
173
173
  }
174
174
 
175
+ /**
176
+ * Join a Play Together session.
177
+ */
178
+ public static joinSession<T>(post_id: string, data?: object): AxiosPromise<Response<T>> {
179
+ return Requests.processRoute(PostsRoute.routes.join, data, { post_id });
180
+ }
181
+
182
+ /**
183
+ * Follow a bug report for updates.
184
+ */
185
+ public static followBug<T>(post_id: string, data?: object): AxiosPromise<Response<T>> {
186
+ return Requests.processRoute(PostsRoute.routes.follow, data, { post_id });
187
+ }
188
+
189
+ /**
190
+ * Update notification preferences for a post.
191
+ */
192
+ public static updatePreferences<T>(post_id: string, data: object): AxiosPromise<Response<T>> {
193
+ return Requests.processRoute(PostsRoute.routes.updatePreferences, data, { post_id });
194
+ }
195
+
196
+ /**
197
+ * Leave a session or unfollow a bug.
198
+ */
199
+ public static leave<T>(post_id: string): AxiosPromise<Response<T>> {
200
+ return Requests.processRoute(PostsRoute.routes.leave, {}, { post_id });
201
+ }
202
+
203
+ /**
204
+ * Mark a bug as resolved (Admin only).
205
+ */
206
+ public static resolveBug<T>(post_id: string): AxiosPromise<Response<T>> {
207
+ return Requests.processRoute(PostsRoute.routes.resolve, {}, { post_id });
208
+ }
209
+
175
210
  }
176
211
 
177
212
  export default Posts;
@@ -138,6 +138,42 @@ class Subscriptions {
138
138
  return Requests.processRoute(SubscriptionsRoute.routes.refundLicense, {}, { license_id });
139
139
  }
140
140
 
141
+ /**
142
+ * Purchase a game or subscription as a gift for another user.
143
+ *
144
+ * @see https://api.glitch.fun/api/documentation#/Subscriptions/purchaseGift
145
+ *
146
+ * @param data { gift_type: 'premium'|'rental'|'subscription', payment_method_id: string, title_id?: string, recipient_id?: string, recipient_email?: string, recipient_name?: string }
147
+ * @returns promise
148
+ */
149
+ public static purchaseGift<T>(data: object): AxiosPromise<Response<T>> {
150
+ return Requests.processRoute(SubscriptionsRoute.routes.purchaseGift, data);
151
+ }
152
+
153
+ /**
154
+ * Redeem a gift code to grant access to a game or subscription.
155
+ *
156
+ * @see https://api.glitch.fun/api/documentation#/Subscriptions/redeemGift
157
+ *
158
+ * @param redemption_code The unique GLITCH-XXXX-XXXX code.
159
+ * @returns promise
160
+ */
161
+ public static redeemGift<T>(redemption_code: string): AxiosPromise<Response<T>> {
162
+ return Requests.processRoute(SubscriptionsRoute.routes.redeemGift, { redemption_code });
163
+ }
164
+
165
+ /**
166
+ * Cancel an unredeemed gift and trigger a refund.
167
+ * Only the user who purchased the gift (the giver) can perform this action.
168
+ *
169
+ * @see https://api.glitch.fun/api/documentation#/Subscriptions/cancelGift
170
+ *
171
+ * @param gift_id The UUID of the gift to cancel.
172
+ * @returns promise
173
+ */
174
+ public static cancelGift<T>(gift_id: string): AxiosPromise<Response<T>> {
175
+ return Requests.processRoute(SubscriptionsRoute.routes.cancelGift, {}, { gift_id });
176
+ }
141
177
 
142
178
  }
143
179
 
package/src/api/Users.ts CHANGED
@@ -659,6 +659,30 @@ class Users {
659
659
  return Requests.processRoute(UserRoutes.routes.shareMedia, data, { id });
660
660
  }
661
661
 
662
+ /**
663
+ * List all gifts purchased by the current user.
664
+ *
665
+ * @see https://api.glitch.fun/api/documentation#/Users%20Route/userSentGifts
666
+ *
667
+ * @param params Optional filters: title_id, status, gift_type, min_amount, max_amount, start_date, end_date, sort_by, sort_order.
668
+ * @returns promise
669
+ */
670
+ public static sentGifts<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
671
+ return Requests.processRoute(UserRoutes.routes.sentGifts, undefined, undefined, params);
672
+ }
673
+
674
+ /**
675
+ * List all gifts received by the current user.
676
+ *
677
+ * @see https://api.glitch.fun/api/documentation#/Users%20Route/userReceivedGifts
678
+ *
679
+ * @param params Optional filters: title_id, status, start_date, sort_by.
680
+ * @returns promise
681
+ */
682
+ public static receivedGifts<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
683
+ return Requests.processRoute(UserRoutes.routes.receivedGifts, undefined, undefined, params);
684
+ }
685
+
662
686
  }
663
687
 
664
688
  export default Users;
@@ -2,16 +2,21 @@ import Route from "./interface";
2
2
  import HTTP_METHODS from "../constants/HttpMethods";
3
3
 
4
4
  class PostsRoute {
5
-
6
- public static routes: { [key: string]: Route } = {
7
- list: { url: '/posts', method: HTTP_METHODS.GET },
8
- create: { url: '/posts', method: HTTP_METHODS.POST },
9
- view : { url: '/posts/{post_id}', method: HTTP_METHODS.GET },
10
- update :{ url: '/posts/{post_id}', method: HTTP_METHODS.PUT },
11
- delete : { url: '/posts/{post_id}', method: HTTP_METHODS.DELETE },
12
- toggleInteraction : { url: '/posts/{post_id}/toggleInteraction', method: HTTP_METHODS.POST },
13
- };
14
5
 
15
- }
6
+ public static routes: { [key: string]: Route } = {
7
+ list: { url: '/posts', method: HTTP_METHODS.GET },
8
+ create: { url: '/posts', method: HTTP_METHODS.POST },
9
+ view: { url: '/posts/{post_id}', method: HTTP_METHODS.GET },
10
+ update: { url: '/posts/{post_id}', method: HTTP_METHODS.PUT },
11
+ delete: { url: '/posts/{post_id}', method: HTTP_METHODS.DELETE },
12
+ toggleInteraction: { url: '/posts/{post_id}/toggleInteraction', method: HTTP_METHODS.POST },
13
+ join: { url: '/posts/{post_id}/join', method: HTTP_METHODS.POST },
14
+ follow: { url: '/posts/{post_id}/follow', method: HTTP_METHODS.POST },
15
+ leave: { url: '/posts/{post_id}/leave', method: HTTP_METHODS.DELETE },
16
+ resolve: { url: '/posts/{post_id}/resolve', method: HTTP_METHODS.POST },
17
+ updatePreferences: { url: '/posts/{post_id}/participants/me', method: HTTP_METHODS.PUT },
18
+ };
16
19
 
17
- export default PostsRoute;
20
+ }
21
+
22
+ export default PostsRoute;
@@ -24,6 +24,10 @@ class SubscriptionsRoute {
24
24
  listMyLicenses: { url: '/subscriptions/my-licenses', method: HTTP_METHODS.GET },
25
25
  refundLicense: { url: '/subscriptions/licenses/{license_id}/refund', method: HTTP_METHODS.POST },
26
26
 
27
+ purchaseGift: { url: '/subscriptions/gifts/purchase', method: HTTP_METHODS.POST },
28
+ redeemGift: { url: '/subscriptions/gifts/redeem', method: HTTP_METHODS.POST },
29
+ cancelGift: { url: '/subscriptions/gifts/{gift_id}', method: HTTP_METHODS.DELETE },
30
+
27
31
  };
28
32
 
29
33
  }
@@ -68,6 +68,9 @@ class UserRoutes {
68
68
  modifyMedia: { url: '/users/me/media/{id}/modify', method: HTTP_METHODS.POST },
69
69
  suggestSmartTrim: { url: '/users/me/media/{id}/smart-trim', method: HTTP_METHODS.GET },
70
70
  shareMedia: { url: '/users/me/media/{id}/share', method: HTTP_METHODS.POST },
71
+
72
+ sentGifts: { url: '/users/me/gifts/sent', method: HTTP_METHODS.GET },
73
+ receivedGifts: { url: '/users/me/gifts/received', method: HTTP_METHODS.GET },
71
74
  };
72
75
 
73
76
  }