@ariary/ariary 3.0.2 → 3.0.3

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/README.md CHANGED
@@ -13,19 +13,23 @@ npm install @ariary/ariary
13
13
  ```typescript
14
14
  import { Ariari } from '@ariary/ariary';
15
15
 
16
- const ariari = new Ariari();
17
- ariari.config({
16
+ Ariari.config({
18
17
  projectId: 'your-project-id',
19
18
  secretId: 'your-secret-id'
20
19
  });
21
20
  ```
22
21
 
22
+
23
+ ```typescript
24
+ import { Ariari, Task, Payment } from '@ariary/ariary';
25
+ ```
26
+
23
27
  ## Notification
24
28
 
25
29
  ### Send Notification
26
30
 
27
31
  ```typescript
28
- const task = await ariari.send(
32
+ const task = await Ariari.send(
29
33
  { phone: '+261123456789', message: 'Message 1' },
30
34
  { phone: ['+261987654321', '+261555555555'], message: 'Message 2' }
31
35
  );
@@ -43,22 +47,22 @@ const details = await task.smsDetails();
43
47
  ### List Tasks
44
48
 
45
49
  ```typescript
46
- const result = await ariari.tasks({
50
+ const result = await Ariari.tasks({
47
51
  from: 0,
48
52
  count: 20,
49
53
  order: -1
50
54
  });
51
55
 
52
- const nextResult = await ariari.tasks(result.next);
56
+ const nextResult = await Ariari.tasks(result.next);
53
57
  ...
54
- const prevResult = await ariari.tasks(result.prev);
58
+ const prevResult = await Ariari.tasks(result.prev);
55
59
  ```
56
60
 
57
61
  ## Payment
58
62
 
59
63
 
60
64
  ```typescript
61
- const payment = await ariari.payment.create({
65
+ const payment = await Ariari.payment.create({
62
66
  code: 'PAY-123',
63
67
  amount: 5000,
64
68
  projectId: 'your-project-id'
@@ -74,21 +78,21 @@ await payment.updateRest('TICKET123');
74
78
  ### Get All Payments
75
79
 
76
80
  ```typescript
77
- const payments = await ariari.payment.getAll();
81
+ const payments = await Ariari.payment.getAll();
78
82
  ```
79
83
 
80
84
  ### Get Payment by ID
81
85
 
82
86
  ```typescript
83
- const payment = ariari.payment.getById('payment-id-123');
87
+ const payment = Ariari.payment.getById('payment-id-123');
84
88
  await payment.get();
85
89
  await payment.updateRest('TICKET123');
86
90
  ```
87
91
  ```typescript
88
- const payment = await ariari.payment({
92
+ const payment = await Ariari.payment.payment({
89
93
  phone: '261345678901',
90
94
  amount: 5000
91
95
  });
92
96
 
93
- const payments = await ariari.payment.getPayments();
97
+ const payments = await Ariari.payment.getPayments();
94
98
  ```
package/dist/index.d.mts CHANGED
@@ -59,19 +59,19 @@ declare class Payment {
59
59
  updateRest: (ticketCode: string) => Promise<unknown>;
60
60
  }
61
61
  declare class Ariari {
62
- config(cfg: {
62
+ static config(cfg: {
63
63
  projectId: string;
64
64
  secretId: string;
65
65
  }): void;
66
- send(...data: Message[]): Promise<Task>;
67
- tasks(param: GetTaskParam): Promise<TaskDetails[]>;
68
- createPayment(data: {
66
+ static send(...data: Message[]): Promise<Task>;
67
+ static tasks(param: GetTaskParam): Promise<TaskDetails[]>;
68
+ static createPayment(data: {
69
69
  code: string;
70
70
  amount: number;
71
71
  projectId: string;
72
72
  }): Promise<Payment>;
73
- getAllPayments: () => Promise<PaymentResponse[]>;
74
- payment: {
73
+ static getAllPayments: () => Promise<PaymentResponse[]>;
74
+ static payment: {
75
75
  create: (data: {
76
76
  code: string;
77
77
  amount: number;
@@ -85,10 +85,8 @@ declare class Ariari {
85
85
  }) => Promise<any>;
86
86
  getPayments: () => Promise<any>;
87
87
  };
88
- Task: typeof Task;
89
- Payment: typeof Payment;
88
+ static Task: typeof Task;
89
+ static Payment: typeof Payment;
90
90
  }
91
91
 
92
- declare const ariari: Ariari;
93
-
94
- export { Ariari, type Config, type CreatePaymentParam, type GetTaskParam, type Message, Payment, type PaymentParam, type PaymentResponse, Task, type TaskDetails, type TaskSummary, ariari as default };
92
+ export { Ariari, type Config, type CreatePaymentParam, type GetTaskParam, type Message, Payment, type PaymentParam, type PaymentResponse, Task, type TaskDetails, type TaskSummary };
package/dist/index.d.ts CHANGED
@@ -59,19 +59,19 @@ declare class Payment {
59
59
  updateRest: (ticketCode: string) => Promise<unknown>;
60
60
  }
61
61
  declare class Ariari {
62
- config(cfg: {
62
+ static config(cfg: {
63
63
  projectId: string;
64
64
  secretId: string;
65
65
  }): void;
66
- send(...data: Message[]): Promise<Task>;
67
- tasks(param: GetTaskParam): Promise<TaskDetails[]>;
68
- createPayment(data: {
66
+ static send(...data: Message[]): Promise<Task>;
67
+ static tasks(param: GetTaskParam): Promise<TaskDetails[]>;
68
+ static createPayment(data: {
69
69
  code: string;
70
70
  amount: number;
71
71
  projectId: string;
72
72
  }): Promise<Payment>;
73
- getAllPayments: () => Promise<PaymentResponse[]>;
74
- payment: {
73
+ static getAllPayments: () => Promise<PaymentResponse[]>;
74
+ static payment: {
75
75
  create: (data: {
76
76
  code: string;
77
77
  amount: number;
@@ -85,10 +85,8 @@ declare class Ariari {
85
85
  }) => Promise<any>;
86
86
  getPayments: () => Promise<any>;
87
87
  };
88
- Task: typeof Task;
89
- Payment: typeof Payment;
88
+ static Task: typeof Task;
89
+ static Payment: typeof Payment;
90
90
  }
91
91
 
92
- declare const ariari: Ariari;
93
-
94
- export { Ariari, type Config, type CreatePaymentParam, type GetTaskParam, type Message, Payment, type PaymentParam, type PaymentResponse, Task, type TaskDetails, type TaskSummary, ariari as default };
92
+ export { Ariari, type Config, type CreatePaymentParam, type GetTaskParam, type Message, Payment, type PaymentParam, type PaymentResponse, Task, type TaskDetails, type TaskSummary };
package/dist/index.js CHANGED
@@ -22,8 +22,7 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  Ariari: () => Ariari,
24
24
  Payment: () => Payment,
25
- Task: () => Task,
26
- default: () => ariari
25
+ Task: () => Task
27
26
  });
28
27
  module.exports = __toCommonJS(src_exports);
29
28
 
@@ -110,23 +109,11 @@ var Payment = class {
110
109
  this.id = id;
111
110
  }
112
111
  };
113
- var Ariari = class {
114
- constructor() {
115
- this.getAllPayments = () => httpGet("/api/payments");
116
- this.payment = {
117
- create: (data) => this.createPayment(data),
118
- getAll: () => this.getAllPayments(),
119
- getById: (id) => new Payment(id),
120
- payment: (data) => httpPost("/api/send-transaction", data),
121
- getPayments: () => httpGet("/api/send-transaction")
122
- };
123
- this.Task = Task;
124
- this.Payment = Payment;
125
- }
126
- config(cfg) {
112
+ var _Ariari = class _Ariari {
113
+ static config(cfg) {
127
114
  setConfig(cfg);
128
115
  }
129
- async send(...data) {
116
+ static async send(...data) {
130
117
  const messages = data.map((item) => ({
131
118
  phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
132
119
  message: item.message
@@ -140,17 +127,25 @@ var Ariari = class {
140
127
  }
141
128
  return new Task(response.notifTaskId);
142
129
  }
143
- async tasks(param) {
130
+ static async tasks(param) {
144
131
  return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
145
132
  }
146
- async createPayment(data) {
133
+ static async createPayment(data) {
147
134
  const res = await httpPost("/api/payments", data);
148
135
  return new Payment(res.id);
149
136
  }
150
137
  };
151
-
152
- // src/index.ts
153
- var ariari = new Ariari();
138
+ _Ariari.getAllPayments = () => httpGet("/api/payments");
139
+ _Ariari.payment = {
140
+ create: (data) => _Ariari.createPayment(data),
141
+ getAll: () => _Ariari.getAllPayments(),
142
+ getById: (id) => new Payment(id),
143
+ payment: (data) => httpPost("/api/send-transaction", data),
144
+ getPayments: () => httpGet("/api/send-transaction")
145
+ };
146
+ _Ariari.Task = Task;
147
+ _Ariari.Payment = Payment;
148
+ var Ariari = _Ariari;
154
149
  // Annotate the CommonJS export names for ESM import in node:
155
150
  0 && (module.exports = {
156
151
  Ariari,
package/dist/index.mjs CHANGED
@@ -81,23 +81,11 @@ var Payment = class {
81
81
  this.id = id;
82
82
  }
83
83
  };
84
- var Ariari = class {
85
- constructor() {
86
- this.getAllPayments = () => httpGet("/api/payments");
87
- this.payment = {
88
- create: (data) => this.createPayment(data),
89
- getAll: () => this.getAllPayments(),
90
- getById: (id) => new Payment(id),
91
- payment: (data) => httpPost("/api/send-transaction", data),
92
- getPayments: () => httpGet("/api/send-transaction")
93
- };
94
- this.Task = Task;
95
- this.Payment = Payment;
96
- }
97
- config(cfg) {
84
+ var _Ariari = class _Ariari {
85
+ static config(cfg) {
98
86
  setConfig(cfg);
99
87
  }
100
- async send(...data) {
88
+ static async send(...data) {
101
89
  const messages = data.map((item) => ({
102
90
  phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
103
91
  message: item.message
@@ -111,20 +99,27 @@ var Ariari = class {
111
99
  }
112
100
  return new Task(response.notifTaskId);
113
101
  }
114
- async tasks(param) {
102
+ static async tasks(param) {
115
103
  return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
116
104
  }
117
- async createPayment(data) {
105
+ static async createPayment(data) {
118
106
  const res = await httpPost("/api/payments", data);
119
107
  return new Payment(res.id);
120
108
  }
121
109
  };
122
-
123
- // src/index.ts
124
- var ariari = new Ariari();
110
+ _Ariari.getAllPayments = () => httpGet("/api/payments");
111
+ _Ariari.payment = {
112
+ create: (data) => _Ariari.createPayment(data),
113
+ getAll: () => _Ariari.getAllPayments(),
114
+ getById: (id) => new Payment(id),
115
+ payment: (data) => httpPost("/api/send-transaction", data),
116
+ getPayments: () => httpGet("/api/send-transaction")
117
+ };
118
+ _Ariari.Task = Task;
119
+ _Ariari.Payment = Payment;
120
+ var Ariari = _Ariari;
125
121
  export {
126
122
  Ariari,
127
123
  Payment,
128
- Task,
129
- ariari as default
124
+ Task
130
125
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariary/ariary",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "SDK officiel pour l'API de paiement Ariary",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",