@rkitwork/whatsapp-ramukjar-cloud-sdk 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/helpers.d.ts CHANGED
@@ -1,39 +1,35 @@
1
+ import { TextMessage } from './payloads';
1
2
  export declare const WhatsApp: {
2
- text: (body: string) => {
3
- type: string;
4
- text: {
5
- body: string;
6
- };
7
- };
8
- image: (link: string, caption?: string) => {
9
- type: string;
3
+ text(body: string): TextMessage;
4
+ image(link: string, caption?: string): {
5
+ type: "image";
10
6
  image: {
11
7
  link: string;
12
8
  caption: string | undefined;
13
9
  };
14
10
  };
15
- video: (link: string, caption?: string) => {
16
- type: string;
11
+ video(link: string, caption?: string): {
12
+ type: "video";
17
13
  video: {
18
14
  link: string;
19
15
  caption: string | undefined;
20
16
  };
21
17
  };
22
- audio: (link: string) => {
23
- type: string;
18
+ audio(link: string): {
19
+ type: "audio";
24
20
  audio: {
25
21
  link: string;
26
22
  };
27
23
  };
28
- document: (link: string, filename?: string) => {
29
- type: string;
24
+ document(link: string, filename?: string): {
25
+ type: "document";
30
26
  document: {
31
27
  link: string;
32
28
  filename: string | undefined;
33
29
  };
34
30
  };
35
- location: (lat: number, lng: number, name?: string) => {
36
- type: string;
31
+ location(lat: number, lng: number, name?: string): {
32
+ type: "location";
37
33
  location: {
38
34
  latitude: number;
39
35
  longitude: number;
package/dist/helpers.js CHANGED
@@ -2,13 +2,40 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WhatsApp = void 0;
4
4
  exports.WhatsApp = {
5
- text: (body) => ({ type: 'text', text: { body } }),
6
- image: (link, caption) => ({ type: 'image', image: { link, caption } }),
7
- video: (link, caption) => ({ type: 'video', video: { link, caption } }),
8
- audio: (link) => ({ type: 'audio', audio: { link } }),
9
- document: (link, filename) => ({ type: 'document', document: { link, filename } }),
10
- location: (lat, lng, name) => ({
11
- type: 'location',
12
- location: { latitude: lat, longitude: lng, name }
13
- })
5
+ text(body) {
6
+ return {
7
+ type: 'text',
8
+ text: { body },
9
+ };
10
+ },
11
+ image(link, caption) {
12
+ return {
13
+ type: 'image',
14
+ image: { link, caption },
15
+ };
16
+ },
17
+ video(link, caption) {
18
+ return {
19
+ type: 'video',
20
+ video: { link, caption },
21
+ };
22
+ },
23
+ audio(link) {
24
+ return {
25
+ type: 'audio',
26
+ audio: { link },
27
+ };
28
+ },
29
+ document(link, filename) {
30
+ return {
31
+ type: 'document',
32
+ document: { link, filename },
33
+ };
34
+ },
35
+ location(lat, lng, name) {
36
+ return {
37
+ type: 'location',
38
+ location: { latitude: lat, longitude: lng, name },
39
+ };
40
+ },
14
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rkitwork/whatsapp-ramukjar-cloud-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A secure WhatsApp Cloud API SDK for NestJS and Express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/helpers.ts CHANGED
@@ -1,11 +1,45 @@
1
+ import { TextMessage } from './payloads';
2
+
1
3
  export const WhatsApp = {
2
- text: (body: string) => ({ type: 'text', text: { body } }),
3
- image: (link: string, caption?: string) => ({ type: 'image', image: { link, caption } }),
4
- video: (link: string, caption?: string) => ({ type: 'video', video: { link, caption } }),
5
- audio: (link: string) => ({ type: 'audio', audio: { link } }),
6
- document: (link: string, filename?: string) => ({ type: 'document', document: { link, filename } }),
7
- location: (lat: number, lng: number, name?: string) => ({
8
- type: 'location',
9
- location: { latitude: lat, longitude: lng, name }
10
- })
4
+ text(body: string): TextMessage {
5
+ return {
6
+ type: 'text',
7
+ text: { body },
8
+ };
9
+ },
10
+
11
+ image(link: string, caption?: string) {
12
+ return {
13
+ type: 'image' as const,
14
+ image: { link, caption },
15
+ };
16
+ },
17
+
18
+ video(link: string, caption?: string) {
19
+ return {
20
+ type: 'video' as const,
21
+ video: { link, caption },
22
+ };
23
+ },
24
+
25
+ audio(link: string) {
26
+ return {
27
+ type: 'audio' as const,
28
+ audio: { link },
29
+ };
30
+ },
31
+
32
+ document(link: string, filename?: string) {
33
+ return {
34
+ type: 'document' as const,
35
+ document: { link, filename },
36
+ };
37
+ },
38
+
39
+ location(lat: number, lng: number, name?: string) {
40
+ return {
41
+ type: 'location' as const,
42
+ location: { latitude: lat, longitude: lng, name },
43
+ };
44
+ },
11
45
  };