Skip to content

Commit 2c2c6af

Browse files
authored
Merge pull request #115 from Space-DF/feat/implement-notification-sdk
feat: implement notification sdk
2 parents 55bf8ef + 0a54e57 commit 2c2c6af

3 files changed

Lines changed: 56 additions & 1 deletion

File tree

api.doc.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3652,7 +3652,7 @@ await client.trip.delete('trip-uuid-456');
36523652
36533653
## Overview
36543654
3655-
The `Telemetry` class provides methods for retrieving telemetry entities, alerts, events, automations, actions, and geofences. This class allows you to search and filter telemetry entities by display type and search terms, retrieve alerts, query events by device, list telemetry actions, manage automations (list, create, retrieve, update, delete), and manage geofences (list, create, retrieve, update, delete, test).
3655+
The `Telemetry` class provides methods for retrieving telemetry entities, alerts, events, automations, actions, notifications, and geofences. This class allows you to search and filter telemetry entities by display type and search terms, retrieve alerts, query events by device, list telemetry actions, manage notification subscriptions, manage automations (list, create, retrieve, update, delete), and manage geofences (list, create, retrieve, update, delete, test).
36563656
36573657
## Methods
36583658
@@ -4006,6 +4006,39 @@ console.log(actions.results);
40064006

40074007
</details>
40084008

4009+
<details>
4010+
<summary><strong>notifications.subscribe</strong></summary>
4011+
4012+
Subscribe a push notification endpoint for telemetry notifications.
4013+
4014+
**Signature:**
4015+
4016+
```typescript
4017+
subscribe(params: NotificationsSubscribeParams, options?: Core.RequestOptions): Core.APIPromise<unknown>
4018+
```
4019+
4020+
**Parameters:**
4021+
4022+
- `params` _(NotificationsSubscribeParams)_: Subscription payload:
4023+
- `auth` _(string)_: Push subscription auth secret.
4024+
- `endpoint` _(string)_: Push service endpoint URL.
4025+
- `p256dh` _(string)_: Push subscription \(p256dh\) public key.
4026+
- `options` _(Core.RequestOptions)_: Additional request options.
4027+
4028+
**Returns:** `Promise<unknown>`
4029+
4030+
**Example:**
4031+
4032+
```typescript
4033+
await client.telemetry.notifications.subscribe({
4034+
auth: 'string1',
4035+
endpoint: 'string3',
4036+
p256dh: 'string5',
4037+
});
4038+
```
4039+
4040+
</details>
4041+
40094042
<details>
40104043
<summary><strong>automations.summary</strong></summary>
40114044

src/resources/telemetry/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Geofences } from './geofences';
55
import { Automations } from './automations';
66
import { Events } from './events';
77
import { Actions } from './actions';
8+
import { Notifications } from './notifications';
89

910
export class Telemetry extends APIResource {
1011
entities: Entities = new Entities(this._client);
@@ -13,4 +14,5 @@ export class Telemetry extends APIResource {
1314
automations: Automations = new Automations(this._client);
1415
events: Events = new Events(this._client);
1516
actions: Actions = new Actions(this._client);
17+
notifications: Notifications = new Notifications(this._client);
1618
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { APIResource } from '../../resource';
2+
import * as Core from '../../core';
3+
4+
export interface NotificationsSubscribeParams {
5+
auth: string;
6+
endpoint: string;
7+
p256dh: string;
8+
}
9+
10+
export type NotificationsSubscribeResponse = unknown;
11+
12+
export class Notifications extends APIResource {
13+
subscribe(params: NotificationsSubscribeParams, options?: Core.RequestOptions): Core.APIPromise<NotificationsSubscribeResponse> {
14+
const { ...body } = params;
15+
return this._client.post(`/telemetry/v1/notifications/subscribe`, {
16+
body,
17+
...options,
18+
});
19+
}
20+
}

0 commit comments

Comments
 (0)