Skip to content

Commit

Permalink
fix: minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: sarthakjdev <jsarthak448@gmail.com>
  • Loading branch information
sarthakjdev committed May 29, 2024
1 parent b43fd2c commit 4aab334
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 121 deletions.
14 changes: 0 additions & 14 deletions packages/example-chat-bot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,7 @@ function init() {
message: listMessage,
phoneNumber: message.context.from
})


console.log({ response })

} else if (message.text.data.text.toLowerCase() === 'media') {
const response = await message.client.media.upload({
filePath: path.resolve(__dirname, '../src/media.png')
})

console.log({ response })

} else {
await message.reply({
message: new TextMessage({
Expand Down Expand Up @@ -128,10 +118,6 @@ function init() {
})
})

whatsappClient.on('Error', error => {
console.error(error)
})

whatsappClient.initiate()
}

Expand Down
3 changes: 0 additions & 3 deletions packages/wapi.js/src/client/request-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export class RequestClient implements RequestClientInterface {
try {
const requestUrl = this.getRequestUrl();

console.log({ requestUrl, path, body });

const response = await fetch(`${requestUrl}${path}`, {
method: method,
Expand All @@ -82,8 +81,6 @@ export class RequestClient implements RequestClientInterface {

const responseBody = await response.json();

console.log({ responseCode: response.status });

return responseBody as CloudApiRequesterResourceTypeToResponseTypeMap[T];
} catch (error) {
if (error instanceof Error) this.client.emit("Error", error);
Expand Down
3 changes: 1 addition & 2 deletions packages/wapi.js/src/structures/contact/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ export class Contact {
*/
export class ContactMessage
extends BaseMessage<"contacts">
implements ContactMessageInterface
{
implements ContactMessageInterface {
contacts: Contact[];

/**
Expand Down
199 changes: 97 additions & 102 deletions packages/wapi.js/src/structures/interaction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import {
*/
abstract class InteractiveMessage
extends BaseMessage<MessageTypeEnum.Interactive>
implements InteractiveMessageInterface
{
implements InteractiveMessageInterface {
readonly interactiveMessageData: {
type: InteractiveMessageTypeEnum;
footerText?: string;
Expand Down Expand Up @@ -71,8 +70,7 @@ abstract class InteractiveMessage
*/
export class ButtonInteractionMessage
extends InteractiveMessage
implements ButtonInteractionMessageInterface
{
implements ButtonInteractionMessageInterface {
data: {
buttons: { id: string; title: string }[];
};
Expand Down Expand Up @@ -104,7 +102,7 @@ export class ButtonInteractionMessage
/**
* Adds a header to the message.
*/
addHeader() {}
addHeader() { }

/**
* Adds a footer to the message.
Expand Down Expand Up @@ -150,31 +148,31 @@ export class ButtonInteractionMessage
},
...(this.interactiveMessageData.header
? {
header: {
...(this.interactiveMessageData.header.type ===
header: {
...(this.interactiveMessageData.header.type ===
HeaderTypeEnum.Text
? {
type: HeaderTypeEnum.Text,
text: this.interactiveMessageData.header.text,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Document
? {
type: HeaderTypeEnum.Text,
text: this.interactiveMessageData.header.text,
}
type: HeaderTypeEnum.Document,
document: this.interactiveMessageData.header.document,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Document
HeaderTypeEnum.Image
? {
type: HeaderTypeEnum.Document,
document: this.interactiveMessageData.header.document,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Image
? {
type: HeaderTypeEnum.Image,
image: this.interactiveMessageData.header.image,
}
: {
type: HeaderTypeEnum.Video,
video: this.interactiveMessageData.header.video,
}),
},
}
type: HeaderTypeEnum.Image,
image: this.interactiveMessageData.header.image,
}
: {
type: HeaderTypeEnum.Video,
video: this.interactiveMessageData.header.video,
}),
},
}
: {}),
type: InteractiveMessageTypeEnum.Button,
},
Expand All @@ -190,8 +188,7 @@ export class ButtonInteractionMessage
*/
export class ListInteractionMessage
extends InteractiveMessage
implements ListInteractionMessageInterface
{
implements ListInteractionMessageInterface {
data: {
buttonText: string;
sections: z.infer<typeof ListInteractiveMessageSection>[];
Expand Down Expand Up @@ -225,7 +222,7 @@ export class ListInteractionMessage
footerText: params.footerText,
bodyText: params.bodyText,
});
// this.parseConstructorPayload(this._constructorPayloadSchema, params);
this.parseConstructorPayload(this._constructorPayloadSchema, params);
this.data = {
buttonText: params.buttonText,
sections: params.sections,
Expand All @@ -243,7 +240,7 @@ export class ListInteractionMessage
/**
* Adds a header to the message.
*/
addHeader() {}
addHeader() { }

/**
* Adds a footer to the message.
Expand Down Expand Up @@ -285,38 +282,38 @@ export class ListInteractionMessage
},
...(this.interactiveMessageData.header
? {
header: {
...(this.interactiveMessageData.header.type ===
header: {
...(this.interactiveMessageData.header.type ===
HeaderTypeEnum.Text
? {
type: HeaderTypeEnum.Text,
text: this.interactiveMessageData.header.text,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Document
? {
type: HeaderTypeEnum.Text,
text: this.interactiveMessageData.header.text,
}
type: HeaderTypeEnum.Document,
document: this.interactiveMessageData.header.document,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Document
HeaderTypeEnum.Image
? {
type: HeaderTypeEnum.Document,
document: this.interactiveMessageData.header.document,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Image
? {
type: HeaderTypeEnum.Image,
image: this.interactiveMessageData.header.image,
}
: {
type: HeaderTypeEnum.Video,
video: this.interactiveMessageData.header.video,
}),
},
}
type: HeaderTypeEnum.Image,
image: this.interactiveMessageData.header.image,
}
: {
type: HeaderTypeEnum.Video,
video: this.interactiveMessageData.header.video,
}),
},
}
: {}),
...(this.interactiveMessageData.footerText
? {
footer: {
text: this.interactiveMessageData.footerText,
},
}
footer: {
text: this.interactiveMessageData.footerText,
},
}
: {}),
},
};
Expand All @@ -331,8 +328,7 @@ export class ListInteractionMessage
*/
export class ProductInteractionMessage
extends InteractiveMessage
implements ProductInteractionMessageInterface
{
implements ProductInteractionMessageInterface {
data: {
catalogId: string;
productRetailerId: string;
Expand Down Expand Up @@ -370,7 +366,7 @@ export class ProductInteractionMessage
/**
* Adds a header to the message.
*/
addHeader() {}
addHeader() { }

/**
* Adds a footer to the message.
Expand Down Expand Up @@ -412,38 +408,38 @@ export class ProductInteractionMessage
},
...(this.interactiveMessageData.header
? {
header: {
...(this.interactiveMessageData.header.type ===
header: {
...(this.interactiveMessageData.header.type ===
HeaderTypeEnum.Text
? {
type: HeaderTypeEnum.Text,
text: this.interactiveMessageData.header.text,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Document
? {
type: HeaderTypeEnum.Text,
text: this.interactiveMessageData.header.text,
}
type: HeaderTypeEnum.Document,
document: this.interactiveMessageData.header.document,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Document
HeaderTypeEnum.Image
? {
type: HeaderTypeEnum.Document,
document: this.interactiveMessageData.header.document,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Image
? {
type: HeaderTypeEnum.Image,
image: this.interactiveMessageData.header.image,
}
: {
type: HeaderTypeEnum.Video,
video: this.interactiveMessageData.header.video,
}),
},
}
type: HeaderTypeEnum.Image,
image: this.interactiveMessageData.header.image,
}
: {
type: HeaderTypeEnum.Video,
video: this.interactiveMessageData.header.video,
}),
},
}
: {}),
...(this.interactiveMessageData.footerText
? {
footer: {
text: this.interactiveMessageData.footerText,
},
}
footer: {
text: this.interactiveMessageData.footerText,
},
}
: {}),
},
};
Expand All @@ -458,8 +454,7 @@ export class ProductInteractionMessage
*/
export class ProductListInteractionMessage
extends InteractiveMessage
implements ProductListInteractionMessageInterface
{
implements ProductListInteractionMessageInterface {
data: {
catalogId: string;
productRetailerId: string;
Expand Down Expand Up @@ -551,34 +546,34 @@ export class ProductListInteractionMessage
header: {
...(this.interactiveMessageData.header.type === HeaderTypeEnum.Text
? {
type: HeaderTypeEnum.Text,
text: this.interactiveMessageData.header.text,
}
type: HeaderTypeEnum.Text,
text: this.interactiveMessageData.header.text,
}
: this.interactiveMessageData.header.type ===
HeaderTypeEnum.Document
HeaderTypeEnum.Document
? {
type: HeaderTypeEnum.Document,
document: this.interactiveMessageData.header.document,
}
type: HeaderTypeEnum.Document,
document: this.interactiveMessageData.header.document,
}
: this.interactiveMessageData.header.type === HeaderTypeEnum.Image
? {
type: HeaderTypeEnum.Image,
image: this.interactiveMessageData.header.image,
}
type: HeaderTypeEnum.Image,
image: this.interactiveMessageData.header.image,
}
: {
type: HeaderTypeEnum.Video,
video: this.interactiveMessageData.header.video,
}),
type: HeaderTypeEnum.Video,
video: this.interactiveMessageData.header.video,
}),
},
body: {
text: this.interactiveMessageData.bodyText,
},
...(this.interactiveMessageData.footerText
? {
footer: {
text: this.interactiveMessageData.footerText,
},
}
footer: {
text: this.interactiveMessageData.footerText,
},
}
: {}),
},
};
Expand Down

0 comments on commit 4aab334

Please sign in to comment.