@allanfsouza/aether-sdk 2.2.0 → 2.3.0
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/dist/push.js +6 -5
- package/package.json +6 -2
- package/src/push.ts +6 -5
package/dist/push.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { routes } from "@allanfsouza/aether-shared";
|
|
1
2
|
export class PushModule {
|
|
2
3
|
constructor(client, http) {
|
|
3
4
|
this.client = client;
|
|
@@ -5,7 +6,7 @@ export class PushModule {
|
|
|
5
6
|
}
|
|
6
7
|
async registerDevice(params) {
|
|
7
8
|
const projectId = this.client.projectId;
|
|
8
|
-
const { data } = await this.http.post(
|
|
9
|
+
const { data } = await this.http.post(routes.push.devices.build(projectId), {
|
|
9
10
|
platform: params.platform,
|
|
10
11
|
token: params.token,
|
|
11
12
|
environment: params.environment ?? "prod",
|
|
@@ -14,7 +15,7 @@ export class PushModule {
|
|
|
14
15
|
}
|
|
15
16
|
async sendToToken(params) {
|
|
16
17
|
const projectId = this.client.projectId;
|
|
17
|
-
const { data } = await this.http.post(
|
|
18
|
+
const { data } = await this.http.post(routes.push.send.build(projectId), {
|
|
18
19
|
token: params.token,
|
|
19
20
|
title: params.title,
|
|
20
21
|
body: params.body,
|
|
@@ -25,7 +26,7 @@ export class PushModule {
|
|
|
25
26
|
}
|
|
26
27
|
async sendToUser(params) {
|
|
27
28
|
const projectId = this.client.projectId;
|
|
28
|
-
const { data } = await this.http.post(
|
|
29
|
+
const { data } = await this.http.post(routes.push.send.build(projectId), {
|
|
29
30
|
userId: params.userId,
|
|
30
31
|
title: params.title,
|
|
31
32
|
body: params.body,
|
|
@@ -36,7 +37,7 @@ export class PushModule {
|
|
|
36
37
|
}
|
|
37
38
|
async listLogs(options = {}) {
|
|
38
39
|
const projectId = this.client.projectId;
|
|
39
|
-
const { data } = await this.http.get(
|
|
40
|
+
const { data } = await this.http.get(routes.push.logs.build(projectId), {
|
|
40
41
|
params: {
|
|
41
42
|
limit: options.limit,
|
|
42
43
|
offset: options.offset,
|
|
@@ -47,7 +48,7 @@ export class PushModule {
|
|
|
47
48
|
}
|
|
48
49
|
async getStats() {
|
|
49
50
|
const projectId = this.client.projectId;
|
|
50
|
-
const { data } = await this.http.get(
|
|
51
|
+
const { data } = await this.http.get(routes.push.stats.build(projectId));
|
|
51
52
|
return data;
|
|
52
53
|
}
|
|
53
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allanfsouza/aether-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "SDK do Cliente para a Plataforma Aether",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,9 +23,13 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"
|
|
26
|
+
"@allanfsouza/aether-shared": "file:../aether-shared",
|
|
27
|
+
"axios": "^1.6.0",
|
|
28
|
+
"ws": "^8.16.0"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
31
|
+
"@types/node": "^20.0.0",
|
|
32
|
+
"@types/ws": "^8.5.10",
|
|
29
33
|
"typescript": "^5.3.0"
|
|
30
34
|
}
|
|
31
35
|
}
|
package/src/push.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/push.ts
|
|
2
2
|
import type { AxiosInstance } from "axios";
|
|
3
3
|
import type { PlataformaClient } from "./index.js";
|
|
4
|
+
import { routes } from "@allanfsouza/aether-shared";
|
|
4
5
|
|
|
5
6
|
export type PushPlatform = "android" | "ios" | "web";
|
|
6
7
|
export type PushEnvironment = "dev" | "staging" | "prod";
|
|
@@ -69,7 +70,7 @@ export class PushModule {
|
|
|
69
70
|
const projectId = this.client.projectId;
|
|
70
71
|
|
|
71
72
|
const { data } = await this.http.post<RegisterDeviceResponse>(
|
|
72
|
-
|
|
73
|
+
routes.push.devices.build(projectId),
|
|
73
74
|
{
|
|
74
75
|
platform: params.platform,
|
|
75
76
|
token: params.token,
|
|
@@ -90,7 +91,7 @@ export class PushModule {
|
|
|
90
91
|
const projectId = this.client.projectId;
|
|
91
92
|
|
|
92
93
|
const { data } = await this.http.post<SendPushResponse>(
|
|
93
|
-
|
|
94
|
+
routes.push.send.build(projectId),
|
|
94
95
|
{
|
|
95
96
|
token: params.token,
|
|
96
97
|
title: params.title,
|
|
@@ -113,7 +114,7 @@ export class PushModule {
|
|
|
113
114
|
const projectId = this.client.projectId;
|
|
114
115
|
|
|
115
116
|
const { data } = await this.http.post<SendPushResponse>(
|
|
116
|
-
|
|
117
|
+
routes.push.send.build(projectId),
|
|
117
118
|
{
|
|
118
119
|
userId: params.userId,
|
|
119
120
|
title: params.title,
|
|
@@ -132,7 +133,7 @@ export class PushModule {
|
|
|
132
133
|
const projectId = this.client.projectId;
|
|
133
134
|
|
|
134
135
|
const { data } = await this.http.get<{ data: PushLogEntry[] }>(
|
|
135
|
-
|
|
136
|
+
routes.push.logs.build(projectId),
|
|
136
137
|
{
|
|
137
138
|
params: {
|
|
138
139
|
limit: options.limit,
|
|
@@ -149,7 +150,7 @@ export class PushModule {
|
|
|
149
150
|
const projectId = this.client.projectId;
|
|
150
151
|
|
|
151
152
|
const { data } = await this.http.get<PushStats>(
|
|
152
|
-
|
|
153
|
+
routes.push.stats.build(projectId)
|
|
153
154
|
);
|
|
154
155
|
|
|
155
156
|
return data;
|