@@ -5,6 +5,7 @@ import {Wrapper} from '../objects/Wrapper';
55import  { AdvancedSearchOptions }  from  '../method-options/StackExchange/AdvancedSearchOptions' ; 
66import  { GetAnswersOptions }  from  '../method-options/StackExchange/GetAnswersOptions' ; 
77import  { GetAnswersByIdsOptions }  from  '../method-options/StackExchange/GetAnswersByIdsOptions' ; 
8+ import  { GetBadgesOptions }  from  '../method-options/StackExchange/GetBadgesOptions' ; 
89import  { GetCommentsOptions }  from  '../method-options/StackExchange/GetCommentsOptions' ; 
910import  { GetCommentsByIdsOptions }  from  '../method-options/StackExchange/GetCommentsByIdsOptions' ; 
1011import  { GetCommentsOnAnswersOptions }  from  '../method-options/StackExchange/GetCommentsOnAnswersOptions' ; 
@@ -255,6 +256,59 @@ export class StackExchange {
255256 } 
256257
257258
259+  /* 
260+  * A method for the /badges endpoint: https://api.stackexchange.com/docs/badges 
261+  * Returns all the badges in the system. 
262+  * This method returns an array of badges (Badge[]) wrapped in a Wrapper. 
263+  */ 
264+  public  static  async  getBadges  ( 
265+  options : GetBadgesOptions 
266+  ) : Promise < Wrapper >  { 
267+  const  getBadgesUrl  =  new  URL ( '/badges' ,  this . baseUrl ) ; 
268+ 269+  if  ( options . fromDate )  { 
270+  getBadgesUrl . searchParams . append ( 'fromdate' ,  this . dateHandler ( options . fromDate ) ) ; 
271+  } 
272+  if  ( options . inName )  { 
273+  getBadgesUrl . searchParams . append ( 'inname' ,  options . inName ) ; 
274+  } 
275+  if  ( options . max )  { 
276+  getBadgesUrl . searchParams . append ( 'max' ,  options . max ) ; 
277+  } 
278+  if  ( options . min )  { 
279+  getBadgesUrl . searchParams . append ( 'min' ,  options . min ) ; 
280+  } 
281+  if  ( options . order )  { 
282+  getBadgesUrl . searchParams . append ( 'order' ,  options . order ) ; 
283+  } 
284+  if  ( options . page )  { 
285+  getBadgesUrl . searchParams . append ( 'page' ,  options . page . toString ( ) ) ; 
286+  } 
287+  if  ( options . pageSize )  { 
288+  getBadgesUrl . searchParams . append ( 'pagesize' ,  options . pageSize . toString ( ) ) ; 
289+  } 
290+  getBadgesUrl . searchParams . append ( 'site' ,  options . site ) ; 
291+  if  ( options . sort )  { 
292+  getBadgesUrl . searchParams . append ( 'sort' ,  options . sort ) ; 
293+  } 
294+  if  ( options . toDate )  { 
295+  getBadgesUrl . searchParams . append ( 'todate' ,  this . dateHandler ( options . toDate ) ) ; 
296+  } 
297+ 298+  return  new  Wrapper ( 
299+  await  rp . get ( 
300+  getBadgesUrl . href ,  { 
301+  headers : { 
302+  'accept-encoding' : 'gzip' , 
303+  } , 
304+  gzip : true , 
305+  json : true , 
306+  } 
307+  ) ,  'Badge' 
308+  ) ; 
309+  } 
310+ 311+ 258312 /* 
259313 * A method for the /comments endpoint: https://api.stackexchange.com/docs/comments 
260314 * Gets all the comments on the site. 
0 commit comments