vayu-ts 0.2.8 → 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
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,6 +180,21 @@ console.log(response.hasMore);
|
|
|
170
180
|
console.log(response.nextCursor);
|
|
171
181
|
```
|
|
172
182
|
|
|
183
|
+
### Webhooks
|
|
184
|
+
|
|
185
|
+
#### Subscribing to Events
|
|
186
|
+
|
|
187
|
+
You can subscribe to various events using webhooks. Here are the available subscription methods:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
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
|
+
|
|
196
|
+
```
|
|
197
|
+
|
|
173
198
|
## Features
|
|
174
199
|
|
|
175
200
|
The Vayu API client library provides access to the following features:
|
|
@@ -189,6 +214,7 @@ The Vayu API client library provides access to the following features:
|
|
|
189
214
|
- `customers.list()`
|
|
190
215
|
- `customers.get()`
|
|
191
216
|
- `customers.getByExternalId()`
|
|
217
|
+
- `customers.getProductConsumptions()`
|
|
192
218
|
- **Meters**
|
|
193
219
|
- `meters.get()`
|
|
194
220
|
- `meters.update()`
|
|
@@ -206,6 +232,11 @@ The Vayu API client library provides access to the following features:
|
|
|
206
232
|
- **Invoices**
|
|
207
233
|
- `invoices.get()`
|
|
208
234
|
- `invoices.list()`
|
|
235
|
+
- **Webhooks**
|
|
236
|
+
- `webhooks.subscribeToOverage()`
|
|
237
|
+
- `webhooks.subscribeToAnonymousCustomerCreated()`
|
|
238
|
+
- **Product Consumption**
|
|
239
|
+
- `productConsumption.get()`
|
|
209
240
|
|
|
210
241
|
## Support
|
|
211
242
|
|
|
@@ -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
|
}
|