Skip to content

Commit

Permalink
DEVEXP-321: Add sub methods for messages and events with different ki…
Browse files Browse the repository at this point in the history
…nds of recipient
  • Loading branch information
asein-sinch committed Mar 11, 2024
1 parent d423046 commit e483c1d
Show file tree
Hide file tree
Showing 52 changed files with 2,482 additions and 464 deletions.
115 changes: 65 additions & 50 deletions examples/simple-examples/README.md

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion examples/simple-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
"conversation:contact:getChannelProfile": "ts-node src/conversation/contact/getChannelProfile.ts",
"conversation:contact:delete": "ts-node src/conversation/contact/delete.ts",
"conversation:messages:send": "ts-node src/conversation/messages/send.ts",
"conversation:messages:sendCardMessage": "ts-node src/conversation/messages/sendCardMessage.ts",
"conversation:messages:sendCarouselMessage": "ts-node src/conversation/messages/sendCarouselMessage.ts",
"conversation:messages:sendChoiceMessage": "ts-node src/conversation/messages/sendChoiceMessage.ts",
"conversation:messages:sendContactInfoMessage": "ts-node src/conversation/messages/sendContactInfoMessage.ts",
"conversation:messages:sendListMessage": "ts-node src/conversation/messages/sendListMessage.ts",
"conversation:messages:sendLocationMessage": "ts-node src/conversation/messages/sendLocationMessage.ts",
"conversation:messages:sendMediaMessage": "ts-node src/conversation/messages/sendMediaMessage.ts",
"conversation:messages:sendTemplateMessage": "ts-node src/conversation/messages/sendTemplateMessage.ts",
"conversation:messages:sendTextMessage": "ts-node src/conversation/messages/sendTextMessage.ts",
"conversation:messages:get": "ts-node src/conversation/messages/get.ts",
"conversation:messages:list": "ts-node src/conversation/messages/list.ts",
"conversation:messages:update": "ts-node src/conversation/messages/update.ts",
Expand All @@ -35,6 +44,12 @@
"conversation:conversation:stop": "ts-node src/conversation/conversation/stop.ts",
"conversation:conversation:delete": "ts-node src/conversation/conversation/delete.ts",
"conversation:events:send": "ts-node src/conversation/events/send.ts",
"conversation:events:sendComposingEvent": "ts-node src/conversation/events/sendComposingEvent.ts",
"conversation:events:sendComposingEndEvent": "ts-node src/conversation/events/sendComposingEndEvent.ts",
"conversation:events:sendCommentReplyEvent": "ts-node src/conversation/events/sendCommentReplyEvent.ts",
"conversation:events:sendAgentJoinedEvent": "ts-node src/conversation/events/sendAgentJoinedEvent.ts",
"conversation:events:sendAgentLeftEvent": "ts-node src/conversation/events/sendAgentLeftEvent.ts",
"conversation:events:sendGenericEvent": "ts-node src/conversation/events/sendGenericEvent.ts",
"conversation:events:get": "ts-node src/conversation/events/get.ts",
"conversation:events:list": "ts-node src/conversation/events/list.ts",
"conversation:events:delete": "ts-node src/conversation/events/delete.ts",
Expand All @@ -53,7 +68,7 @@
"conversation:templatev2:create": "ts-node src/conversation/templates-v2/create.ts",
"conversation:templatev2:get": "ts-node src/conversation/templates-v2/get.ts",
"conversation:templatev2:list": "ts-node src/conversation/templates-v2/list.ts",
"conversation:templatev2:listTranslations": "ts-node src/conversation/templates-v2/list-translations.ts pretty",
"conversation:templatev2:listTranslations": "ts-node src/conversation/templates-v2/list-translations.ts",
"conversation:templatev2:update": "ts-node src/conversation/templates-v2/update.ts",
"conversation:templatev2:delete": "ts-node src/conversation/templates-v2/delete.ts",
"numbers:regions:list": "ts-node src/numbers/regions/list.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LookupCapabilityRequestData } from '@sinch/sdk-core';
import { ContactId, LookupCapabilityRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
Expand All @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullRespon
const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: LookupCapabilityRequestData = {
const requestData: LookupCapabilityRequestData<ContactId> = {
lookupCapabilityRequestBody: {
app_id: appId,
recipient: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GetChannelProfileRequestData } from '@sinch/sdk-core';
import { GetChannelProfileRequestData, IdentifiedBy } from '@sinch/sdk-core';
import {
getAppIdFromConfig,
getMessengerUserIdFromConfig,
Expand All @@ -14,7 +14,7 @@ import {
const appId = getAppIdFromConfig();
const messengerUserId = getMessengerUserIdFromConfig();

const requestData: GetChannelProfileRequestData = {
const requestData: GetChannelProfileRequestData<IdentifiedBy> = {
getChannelProfileRequestBody: {
app_id: appId,
channel: 'MESSENGER',
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-examples/src/conversation/events/send.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SendEventRequestData } from '@sinch/sdk-core';
import { ContactId, SendEventRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
Expand All @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullRespon
const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendEventRequestData = {
const requestData: SendEventRequestData<ContactId> = {
sendEventRequestBody: {
app_id: appId,
recipient: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ContactId, SendAgentJoinedEventRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
console.log('********************');
console.log('* Events_SendEvent *');
console.log('********************');

const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendAgentJoinedEventRequestData<ContactId> = {
sendEventRequestBody: {
app_id: appId,
recipient: {
contact_id: contactId,
},
event: {
agent_joined_event: {
agent: {
display_name: 'Agent bot name',
type: 'BOT',
},
},
},
},
};

const sinchClient = initClient();
const response = await sinchClient.conversation.events.sendAgentJoinedEvent(requestData);

printFullResponse(response);

})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ContactId, SendAgentLeftEventRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
console.log('********************');
console.log('* Events_SendEvent *');
console.log('********************');

const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendAgentLeftEventRequestData<ContactId> = {
sendEventRequestBody: {
app_id: appId,
recipient: {
contact_id: contactId,
},
event: {
agent_left_event: {
agent: {
display_name: 'Agent bot name',
type: 'BOT',
},
},
},
},
};

const sinchClient = initClient();
const response = await sinchClient.conversation.events.sendAgentLeftEvent(requestData);

printFullResponse(response);

})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ContactId, SendCommentReplyEventRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
console.log('********************');
console.log('* Events_SendEvent *');
console.log('********************');

const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendCommentReplyEventRequestData<ContactId> = {
sendEventRequestBody: {
app_id: appId,
recipient: {
contact_id: contactId,
},
event: {
comment_reply_event: {
text: 'Comment data',
},
},
},
};

const sinchClient = initClient();
const response = await sinchClient.conversation.events.sendCommentReplyEvent(requestData);

printFullResponse(response);

})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ContactId, SendComposingEndEventRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
console.log('********************');
console.log('* Events_SendEvent *');
console.log('********************');

const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendComposingEndEventRequestData<ContactId> = {
sendEventRequestBody: {
app_id: appId,
recipient: {
contact_id: contactId,
},
event: {
composing_end_event: {},
},
},
};

const sinchClient = initClient();
const response = await sinchClient.conversation.events.sendComposingEndEvent(requestData);

printFullResponse(response);

})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ContactId, SendComposingEventRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
console.log('********************');
console.log('* Events_SendEvent *');
console.log('********************');

const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendComposingEventRequestData<ContactId> = {
sendEventRequestBody: {
app_id: appId,
recipient: {
contact_id: contactId,
},
event: {
composing_event: {},
},
},
};

const sinchClient = initClient();
const response = await sinchClient.conversation.events.sendComposingEvent(requestData);

printFullResponse(response);

})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ContactId, SendGenericEventRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
console.log('********************');
console.log('* Events_SendEvent *');
console.log('********************');

const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendGenericEventRequestData<ContactId> = {
sendEventRequestBody: {
app_id: appId,
recipient: {
contact_id: contactId,
},
event: {
generic_event: {
payload: {
key: 'value for the generic event',
},
},
},
},
};

const sinchClient = initClient();
const response = await sinchClient.conversation.events.sendGenericEvent(requestData);

printFullResponse(response);

})();
6 changes: 3 additions & 3 deletions examples/simple-examples/src/conversation/messages/send.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SendMessageRequestData } from '@sinch/sdk-core';
import { ContactId, SendMessageRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
Expand All @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullRespon
const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendMessageRequestData = {
const requestData: SendMessageRequestData<ContactId> = {
sendMessageRequestBody: {
app_id: appId,
message: {
Expand All @@ -20,7 +20,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullRespon
recipient: {
contact_id: contactId,
},
correlation_id: 'correlator',
correlation_id: 'correlatorId',
queue: 'HIGH_PRIORITY',
processing_strategy: 'DEFAULT',
channel_priority_order: ['MESSENGER'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ContactId, SendCardMessageRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
console.log('****************************');
console.log('* Messages_SendCardMessage *');
console.log('****************************');

const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendCardMessageRequestData<ContactId> = {
sendMessageRequestBody: {
app_id: appId,
message: {
card_message: {
title: 'Card message title',
description: 'Card message description',
height: 'MEDIUM',
},
},
recipient: {
contact_id: contactId,
},
correlation_id: 'correlatorId',
queue: 'HIGH_PRIORITY',
processing_strategy: 'DEFAULT',
channel_priority_order: ['MESSENGER'],
},
};

const sinchClient = initClient();
const response = await sinchClient.conversation.messages.sendCardMessage(requestData);

printFullResponse(response);

})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ContactId, SendCarouselMessageRequestData } from '@sinch/sdk-core';
import { getAppIdFromConfig, getContactIdFromConfig, initClient, printFullResponse } from '../../config';

(async () => {
console.log('********************************');
console.log('* Messages_SendCarouselMessage *');
console.log('********************************');

const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: SendCarouselMessageRequestData<ContactId> = {
sendMessageRequestBody: {
app_id: appId,
message: {
carousel_message: {
cards: [
{
title: 'Card #1 title',
description: 'Card #1 description',
height: 'TALL',
},
{
title: 'Card #2 title',
description: 'Card #2 description',
height: 'TALL',
},
],
},
},
recipient: {
contact_id: contactId,
},
correlation_id: 'correlatorId',
queue: 'HIGH_PRIORITY',
processing_strategy: 'DEFAULT',
channel_priority_order: ['MESSENGER'],
},
};

const sinchClient = initClient();
const response = await sinchClient.conversation.messages.sendCarouselMessage(requestData);

printFullResponse(response);

})();
Loading

0 comments on commit e483c1d

Please sign in to comment.