Skip to content

Commit

Permalink
Update models and API methods and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
asein-sinch committed Jan 25, 2024
1 parent 3a0f6fa commit ddb3a4a
Show file tree
Hide file tree
Showing 27 changed files with 208 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ export interface AppMessage {
explicit_channel_message?: object;
/** @see AppMessageAdditionalProperties */
additionalProperties?: AppMessageAdditionalProperties;

/** TBC: Not documented */
agent?: any | null;
/** TBC: Not documented */
explicit_channel_omni_message?: object;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AppMessage } from '../app-message';
import { ChannelIdentity } from '../channel-identity';
import { ContactMessage } from '../contact-message';
import { ConversationDirection } from '../conversation-direction';
import { ProcessingMode } from '../processing-mode';

/**
* A message on a particular channel.
Expand All @@ -28,4 +29,11 @@ export interface ConversationMessage {
metadata?: string;
/** Flag for whether this message was injected. */
injected?: boolean;

/** TBC: Not documented */
sender_id?: string;
/** TBC: Not documented */
processing_mode?: ProcessingMode;
/** TBC: Not documented */
message_status?: any | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ export interface Conversation {
metadata?: string;
/** Arbitrary data set by the Conversation API clients and/or provided in the `conversation_metadata` field of a SendMessageRequest. A valid JSON object. */
metadata_json?: object;
/** Up to 128 characters long */
correlation_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export interface CreateConversationRequest {
app_id: string;
/** The ID of the participating contact. */
contact_id: string;
/** The ID of the conversation. */
id?: string;
/** Arbitrary data set by the Conversation API clients. Up to 1024 characters long. */
metadata?: string;
/** Arbitrary data set by the Conversation API clients and/or provided in the `conversation_metadata` field of a SendMessageRequest. A valid JSON object. */
Expand Down
2 changes: 1 addition & 1 deletion packages/conversation/src/models/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export * from './processing-mode';
export * from './processing-strategy';
export * from './product';
export * from './error-detail';
export * from './query-capability';
export * from './lookup-capability';
export * from './query-capability-response';
export * from './queue-stats';
export * from './rate-limits';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { LookupCapability } from './lookup-capability';
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Recipient } from '../recipient';

export interface QueryCapability {
export interface LookupCapability {

/** The ID of the app to use for capability lookup. */
app_id: string;
/** @see Recipient */
recipient: Recipient;
/** ID for the asynchronous response, will be generated if not set. Currently this field is not used for idempotency. */
/** ID for the asynchronous response, will be generated if not set. Currently, this field is not used for idempotency. */
request_id?: string;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AppMessage } from '../app-message';
import { ConversationChannel } from '../conversation-channel';
import { MessageQueue } from '../message-queue';
import { Recipient } from '../recipient';
import { ProcessingStrategy } from '../processing-strategy';
import { ConversationMetadataUpdateStrategy } from '../conversation-metadata-update-strategy';
import { AppMessageMessage } from '../app-message-message';

/**
* This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields.
Expand All @@ -19,7 +19,7 @@ export interface SendMessageRequest {
/** Channel-specific properties. The key in the map must point to a valid channel property key as defined by the enum ChannelPropertyKeys. The maximum allowed property value length is 1024 characters. */
channel_properties?: { [key: string]: string; };
/** @see AppMessage */
message: AppMessage;
message: AppMessageMessage;
/** Metadata that should be associated with the message. Returned in the `metadata` field of a [Message Delivery Receipt](https://developers.sinch.com/docs/conversation/callbacks/#message-delivery-receipt). Up to 1024 characters long. */
message_metadata?: string;
/** Metadata that should be associated with the conversation. This metadata will be propagated on MO callbacks associated with this conversation. Up to 1024 characters long. Note that the MO callback will always use the last metadata available in the conversation. Important notes: - If you send a message with the `conversation_metadata` field populated, and then send another message without populating the `conversation_metadata` field, the original metadata will continue be propagated on the related MO callbacks. - If you send a message with the `conversation_metadata` field populated, and then send another message with a different value for `conversation_metadata` in the same conversation, the latest metadata value overwrites the existing one. So, future MO callbacks will include the new metadata. - The `conversation_metadata` only accepts json objects. Currently only returned in the `message_metadata` field of an [Inbound Message](/docs/conversation/callbacks/#inbound-message) callback. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AppMessage } from '../app-message';
import { ConversationChannel } from '../conversation-channel';
import { AppMessageMessage } from '../app-message-message';

export interface TranscodeMessageRequest {

/** The ID of the app used to transcode the message. */
app_id: string;
/** @see AppMessage */
app_message: AppMessage;
/** @see AppMessageMessage */
app_message: AppMessageMessage;
/** The list of channels for which the message shall be transcoded to. */
channels: ConversationChannel[];
/** Optional. */
Expand Down
5 changes: 0 additions & 5 deletions packages/conversation/src/rest/v1/app/app-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export class AppApi extends ConversationDomainApi {
const headers: { [key: string]: string | undefined } = {
'Content-Type': 'application/json',
'Accept': 'application/json',

};

const body: RequestBody = data['appCreateRequestBody'] ? JSON.stringify(data['appCreateRequestBody']) : '{}';
Expand Down Expand Up @@ -83,7 +82,6 @@ export class AppApi extends ConversationDomainApi {
const headers: { [key: string]: string | undefined } = {
'Content-Type': 'application/json',
'Accept': 'application/json',

};

const body: RequestBody = '';
Expand Down Expand Up @@ -112,7 +110,6 @@ export class AppApi extends ConversationDomainApi {
const headers: { [key: string]: string | undefined } = {
'Content-Type': 'application/json',
'Accept': 'application/json',

};

const body: RequestBody = '';
Expand Down Expand Up @@ -140,7 +137,6 @@ export class AppApi extends ConversationDomainApi {
const headers: { [key: string]: string | undefined } = {
'Content-Type': 'application/json',
'Accept': 'application/json',

};

const body: RequestBody = '';
Expand Down Expand Up @@ -168,7 +164,6 @@ export class AppApi extends ConversationDomainApi {
const headers: { [key: string]: string | undefined } = {
'Content-Type': 'application/json',
'Accept': 'application/json',

};

const body: RequestBody = data['appUpdateRequestBody'] ? JSON.stringify(data['appUpdateRequestBody']) : '{}';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { QueryCapabilityResponse } from '../../../models';
import { CapabilityApi, QueryCapabilityRequestData } from './capability-api';
import { CapabilityApi, LookupCapabilityRequestData } from './capability-api';

export class CapabilityApiFixture implements Partial<Readonly<CapabilityApi>> {

/**
* Fixture associated to function queryCapability
* Fixture associated to function lookup
*/
public queryCapability: jest.Mock<Promise<QueryCapabilityResponse>, [QueryCapabilityRequestData]> = jest.fn();
public lookup: jest.Mock<Promise<QueryCapabilityResponse>, [LookupCapabilityRequestData]> = jest.fn();
}

19 changes: 10 additions & 9 deletions packages/conversation/src/rest/v1/capability/capability-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {
SinchClientParameters,
} from '@sinch/sdk-client';
import {
QueryCapability,
LookupCapability,
QueryCapabilityResponse,
} from '../../../models';
import { ConversationDomainApi } from '../conversation-domain-api';

export interface QueryCapabilityRequestData {
/** The query capability request. */
'queryCapabilityBody': QueryCapability;
export interface LookupCapabilityRequestData {
/** The lookup capability request. */
'lookupCapabilityRequestBody': LookupCapability;
}

export class CapabilityApi extends ConversationDomainApi {
Expand All @@ -27,18 +27,19 @@ export class CapabilityApi extends ConversationDomainApi {
/**
* Capability lookup
* This method is asynchronous - it immediately returns the requested Capability registration. Capability check is then delivered as a callback to registered webhooks with trigger CAPABILITY for every reachable channel.
* @param { QueryCapabilityRequestData } data - The data to provide to the API call.
* @param { LookupCapabilityRequestData } data - The data to provide to the API call.
*/
public async queryCapability(data: QueryCapabilityRequestData): Promise<QueryCapabilityResponse> {
public async lookup(data: LookupCapabilityRequestData): Promise<QueryCapabilityResponse> {
this.client = this.getSinchClient();
const getParams = this.client.extractQueryParams<QueryCapabilityRequestData>(data, [] as never[]);
const getParams = this.client.extractQueryParams<LookupCapabilityRequestData>(data, [] as never[]);
const headers: { [key: string]: string | undefined } = {
'Content-Type': 'application/json',
'Accept': 'application/json',

};

const body: RequestBody = data['queryCapabilityBody'] ? JSON.stringify(data['queryCapabilityBody']) : '{}';
const body: RequestBody = data['lookupCapabilityRequestBody']
? JSON.stringify(data['lookupCapabilityRequestBody'])
: '{}';
const basePathUrl = `${this.client.apiClientOptions.basePath}/v1/projects/${this.client.apiClientOptions.projectId}/capability:query`;

const requestOptions = await this.client.prepareOptions(basePathUrl, 'POST', getParams, headers, body || undefined);
Expand Down
4 changes: 2 additions & 2 deletions packages/conversation/src/rest/v1/contact/contact-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface UpdateContactRequestData {
/** The unique ID of the contact. */
'contact_id': string;
/** The updated contact. */
'updateContactBody': Contact;
'updateContactRequestBody': Contact;
/** The set of field mask paths. */
'update_mask'?: Array<string>;
}
Expand Down Expand Up @@ -266,7 +266,7 @@ export class ContactApi extends ConversationDomainApi {
'Accept': 'application/json',
};

const body: RequestBody = data['updateContactBody'] ? JSON.stringify(data['updateContactBody']) : '{}';
const body: RequestBody = data['updateContactRequestBody'] ? JSON.stringify(data['updateContactRequestBody']) : '{}';

Check failure on line 269 in packages/conversation/src/rest/v1/contact/contact-api.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

This line has a length of 121. Maximum allowed is 120

Check failure on line 269 in packages/conversation/src/rest/v1/contact/contact-api.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

This line has a length of 121. Maximum allowed is 120
const basePathUrl = `${this.client.apiClientOptions.basePath}/v1/projects/${this.client.apiClientOptions.projectId}/contacts/${data['contact_id']}`;

const requestOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ import { ApiListPromise } from '@sinch/sdk-client';
export class ConversationApiFixture implements Partial<Readonly<ConversationApi>> {

/**
* Fixture associated to function createConversation
* Fixture associated to function create
*/
public createConversation: jest.Mock<Promise<Conversation>, [CreateConversationRequestData]> = jest.fn();
public create: jest.Mock<Promise<Conversation>, [CreateConversationRequestData]> = jest.fn();
/**
* Fixture associated to function deleteConversation
* Fixture associated to function delete
*/
public deleteConversation: jest.Mock<Promise<any>, [DeleteConversationRequestData]> = jest.fn();
public delete: jest.Mock<Promise<any>, [DeleteConversationRequestData]> = jest.fn();
/**
* Fixture associated to function getConversation
* Fixture associated to function get
*/
public getConversation: jest.Mock<Promise<Conversation>, [GetConversationRequestData]> = jest.fn();
public get: jest.Mock<Promise<Conversation>, [GetConversationRequestData]> = jest.fn();
/**
* Fixture associated to function injectMessage
*/
public injectMessage: jest.Mock<Promise<any>, [InjectMessageRequestData]> = jest.fn();
/**
* Fixture associated to function listConversations
* Fixture associated to function list
*/
public listConversations: jest.Mock<ApiListPromise<Conversation>, [ListConversationsRequestData]> = jest.fn();
public list: jest.Mock<ApiListPromise<Conversation>, [ListConversationsRequestData]> = jest.fn();
/**
* Fixture associated to function stopActiveConversation
* Fixture associated to function stopActive
*/
public stopActiveConversation: jest.Mock<Promise<any>, [StopActiveConversationRequestData]> = jest.fn();
public stopActive: jest.Mock<Promise<any>, [StopActiveConversationRequestData]> = jest.fn();
/**
* Fixture associated to function updateConversation
* Fixture associated to function update
*/
public updateConversation: jest.Mock<Promise<Conversation>, [UpdateConversationRequestData]> = jest.fn();
public update: jest.Mock<Promise<Conversation>, [UpdateConversationRequestData]> = jest.fn();
}

Loading

0 comments on commit ddb3a4a

Please sign in to comment.