Skip to content

Commit

Permalink
feat(api-client): implement v7 changes in the conversation api
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Gira committed Dec 3, 2024
1 parent 0802b54 commit 009e706
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class ConversationAPI {
public static readonly MAX_CHUNK_SIZE = 500;
public static readonly URL = {
ACCESS: 'access',
BOT: 'bot',
BOTS: 'bots',
CLIENTS: '/clients',
CODE: 'code',
Expand Down Expand Up @@ -151,7 +152,10 @@ export class ConversationAPI {
public async deleteService(conversationId: string, serviceId: string): Promise<void> {
const config: AxiosRequestConfig = {
method: 'delete',
url: `${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.BOTS}/${serviceId}`,
url:
this.backendFeatures.version >= 7
? `${ConversationAPI.URL.BOT}/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${serviceId}`
: `${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.BOTS}/${serviceId}`,
};

await this.client.sendJSON(config);
Expand Down Expand Up @@ -411,7 +415,10 @@ export class ConversationAPI {
const config: AxiosRequestConfig = {
data: conversationData,
method: 'post',
url: `${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.ONE_2_ONE}`,
url:
this.backendFeatures.version >= 7
? `${ConversationAPI.URL.ONE_2_ONE}-${ConversationAPI.URL.CONVERSATIONS}`
: `${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.ONE_2_ONE}`,
};

await this.client.sendJSON(config);
Expand All @@ -424,7 +431,10 @@ export class ConversationAPI {
public async getMLS1to1Conversation({domain, id}: QualifiedId): Promise<MLS1to1Conversation | MLSConversation> {
const config: AxiosRequestConfig = {
method: 'get',
url: `${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.ONE_2_ONE}/${domain}/${id}`,
url:
this.backendFeatures.version >= 7
? `${ConversationAPI.URL.ONE_2_ONE}-${ConversationAPI.URL.CONVERSATIONS}/${domain}/${id}`
: `${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.ONE_2_ONE}/${domain}/${id}`,
};

const response = await this.client.sendJSON<MLS1to1Conversation | MLSConversation>(config);
Expand Down Expand Up @@ -482,7 +492,10 @@ export class ConversationAPI {
service: serviceId,
},
method: 'post',
url: `${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.BOTS}`,
url:
this.backendFeatures.version >= 7
? `${ConversationAPI.URL.BOT}/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}`
: `${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.BOTS}}`,
};

const response = await this.client.sendJSON<ConversationMemberJoinEvent>(config);
Expand Down

0 comments on commit 009e706

Please sign in to comment.