@@ -280,6 +280,16 @@ export class Api<SecurityDataType> {
280
280
this . securityData = data
281
281
}
282
282
283
+ private addQueryParams ( query : object ) : string {
284
+ const keys = Object . keys ( query ) ;
285
+ return keys . length ? (
286
+ '?' +
287
+ keys . reduce ( ( paramsArray , param ) => [
288
+ ...paramsArray ,
289
+ param + '=' + encodeURIComponent ( query [ param ] )
290
+ ] , [ ] ) . join ( '&' )
291
+ ) : ''
292
+ }
283
293
284
294
private mergeRequestOptions ( params : RequestParams , securityParams ?: RequestParams ) : RequestParams {
285
295
return {
@@ -329,8 +339,8 @@ export class Api<SecurityDataType> {
329
339
* @request GET:/gifs
330
340
* @description A multiget version of the get GIF by ID endpoint..
331
341
*/
332
- getGifsById : ( params ?: RequestParams ) =>
333
- this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/gifs` , "GET" , params , null ) ,
342
+ getGifsById : ( query : { ids ?: string } , params ?: RequestParams ) =>
343
+ this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/gifs${ this . addQueryParams ( query ) } ` , "GET" , params , null ) ,
334
344
335
345
336
346
/**
@@ -340,8 +350,8 @@ export class Api<SecurityDataType> {
340
350
* @request GET:/gifs/random
341
351
* @description Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog..
342
352
*/
343
- randomGif : ( params ?: RequestParams ) =>
344
- this . request < { data ?: Gif , meta ?: Meta } > ( `/gifs/random` , "GET" , params , null ) ,
353
+ randomGif : ( query : { tag ?: string , rating ?: string } , params ?: RequestParams ) =>
354
+ this . request < { data ?: Gif , meta ?: Meta } > ( `/gifs/random${ this . addQueryParams ( query ) } ` , "GET" , params , null ) ,
345
355
346
356
347
357
/**
@@ -351,8 +361,8 @@ export class Api<SecurityDataType> {
351
361
* @request GET:/gifs/search
352
362
* @description Search all GIPHY GIFs for a word or phrase. Punctuation will be stripped and ignored. Use a plus or url encode for phrases. Example paul+rudd, ryan+gosling or american+psycho..
353
363
*/
354
- searchGifs : ( params ?: RequestParams ) =>
355
- this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/gifs/search` , "GET" , params , null ) ,
364
+ searchGifs : ( query : { q : string , limit ?: number , offset ?: number , rating ?: string , lang ?: string } , params ?: RequestParams ) =>
365
+ this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/gifs/search${ this . addQueryParams ( query ) } ` , "GET" , params , null ) ,
356
366
357
367
358
368
/**
@@ -362,8 +372,8 @@ export class Api<SecurityDataType> {
362
372
* @request GET:/gifs/translate
363
373
* @description The translate API draws on search, but uses the GIPHY `special sauce` to handle translating from one vocabulary to another. In this case, words and phrases to GIF.
364
374
*/
365
- translateGif : ( params ?: RequestParams ) =>
366
- this . request < { data ?: Gif , meta ?: Meta } > ( `/gifs/translate` , "GET" , params , null ) ,
375
+ translateGif : ( query : { s : string } , params ?: RequestParams ) =>
376
+ this . request < { data ?: Gif , meta ?: Meta } > ( `/gifs/translate${ this . addQueryParams ( query ) } ` , "GET" , params , null ) ,
367
377
368
378
369
379
/**
@@ -373,8 +383,8 @@ export class Api<SecurityDataType> {
373
383
* @request GET:/gifs/trending
374
384
* @description Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the GIPHY homepage. Returns 25 results by default..
375
385
*/
376
- trendingGifs : ( params ?: RequestParams ) =>
377
- this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/gifs/trending` , "GET" , params , null ) ,
386
+ trendingGifs : ( query : { limit ?: number , offset ?: number , rating ?: string } , params ?: RequestParams ) =>
387
+ this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/gifs/trending${ this . addQueryParams ( query ) } ` , "GET" , params , null ) ,
378
388
379
389
380
390
/**
@@ -384,7 +394,7 @@ export class Api<SecurityDataType> {
384
394
* @request GET:/gifs/{gifId}
385
395
* @description Returns a GIF given that GIF's unique ID.
386
396
*/
387
- getGifById : ( params ?: RequestParams ) =>
397
+ getGifById : ( gifId : number , params ?: RequestParams ) =>
388
398
this . request < { data ?: Gif , meta ?: Meta } > ( `/gifs/${ gifId } ` , "GET" , params , null ) ,
389
399
}
390
400
stickers = {
@@ -397,8 +407,8 @@ export class Api<SecurityDataType> {
397
407
* @request GET:/stickers/random
398
408
* @description Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog..
399
409
*/
400
- randomSticker : ( params ?: RequestParams ) =>
401
- this . request < { data ?: Gif , meta ?: Meta } > ( `/stickers/random` , "GET" , params , null ) ,
410
+ randomSticker : ( query : { tag ?: string , rating ?: string } , params ?: RequestParams ) =>
411
+ this . request < { data ?: Gif , meta ?: Meta } > ( `/stickers/random${ this . addQueryParams ( query ) } ` , "GET" , params , null ) ,
402
412
403
413
404
414
/**
@@ -408,8 +418,8 @@ export class Api<SecurityDataType> {
408
418
* @request GET:/stickers/search
409
419
* @description Replicates the functionality and requirements of the classic GIPHY search, but returns animated stickers rather than GIFs..
410
420
*/
411
- searchStickers : ( params ?: RequestParams ) =>
412
- this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/stickers/search` , "GET" , params , null ) ,
421
+ searchStickers : ( query : { q : string , limit ?: number , offset ?: number , rating ?: string , lang ?: string } , params ?: RequestParams ) =>
422
+ this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/stickers/search${ this . addQueryParams ( query ) } ` , "GET" , params , null ) ,
413
423
414
424
415
425
/**
@@ -419,8 +429,8 @@ export class Api<SecurityDataType> {
419
429
* @request GET:/stickers/translate
420
430
* @description The translate API draws on search, but uses the GIPHY `special sauce` to handle translating from one vocabulary to another. In this case, words and phrases to GIFs..
421
431
*/
422
- translateSticker : ( params ?: RequestParams ) =>
423
- this . request < { data ?: Gif , meta ?: Meta } > ( `/stickers/translate` , "GET" , params , null ) ,
432
+ translateSticker : ( query : { s : string } , params ?: RequestParams ) =>
433
+ this . request < { data ?: Gif , meta ?: Meta } > ( `/stickers/translate${ this . addQueryParams ( query ) } ` , "GET" , params , null ) ,
424
434
425
435
426
436
/**
@@ -430,8 +440,8 @@ export class Api<SecurityDataType> {
430
440
* @request GET:/stickers/trending
431
441
* @description Fetch Stickers currently trending online. Hand curated by the GIPHY editorial team. Returns 25 results by default..
432
442
*/
433
- trendingStickers : ( params ?: RequestParams ) =>
434
- this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/stickers/trending` , "GET" , params , null ) ,
443
+ trendingStickers : ( query : { limit ?: number , offset ?: number , rating ?: string } , params ?: RequestParams ) =>
444
+ this . request < { data ?: Gif [ ] , meta ?: Meta , pagination ?: Pagination } > ( `/stickers/trending${ this . addQueryParams ( query ) } ` , "GET" , params , null ) ,
435
445
}
436
446
437
447
}
0 commit comments