@@ -20,6 +20,12 @@ import {
20
20
listBatchComplianceJobs ,
21
21
createBatchComplianceJob ,
22
22
getBatchComplianceJob ,
23
+ dmConversationIdCreate ,
24
+ getDmConversationsWithParticipantIdDmEvents ,
25
+ dmConversationWithUserEventIdCreate ,
26
+ dmConversationByIdEventIdCreate ,
27
+ getDmConversationsIdDmEvents ,
28
+ getDmEvents ,
23
29
listIdCreate ,
24
30
listIdDelete ,
25
31
listIdGet ,
@@ -108,8 +114,8 @@ export class Client {
108
114
auth : string | AuthClient ,
109
115
requestOptions ?: Partial < RequestOptions >
110
116
) {
111
- this . version = "1.2.1 " ;
112
- this . twitterApiOpenApiVersion = "2.54 " ;
117
+ this . version = "1.3.0 " ;
118
+ this . twitterApiOpenApiVersion = "2.55 " ;
113
119
this . #auth = typeof auth === "string" ? new OAuth2Bearer ( auth ) : auth ;
114
120
this . #defaultRequestOptions = {
115
121
...requestOptions ,
@@ -334,6 +340,153 @@ export class Client {
334
340
method : "GET" ,
335
341
} ) ,
336
342
} ;
343
+ /**
344
+ * Direct Messages
345
+ *
346
+ * Endpoints related to retrieving, managing Direct Messages
347
+ *
348
+ * Find out more
349
+ * https://developer.twitter.com/en/docs/twitter-api/direct-messages
350
+ */
351
+ public readonly directMessages = {
352
+ /**
353
+ * Create a new DM Conversation
354
+ *
355
+
356
+ * Creates a new DM Conversation.
357
+ * @param request_body - The request_body for dmConversationIdCreate
358
+ * @param request_options - Customize the options for this request
359
+ */
360
+ dmConversationIdCreate : (
361
+ request_body : TwitterBody < dmConversationIdCreate > ,
362
+ request_options ?: Partial < RequestOptions >
363
+ ) : Promise < TwitterResponse < dmConversationIdCreate > > =>
364
+ rest < TwitterResponse < dmConversationIdCreate > > ( {
365
+ auth : this . #auth,
366
+ ...this . #defaultRequestOptions,
367
+ ...request_options ,
368
+ endpoint : `/2/dm_conversations` ,
369
+ request_body,
370
+ method : "POST" ,
371
+ } ) ,
372
+
373
+ /**
374
+ * Get DM Events for a DM Conversation
375
+ *
376
+
377
+ * Returns DM Events for a DM Conversation
378
+ * @param participant_id - The ID of the participant user for the One to One DM conversation.
379
+ * @param params - The params for getDmConversationsWithParticipantIdDmEvents
380
+ * @param request_options - Customize the options for this request
381
+ */
382
+ getDmConversationsWithParticipantIdDmEvents : (
383
+ participant_id : string ,
384
+ params : TwitterParams < getDmConversationsWithParticipantIdDmEvents > = { } ,
385
+ request_options ?: Partial < RequestOptions >
386
+ ) : TwitterPaginatedResponse <
387
+ TwitterResponse < getDmConversationsWithParticipantIdDmEvents >
388
+ > =>
389
+ paginate < TwitterResponse < getDmConversationsWithParticipantIdDmEvents > > ( {
390
+ auth : this . #auth,
391
+ ...this . #defaultRequestOptions,
392
+ ...request_options ,
393
+ endpoint : `/2/dm_conversations/with/${ participant_id } /dm_events` ,
394
+ params,
395
+ method : "GET" ,
396
+ } ) ,
397
+
398
+ /**
399
+ * Send a new message to a user
400
+ *
401
+
402
+ * Creates a new message for a DM Conversation with a participant user by ID
403
+ * @param participant_id - The ID of the recipient user that will receive the DM.
404
+ * @param request_body - The request_body for dmConversationWithUserEventIdCreate
405
+ * @param request_options - Customize the options for this request
406
+ */
407
+ dmConversationWithUserEventIdCreate : (
408
+ participant_id : string ,
409
+ request_body : TwitterBody < dmConversationWithUserEventIdCreate > ,
410
+ request_options ?: Partial < RequestOptions >
411
+ ) : Promise < TwitterResponse < dmConversationWithUserEventIdCreate > > =>
412
+ rest < TwitterResponse < dmConversationWithUserEventIdCreate > > ( {
413
+ auth : this . #auth,
414
+ ...this . #defaultRequestOptions,
415
+ ...request_options ,
416
+ endpoint : `/2/dm_conversations/with/${ participant_id } /messages` ,
417
+ request_body,
418
+ method : "POST" ,
419
+ } ) ,
420
+
421
+ /**
422
+ * Send a new message to a DM Conversation
423
+ *
424
+
425
+ * Creates a new message for a DM Conversation specified by DM Conversation ID
426
+ * @param dm_conversation_id - The DM Conversation ID.
427
+ * @param request_body - The request_body for dmConversationByIdEventIdCreate
428
+ * @param request_options - Customize the options for this request
429
+ */
430
+ dmConversationByIdEventIdCreate : (
431
+ dm_conversation_id : string ,
432
+ request_body : TwitterBody < dmConversationByIdEventIdCreate > ,
433
+ request_options ?: Partial < RequestOptions >
434
+ ) : Promise < TwitterResponse < dmConversationByIdEventIdCreate > > =>
435
+ rest < TwitterResponse < dmConversationByIdEventIdCreate > > ( {
436
+ auth : this . #auth,
437
+ ...this . #defaultRequestOptions,
438
+ ...request_options ,
439
+ endpoint : `/2/dm_conversations/${ dm_conversation_id } /messages` ,
440
+ request_body,
441
+ method : "POST" ,
442
+ } ) ,
443
+
444
+ /**
445
+ * Get DM Events for a DM Conversation
446
+ *
447
+
448
+ * Returns DM Events for a DM Conversation
449
+ * @param id - The DM Conversation ID.
450
+ * @param params - The params for getDmConversationsIdDmEvents
451
+ * @param request_options - Customize the options for this request
452
+ */
453
+ getDmConversationsIdDmEvents : (
454
+ id : string ,
455
+ params : TwitterParams < getDmConversationsIdDmEvents > = { } ,
456
+ request_options ?: Partial < RequestOptions >
457
+ ) : TwitterPaginatedResponse <
458
+ TwitterResponse < getDmConversationsIdDmEvents >
459
+ > =>
460
+ paginate < TwitterResponse < getDmConversationsIdDmEvents > > ( {
461
+ auth : this . #auth,
462
+ ...this . #defaultRequestOptions,
463
+ ...request_options ,
464
+ endpoint : `/2/dm_conversations/${ id } /dm_events` ,
465
+ params,
466
+ method : "GET" ,
467
+ } ) ,
468
+
469
+ /**
470
+ * Get recent DM Events
471
+ *
472
+
473
+ * Returns recent DM Events across DM conversations
474
+ * @param params - The params for getDmEvents
475
+ * @param request_options - Customize the options for this request
476
+ */
477
+ getDmEvents : (
478
+ params : TwitterParams < getDmEvents > = { } ,
479
+ request_options ?: Partial < RequestOptions >
480
+ ) : TwitterPaginatedResponse < TwitterResponse < getDmEvents > > =>
481
+ paginate < TwitterResponse < getDmEvents > > ( {
482
+ auth : this . #auth,
483
+ ...this . #defaultRequestOptions,
484
+ ...request_options ,
485
+ endpoint : `/2/dm_events` ,
486
+ params,
487
+ method : "GET" ,
488
+ } ) ,
489
+ } ;
337
490
/**
338
491
* General
339
492
*
0 commit comments