diff --git a/.changeset/silver-deers-double.md b/.changeset/silver-deers-double.md index 9fab7fe..7f2194f 100644 --- a/.changeset/silver-deers-double.md +++ b/.changeset/silver-deers-double.md @@ -2,4 +2,32 @@ "@great-detail/whatsapp": major --- -Rewrite SDK +Refactor & Rewrite SDK. + +**Before**: + +```ts +import CloudAPI from "@great-detail/whatsapp"; + +const sdk = new CloudAPI(); +const message = sdk + .message({ phoneNumberID: "123...809" }) + .text({ body: "Hello" }, { toNumber: "1234567890" }); +const sendReceipt = await message.send(); +``` + +**After**: + +```ts +import Client from "@great-detail/whatsapp"; + +const sdk = new Client(); +const message = await sdk.message.createMessage({ + phoneNumberID: "123...809", + to: "1234567890", + type: "text", + text: { + body: "Hello", + }, +}); +``` diff --git a/README.md b/README.md index 95bad39..511466d 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,21 @@ Originally a fork of the ## Getting started -```typescript -// ESM +**ESM Import**: +```ts import Client from "@great-detail/whatsapp"; +``` + +**CJS Import**: -// CJS +```ts const CloudAPI = require("@great-detail/whatsapp").default; +``` + +**Usage**: +```typescript const sdk = new Client(); const message = await sdk.message.createMessage({ phoneNumberID: "123...809",