glitch-javascript-sdk 3.0.1 → 3.0.2
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/cjs/index.js +83 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Posts.d.ts +20 -0
- package/dist/esm/api/Subscriptions.d.ts +18 -0
- package/dist/esm/api/Users.d.ts +18 -0
- package/dist/esm/index.js +83 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +56 -0
- package/package.json +1 -1
- package/src/api/Posts.ts +35 -0
- package/src/api/Subscriptions.ts +24 -0
- package/src/api/Users.ts +24 -0
- package/src/routes/PostsRoute.ts +16 -11
- package/src/routes/SubscriptionsRoute.ts +3 -0
- package/src/routes/UserRoutes.ts +3 -0
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,24 @@ 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>>;
|
|
5425
5481
|
}
|
|
5426
5482
|
|
|
5427
5483
|
declare class Messages {
|
package/package.json
CHANGED
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;
|
package/src/api/Subscriptions.ts
CHANGED
|
@@ -138,6 +138,30 @@ 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
|
+
|
|
141
165
|
|
|
142
166
|
}
|
|
143
167
|
|
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;
|
package/src/routes/PostsRoute.ts
CHANGED
|
@@ -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
|
-
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default PostsRoute;
|
|
@@ -24,6 +24,9 @@ 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
|
+
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
}
|
package/src/routes/UserRoutes.ts
CHANGED
|
@@ -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
|
}
|