vayu-ts 0.2.9 → 0.2.10
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 +27 -5
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/sdk/clients/WebhooksClient.d.ts +3 -2
- package/dist/sdk/clients/WebhooksClient.js +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -133,6 +133,16 @@ const response = await vayu.customers.delete('customer-id');
|
|
|
133
133
|
console.log(response.customer);
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
+
#### Getting Product Consumptions
|
|
137
|
+
|
|
138
|
+
To get product consumptions for a customer:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
const response = await vayu.customers.getProductConsumptions('customer-id');
|
|
142
|
+
|
|
143
|
+
console.log(response.productConsumptions);
|
|
144
|
+
```
|
|
145
|
+
|
|
136
146
|
### Contracts
|
|
137
147
|
|
|
138
148
|
#### Assigning a contract to a customer
|
|
@@ -170,13 +180,19 @@ console.log(response.hasMore);
|
|
|
170
180
|
console.log(response.nextCursor);
|
|
171
181
|
```
|
|
172
182
|
|
|
173
|
-
|
|
183
|
+
### Webhooks
|
|
184
|
+
|
|
185
|
+
#### Subscribing to Events
|
|
186
|
+
|
|
187
|
+
You can subscribe to various events using webhooks. Here are the available subscription methods:
|
|
174
188
|
|
|
175
189
|
```typescript
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
190
|
+
// Subscribe to overage notifications
|
|
191
|
+
await vayu.webhooks.subscribeToOverage('https://your-webhook-url.com/overage');
|
|
192
|
+
|
|
193
|
+
// Subscribe to anonymous customer creation notifications
|
|
194
|
+
await vayu.webhooks.subscribeToAnonymousCustomerCreated('https://your-webhook-url.com/your_path');
|
|
195
|
+
|
|
180
196
|
```
|
|
181
197
|
|
|
182
198
|
## Features
|
|
@@ -198,6 +214,7 @@ The Vayu API client library provides access to the following features:
|
|
|
198
214
|
- `customers.list()`
|
|
199
215
|
- `customers.get()`
|
|
200
216
|
- `customers.getByExternalId()`
|
|
217
|
+
- `customers.getProductConsumptions()`
|
|
201
218
|
- **Meters**
|
|
202
219
|
- `meters.get()`
|
|
203
220
|
- `meters.update()`
|
|
@@ -215,6 +232,11 @@ The Vayu API client library provides access to the following features:
|
|
|
215
232
|
- **Invoices**
|
|
216
233
|
- `invoices.get()`
|
|
217
234
|
- `invoices.list()`
|
|
235
|
+
- **Webhooks**
|
|
236
|
+
- `webhooks.subscribeToOverage()`
|
|
237
|
+
- `webhooks.subscribeToAnonymousCustomerCreated()`
|
|
238
|
+
- **Product Consumption**
|
|
239
|
+
- `productConsumption.get()`
|
|
218
240
|
|
|
219
241
|
## Support
|
|
220
242
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { WebhookSubscribeRequest } from '../../openapi';
|
|
2
1
|
export declare class WebhooksClient {
|
|
3
2
|
private client;
|
|
4
3
|
constructor();
|
|
5
|
-
|
|
4
|
+
subscribeToOverage(callbackUrl: string): Promise<void>;
|
|
5
|
+
subscribeToAnonymousCustomerCreated(callbackUrl: string): Promise<void>;
|
|
6
|
+
private subscribe;
|
|
6
7
|
}
|
|
@@ -7,6 +7,18 @@ class WebhooksClient {
|
|
|
7
7
|
constructor() {
|
|
8
8
|
this.client = services_1.ConfigurationService.instance.generateNewClient(openapi_1.WebhooksApi);
|
|
9
9
|
}
|
|
10
|
+
subscribeToOverage(callbackUrl) {
|
|
11
|
+
return this.subscribe({
|
|
12
|
+
callbackUrl,
|
|
13
|
+
eventType: openapi_1.NotificationEventType.Overage,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
subscribeToAnonymousCustomerCreated(callbackUrl) {
|
|
17
|
+
return this.subscribe({
|
|
18
|
+
callbackUrl,
|
|
19
|
+
eventType: openapi_1.NotificationEventType.AnonymousCustomer,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
10
22
|
async subscribe(payload) {
|
|
11
23
|
return this.client.webhookSubscribe(payload);
|
|
12
24
|
}
|