@ariary/notification 2.0.1 → 2.0.2

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.
@@ -0,0 +1,31 @@
1
+ type Message = {
2
+ phone: string[] | string;
3
+ message: string;
4
+ };
5
+ type GetTaskParam = {
6
+ from: number;
7
+ count: number;
8
+ order: -1 | 1;
9
+ };
10
+
11
+ declare class Task {
12
+ id: string;
13
+ notifTaskId: string;
14
+ constructor(id: string, notifTaskId: string);
15
+ status(): Promise<unknown>;
16
+ detailedStatus(): Promise<unknown>;
17
+ }
18
+ declare class Notification {
19
+ send(...data: Message[]): Promise<Task>;
20
+ sendMessage(data: Message): Promise<Task>;
21
+ getMessages(param: GetTaskParam): Promise<unknown>;
22
+ }
23
+ declare class Ariari {
24
+ private static notification;
25
+ static config(config: any): void;
26
+ static sendMessage(data: Message): Promise<Task>;
27
+ static send(...data: Message[]): Promise<Task>;
28
+ static getMessages(param: GetTaskParam): Promise<unknown>;
29
+ }
30
+
31
+ export { Ariari, type GetTaskParam, type Message, Notification, Task };
@@ -0,0 +1,31 @@
1
+ type Message = {
2
+ phone: string[] | string;
3
+ message: string;
4
+ };
5
+ type GetTaskParam = {
6
+ from: number;
7
+ count: number;
8
+ order: -1 | 1;
9
+ };
10
+
11
+ declare class Task {
12
+ id: string;
13
+ notifTaskId: string;
14
+ constructor(id: string, notifTaskId: string);
15
+ status(): Promise<unknown>;
16
+ detailedStatus(): Promise<unknown>;
17
+ }
18
+ declare class Notification {
19
+ send(...data: Message[]): Promise<Task>;
20
+ sendMessage(data: Message): Promise<Task>;
21
+ getMessages(param: GetTaskParam): Promise<unknown>;
22
+ }
23
+ declare class Ariari {
24
+ private static notification;
25
+ static config(config: any): void;
26
+ static sendMessage(data: Message): Promise<Task>;
27
+ static send(...data: Message[]): Promise<Task>;
28
+ static getMessages(param: GetTaskParam): Promise<unknown>;
29
+ }
30
+
31
+ export { Ariari, type GetTaskParam, type Message, Notification, Task };
package/dist/index.js CHANGED
@@ -88,14 +88,15 @@ function normalizePhoneNumber(phone) {
88
88
  return normalized;
89
89
  }
90
90
  var Task = class {
91
- constructor(id) {
91
+ constructor(id, notifTaskId) {
92
92
  this.id = id;
93
+ this.notifTaskId = notifTaskId;
93
94
  }
94
95
  async status() {
95
- return httpGet(`/api/notif-task/${this.id}/sms-details`);
96
+ return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
96
97
  }
97
98
  async detailedStatus() {
98
- return httpGet(`/api/notif-task/${this.id}/sms-details`);
99
+ return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
99
100
  }
100
101
  };
101
102
  var Notification = class {
@@ -108,7 +109,10 @@ var Notification = class {
108
109
  if (!response.data || !Array.isArray(response.data) || response.data.length === 0) {
109
110
  throw new Error("Invalid response: no SMS IDs returned");
110
111
  }
111
- return new Task(response.data[0]);
112
+ if (!response.notifTaskId) {
113
+ throw new Error("Invalid response: no notifTaskId returned");
114
+ }
115
+ return new Task(response.data[0], response.notifTaskId);
112
116
  }
113
117
  async sendMessage(data) {
114
118
  return this.send(data);
package/dist/index.mjs CHANGED
@@ -60,14 +60,15 @@ function normalizePhoneNumber(phone) {
60
60
  return normalized;
61
61
  }
62
62
  var Task = class {
63
- constructor(id) {
63
+ constructor(id, notifTaskId) {
64
64
  this.id = id;
65
+ this.notifTaskId = notifTaskId;
65
66
  }
66
67
  async status() {
67
- return httpGet(`/api/notif-task/${this.id}/sms-details`);
68
+ return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
68
69
  }
69
70
  async detailedStatus() {
70
- return httpGet(`/api/notif-task/${this.id}/sms-details`);
71
+ return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
71
72
  }
72
73
  };
73
74
  var Notification = class {
@@ -80,7 +81,10 @@ var Notification = class {
80
81
  if (!response.data || !Array.isArray(response.data) || response.data.length === 0) {
81
82
  throw new Error("Invalid response: no SMS IDs returned");
82
83
  }
83
- return new Task(response.data[0]);
84
+ if (!response.notifTaskId) {
85
+ throw new Error("Invalid response: no notifTaskId returned");
86
+ }
87
+ return new Task(response.data[0], response.notifTaskId);
84
88
  }
85
89
  async sendMessage(data) {
86
90
  return this.send(data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariary/notification",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "SMS et Notification Task SDK pour l'API Ariary",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",