Skip to content

Commit

Permalink
fix: bifurcate product and product list message into more smaller com…
Browse files Browse the repository at this point in the history
…ponents and add documentation for the same

Signed-off-by: sarthakjdev <[email protected]>
  • Loading branch information
sarthakjdev committed Jun 5, 2024
1 parent 925bf90 commit 122ade9
Show file tree
Hide file tree
Showing 15 changed files with 440 additions and 323 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,42 @@ const buttonMessage = new ButtonInteractionMessage({
Product message is a message component that you can use to send a product to a user. You can create a product message using the following code:

```typescript

import { ProductMessage } from '@wapijs/wapi.js'
const productMessage = new ProductMessage({
bodyText: 'Hii, I am a product.',
buttonText: 'Buy',
catalogId: '123',
productRetailerId: '123',
footerText: 'Beta version',
})
```

### Product List Message

Product List message is a message component that you can use to send a list of products to a user. You can create a product list message using the following code:

```typescript
import { ProductListMessage, ProductListSection, Product, HeaderTypeEnum } from '@wapijs/wapi.js'
const productListMessage = new ProductListMessage({
bodyText: 'Welcome to Wapi.js',
buttonText: 'Buy',
footerText: 'Beta version',
catalogId: '123',
productRetailerId: '123',
header: {
text: 'Products',
type: HeaderTypeEnum.Text
},
sections: [
new ProductListSection([new Product('123')], 'Section 1'),
]
})

const section = new ProductListSection([], 'Section 2')

section.addProduct(new Product('123'))

productListMessage.addSection(section)
```

### Temaplate Message
Expand Down
Empty file.
6 changes: 3 additions & 3 deletions apps/js.wapikit.com/guide/wapijs-sdk-scope.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ title: Scope of Wapi.js SDK
## Upcoming Features

- Support for WhatsApp Business Account Management API
- Support for Interactive Address Message
- Support for Business Management API
- Support for [Interactive Address Message](https://developers.facebook.com/docs/whatsapp/cloud-api/messages/address-messages)
- Support for WhatsApp Paymnent API
- Support for WhatsApp Order Mangement
- Support for WhatsApp Order Mangement
- Support for [Interactive Location Message](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-messages/location-request-messages)
3 changes: 1 addition & 2 deletions apps/js.wapikit.com/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
"group": "Installation and Preparations",
"pages": [
"guide/installation-and-preparations/setup-node",
"guide/installation-and-preparations/creating-application",
"guide/installation-and-preparations/using-typescript"
"guide/installation-and-preparations/creating-application"
]
},
{
Expand Down
5 changes: 2 additions & 3 deletions packages/example-chat-bot/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { whatsappClient } from './utils/client'
import { ButtonInteractionMessage, ListInteractionMessage, TextMessage } from '@wapijs/wapi.js'
import { ButtonInteractionMessage, ListInteractionMessage, Product, ProductListMessage, ProductListSection, ProductMessage, TextMessage } from '@wapijs/wapi.js'
import { HeaderTypeEnum } from '@wapijs/wapi.js/dist/cjs/src/structures/interaction/schema'

function init() {
whatsappClient.on('Ready', () => {
Expand Down Expand Up @@ -97,8 +98,6 @@ function init() {
}
})



whatsappClient.on('ListInteraction', async message => {
console.log('List Interaction', message)

Expand Down
17 changes: 17 additions & 0 deletions packages/wapi.js/src/structures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@ export * from "./text/interface";
export * from "./interaction/index";
export * from "./interaction/interface";

export * from "./product/index";
export * from "./product/interface";

export * from "./multi-product/index";
export * from "./multi-product/interface";

export * from "./location/index";
export * from "./location/interface";

export * from "./contact/index";
export * from "./contact/interface";

export * from "./media/index";
export * from "./media/interface";

export * from "./reaction/index";
export * from "./reaction/interface";

export * from "./reaction/index";
export * from "./reaction/interface";

export * from "./reaction/index";
export * from "./reaction/interface";

export * from "./template/index";
export * from "./template/interface";
Loading

0 comments on commit 122ade9

Please sign in to comment.