@onesignal/node-onesignal 1.0.0-beta4 → 1.0.0-beta5
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/.github/ISSUE_TEMPLATE/ask-question.yml +25 -0
- package/.github/ISSUE_TEMPLATE/bug-report.yml +51 -0
- package/.github/ISSUE_TEMPLATE/general-feedback.yml +25 -0
- package/.github/pull_request_template.md +44 -0
- package/.github/workflows/npm_deploy.yml +21 -0
- package/CHANGELOG.md +26 -0
- package/DefaultApi.md +1232 -0
- package/LICENSE +24 -0
- package/README.md +205 -102
- package/RELEASE_INSTRUCTIONS.md +2 -0
- package/apis/DefaultApi.ts +519 -532
- package/apis/baseapi.ts +4 -4
- package/apis/exception.ts +4 -3
- package/auth/auth.ts +4 -1
- package/configuration.ts +21 -2
- package/http/http.ts +26 -26
- package/index.ts +1 -0
- package/middleware.ts +1 -1
- package/models/App.ts +8 -8
- package/models/BasicNotification.ts +1019 -0
- package/models/BasicNotificationAllOf.ts +897 -0
- package/models/{NotificationAllOfAndroidBackgroundLayout.ts → BasicNotificationAllOfAndroidBackgroundLayout.ts} +4 -4
- package/models/Button.ts +2 -2
- package/models/CancelNotificationSuccessResponse.ts +31 -0
- package/models/{InlineResponse400.ts → CreateNotificationBadRequestResponse.ts} +4 -4
- package/models/{InlineResponse200.ts → CreateNotificationSuccessResponse.ts} +7 -6
- package/models/{InlineResponse2004.ts → CreatePlayerSuccessResponse.ts} +4 -4
- package/models/CreateSegmentBadRequestResponse.ts +38 -0
- package/models/{InlineResponse409.ts → CreateSegmentConflictResponse.ts} +4 -4
- package/models/{InlineResponse201.ts → CreateSegmentSuccessResponse.ts} +4 -4
- package/models/DeletePlayerBadRequestResponse.ts +31 -0
- package/models/DeletePlayerNotFoundResponse.ts +31 -0
- package/models/{InlineResponse2003.ts → DeletePlayerSuccessResponse.ts} +4 -4
- package/models/{InlineResponse4002.ts → DeleteSegmentBadRequestResponse.ts} +4 -4
- package/models/DeleteSegmentNotFoundResponse.ts +31 -0
- package/models/DeleteSegmentSuccessResponse.ts +31 -0
- package/models/DeliveryData.ts +17 -2
- package/models/ExportPlayersRequestBody.ts +5 -5
- package/models/{InlineResponse2005.ts → ExportPlayersSuccessResponse.ts} +4 -4
- package/models/Filter.ts +4 -4
- package/models/FilterExpressions.ts +4 -4
- package/models/FilterNotificationTarget.ts +2 -2
- package/models/GetNotificationRequestBody.ts +2 -2
- package/models/InvalidIdentifierError.ts +44 -0
- package/models/Notification.ts +72 -174
- package/models/Notification200Errors.ts +45 -0
- package/models/NotificationAllOf.ts +3 -858
- package/models/{InlineResponse4001.ts → NotificationHistoryBadRequestResponse.ts} +4 -4
- package/models/{InlineResponse2002.ts → NotificationHistorySuccessResponse.ts} +6 -6
- package/models/NotificationSlice.ts +5 -5
- package/models/NotificationTarget.ts +3 -124
- package/models/NotificationWithMeta.ts +1127 -0
- package/models/NotificationWithMetaAllOf.ts +132 -0
- package/models/ObjectSerializer.ts +97 -46
- package/models/Operator.ts +2 -2
- package/models/OutcomeData.ts +2 -2
- package/models/OutcomesData.ts +32 -0
- package/models/PlatformDeliveryData.ts +18 -2
- package/models/PlatformDeliveryDataEmailAllOf.ts +94 -0
- package/models/PlatformDeliveryDataSmsAllOf.ts +54 -0
- package/models/Player.ts +14 -14
- package/models/PlayerNotificationTarget.ts +3 -3
- package/models/PlayerSlice.ts +2 -2
- package/models/Purchase.ts +2 -2
- package/models/Segment.ts +3 -3
- package/models/SegmentNotificationTarget.ts +2 -2
- package/models/StringMap.ts +3 -3
- package/models/{InlineResponse2001.ts → UpdatePlayerSuccessResponse.ts} +6 -6
- package/models/UpdatePlayerTagsRequestBody.ts +4 -4
- package/models/UpdatePlayerTagsSuccessResponse.ts +31 -0
- package/models/all.ts +28 -13
- package/package.json +14 -9
- package/tsconfig.json +1 -2
- package/types/ObjectParamAPI.ts +101 -86
- package/types/ObservableAPI.ts +116 -101
- package/types/PromiseAPI.ts +97 -82
- package/util.ts +10 -1
- package/dist/apis/DefaultApi.d.ts +0 -62
- package/dist/apis/DefaultApi.js +0 -1317
- package/dist/apis/DefaultApi.js.map +0 -1
- package/dist/apis/baseapi.d.ts +0 -16
- package/dist/apis/baseapi.js +0 -42
- package/dist/apis/baseapi.js.map +0 -1
- package/dist/apis/exception.d.ts +0 -5
- package/dist/apis/exception.js +0 -28
- package/dist/apis/exception.js.map +0 -1
- package/dist/auth/auth.d.ts +0 -40
- package/dist/auth/auth.js +0 -108
- package/dist/auth/auth.js.map +0 -1
- package/dist/configuration.d.ts +0 -18
- package/dist/configuration.js +0 -21
- package/dist/configuration.js.map +0 -1
- package/dist/http/http.d.ts +0 -72
- package/dist/http/http.js +0 -205
- package/dist/http/http.js.map +0 -1
- package/dist/http/isomorphic-fetch.d.ts +0 -5
- package/dist/http/isomorphic-fetch.js +0 -33
- package/dist/http/isomorphic-fetch.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/middleware.d.ts +0 -16
- package/dist/middleware.js +0 -18
- package/dist/middleware.js.map +0 -1
- package/dist/models/App.d.ts +0 -47
- package/dist/models/App.js +0 -196
- package/dist/models/App.js.map +0 -1
- package/dist/models/Button.d.ts +0 -19
- package/dist/models/Button.js +0 -34
- package/dist/models/Button.js.map +0 -1
- package/dist/models/DeliveryData.d.ts +0 -21
- package/dist/models/DeliveryData.js +0 -46
- package/dist/models/DeliveryData.js.map +0 -1
- package/dist/models/ExportPlayersRequestBody.d.ts +0 -19
- package/dist/models/ExportPlayersRequestBody.js +0 -34
- package/dist/models/ExportPlayersRequestBody.js.map +0 -1
- package/dist/models/Filter.d.ts +0 -21
- package/dist/models/Filter.js +0 -40
- package/dist/models/Filter.js.map +0 -1
- package/dist/models/FilterExpressions.d.ts +0 -23
- package/dist/models/FilterExpressions.js +0 -46
- package/dist/models/FilterExpressions.js.map +0 -1
- package/dist/models/FilterNotificationTarget.d.ts +0 -28
- package/dist/models/FilterNotificationTarget.js +0 -88
- package/dist/models/FilterNotificationTarget.js.map +0 -1
- package/dist/models/GetNotificationRequestBody.d.ts +0 -20
- package/dist/models/GetNotificationRequestBody.js +0 -34
- package/dist/models/GetNotificationRequestBody.js.map +0 -1
- package/dist/models/InlineResponse200.d.ts +0 -20
- package/dist/models/InlineResponse200.js +0 -40
- package/dist/models/InlineResponse200.js.map +0 -1
- package/dist/models/InlineResponse2001.d.ts +0 -17
- package/dist/models/InlineResponse2001.js +0 -22
- package/dist/models/InlineResponse2001.js.map +0 -1
- package/dist/models/InlineResponse2002.d.ts +0 -18
- package/dist/models/InlineResponse2002.js +0 -28
- package/dist/models/InlineResponse2002.js.map +0 -1
- package/dist/models/InlineResponse2003.d.ts +0 -17
- package/dist/models/InlineResponse2003.js +0 -22
- package/dist/models/InlineResponse2003.js.map +0 -1
- package/dist/models/InlineResponse2004.d.ts +0 -18
- package/dist/models/InlineResponse2004.js +0 -28
- package/dist/models/InlineResponse2004.js.map +0 -1
- package/dist/models/InlineResponse2005.d.ts +0 -17
- package/dist/models/InlineResponse2005.js +0 -22
- package/dist/models/InlineResponse2005.js.map +0 -1
- package/dist/models/InlineResponse201.d.ts +0 -18
- package/dist/models/InlineResponse201.js +0 -28
- package/dist/models/InlineResponse201.js.map +0 -1
- package/dist/models/InlineResponse400.d.ts +0 -17
- package/dist/models/InlineResponse400.js +0 -22
- package/dist/models/InlineResponse400.js.map +0 -1
- package/dist/models/InlineResponse4001.d.ts +0 -18
- package/dist/models/InlineResponse4001.js +0 -28
- package/dist/models/InlineResponse4001.js.map +0 -1
- package/dist/models/InlineResponse4002.d.ts +0 -17
- package/dist/models/InlineResponse4002.js +0 -22
- package/dist/models/InlineResponse4002.js.map +0 -1
- package/dist/models/InlineResponse409.d.ts +0 -18
- package/dist/models/InlineResponse409.js +0 -28
- package/dist/models/InlineResponse409.js.map +0 -1
- package/dist/models/Notification.d.ts +0 -132
- package/dist/models/Notification.js +0 -688
- package/dist/models/Notification.js.map +0 -1
- package/dist/models/NotificationAllOf.d.ts +0 -108
- package/dist/models/NotificationAllOf.js +0 -544
- package/dist/models/NotificationAllOf.js.map +0 -1
- package/dist/models/NotificationAllOfAndroidBackgroundLayout.d.ts +0 -19
- package/dist/models/NotificationAllOfAndroidBackgroundLayout.js +0 -34
- package/dist/models/NotificationAllOfAndroidBackgroundLayout.js.map +0 -1
- package/dist/models/NotificationSlice.d.ts +0 -21
- package/dist/models/NotificationSlice.js +0 -40
- package/dist/models/NotificationSlice.js.map +0 -1
- package/dist/models/NotificationTarget.d.ts +0 -40
- package/dist/models/NotificationTarget.js +0 -160
- package/dist/models/NotificationTarget.js.map +0 -1
- package/dist/models/ObjectSerializer.d.ts +0 -44
- package/dist/models/ObjectSerializer.js +0 -312
- package/dist/models/ObjectSerializer.js.map +0 -1
- package/dist/models/Operator.d.ts +0 -18
- package/dist/models/Operator.js +0 -22
- package/dist/models/Operator.js.map +0 -1
- package/dist/models/OutcomeData.d.ts +0 -20
- package/dist/models/OutcomeData.js +0 -34
- package/dist/models/OutcomeData.js.map +0 -1
- package/dist/models/PlatformDeliveryData.d.ts +0 -23
- package/dist/models/PlatformDeliveryData.js +0 -52
- package/dist/models/PlatformDeliveryData.js.map +0 -1
- package/dist/models/Player.d.ts +0 -43
- package/dist/models/Player.js +0 -178
- package/dist/models/Player.js.map +0 -1
- package/dist/models/PlayerNotificationTarget.d.ts +0 -26
- package/dist/models/PlayerNotificationTarget.js +0 -76
- package/dist/models/PlayerNotificationTarget.js.map +0 -1
- package/dist/models/PlayerSlice.d.ts +0 -21
- package/dist/models/PlayerSlice.js +0 -40
- package/dist/models/PlayerSlice.js.map +0 -1
- package/dist/models/Purchase.d.ts +0 -19
- package/dist/models/Purchase.js +0 -34
- package/dist/models/Purchase.js.map +0 -1
- package/dist/models/Segment.d.ts +0 -20
- package/dist/models/Segment.js +0 -34
- package/dist/models/Segment.js.map +0 -1
- package/dist/models/SegmentNotificationTarget.d.ts +0 -18
- package/dist/models/SegmentNotificationTarget.js +0 -28
- package/dist/models/SegmentNotificationTarget.js.map +0 -1
- package/dist/models/StringMap.d.ts +0 -59
- package/dist/models/StringMap.js +0 -274
- package/dist/models/StringMap.js.map +0 -1
- package/dist/models/UpdatePlayerTagsRequestBody.d.ts +0 -17
- package/dist/models/UpdatePlayerTagsRequestBody.js +0 -22
- package/dist/models/UpdatePlayerTagsRequestBody.js.map +0 -1
- package/dist/models/all.d.ts +0 -35
- package/dist/models/all.js +0 -48
- package/dist/models/all.js.map +0 -1
- package/dist/rxjsStub.d.ts +0 -10
- package/dist/rxjsStub.js +0 -33
- package/dist/rxjsStub.js.map +0 -1
- package/dist/servers.d.ts +0 -17
- package/dist/servers.js +0 -32
- package/dist/servers.js.map +0 -1
- package/dist/types/ObjectParamAPI.d.ts +0 -121
- package/dist/types/ObjectParamAPI.js +0 -69
- package/dist/types/ObjectParamAPI.js.map +0 -1
- package/dist/types/ObservableAPI.d.ts +0 -45
- package/dist/types/ObservableAPI.js +0 -472
- package/dist/types/ObservableAPI.js.map +0 -1
- package/dist/types/PromiseAPI.d.ts +0 -42
- package/dist/types/PromiseAPI.js +0 -88
- package/dist/types/PromiseAPI.js.map +0 -1
- package/dist/util.d.ts +0 -1
- package/dist/util.js +0 -25
- package/dist/util.js.map +0 -1
- package/git_push.sh +0 -52
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Modified MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2022 OneSignal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
1. The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
2. All copies of substantial portions of the Software may only be used in connection
|
|
16
|
+
with services provided by OneSignal.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,16 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<h1 align="center">Welcome to @onesignal/node-onesignal 👋</h1>
|
|
2
|
+
<p>
|
|
3
|
+
<a href="https://www.npmjs.com/package/@onesignal/node-onesignal" target="_blank">
|
|
4
|
+
<img alt="Version" src="https://img.shields.io/npm/v/@onesignal/node-onesignal.svg">
|
|
5
|
+
</a>
|
|
6
|
+
<a href="https://github.com/OneSignal/node-onesignal#readme" target="_blank">
|
|
7
|
+
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://github.com/OneSignal/node-onesignal/graphs/commit-activity" target="_blank">
|
|
10
|
+
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://twitter.com/onesignal" target="_blank">
|
|
13
|
+
<img alt="Twitter: onesignal" src="https://img.shields.io/twitter/follow/onesignal.svg?style=social" />
|
|
14
|
+
</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
> OpenAPI client for node-onesignal
|
|
18
|
+
|
|
19
|
+
### 🏠 [Homepage](https://github.com/OneSignal/node-onesignal#readme)
|
|
20
|
+
### 🖤 [npm](https://www.npmjs.com/package/@onesignal/node-onesignal)
|
|
21
|
+
|
|
22
|
+
# Node Client SDK
|
|
23
|
+
The OneSignal Node client is a server OneSignal SDK for NodeJS. Integrate OneSignal with your backend events, data, and
|
|
24
|
+
more.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# Install
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
# yarn
|
|
31
|
+
yarn add @onesignal/node-onesignal
|
|
5
32
|
|
|
6
|
-
|
|
33
|
+
# npm
|
|
7
34
|
npm install @onesignal/node-onesignal --save
|
|
8
35
|
```
|
|
9
36
|
|
|
10
|
-
```
|
|
11
|
-
yarn add @onesignal/node-onesignal
|
|
12
|
-
```
|
|
13
|
-
|
|
14
37
|
# Usage
|
|
15
38
|
```js
|
|
16
39
|
const OneSignal = require('@onesignal/node-onesignal');
|
|
@@ -21,12 +44,12 @@ import * as OneSignal from '@onesignal/node-onesignal';
|
|
|
21
44
|
|
|
22
45
|
## Creating a client
|
|
23
46
|
### Configuration
|
|
24
|
-
We can configure the client using the `createConfiguration` function. You can find more info on each configuration
|
|
47
|
+
We can configure the client using the `createConfiguration` function. You can find more info on each configuration
|
|
48
|
+
parameter [here](https://github.com/OpenAPITools/openapi-generator/pull/10283/files).
|
|
25
49
|
|
|
26
50
|
```js
|
|
27
51
|
const configuration = OneSignal.createConfiguration(configParams);
|
|
28
52
|
```
|
|
29
|
-
The returned `configuration` object is what is passed to the `DefaultApi` constructor to initialize the client.
|
|
30
53
|
|
|
31
54
|
### Initializing the Client
|
|
32
55
|
```js
|
|
@@ -34,79 +57,66 @@ const client = new OneSignal.DefaultApi(configuration);
|
|
|
34
57
|
```
|
|
35
58
|
|
|
36
59
|
### Authentication
|
|
37
|
-
|
|
38
|
-
For managing operations outside of a OneSignal app (e.g: creating a OneSignal app), you will need to use your OneSignal account [user auth key](https://documentation.onesignal.com/docs/accounts-and-keys#user-auth-key). Create a key provider object with a function `getToken` that returns your key.
|
|
39
|
-
```js
|
|
40
|
-
const user_key_provider = {
|
|
41
|
-
getToken() {
|
|
42
|
-
return "************************************************";
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
#### App
|
|
48
|
-
Create a key provider object with a function `getToken` that returns your OneSignal [app's API key](https://documentation.onesignal.com/docs/accounts-and-keys#rest-api-key).
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
const app_key_provider = {
|
|
52
|
-
getToken() {
|
|
53
|
-
return "************************************************";
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
```
|
|
60
|
+
You can configure auth parameters passing them like this:
|
|
57
61
|
|
|
58
|
-
#### Putting it together
|
|
59
62
|
```js
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
user_key: {
|
|
64
|
-
tokenProvider: user_key_provider
|
|
65
|
-
},
|
|
66
|
-
app_key: {
|
|
67
|
-
tokenProvider: app_key_provider
|
|
68
|
-
}
|
|
69
|
-
}
|
|
63
|
+
const configuration = OneSignal.createConfiguration({
|
|
64
|
+
userKey: '<YOUR_USER_KEY_TOKEN>',
|
|
65
|
+
appKey: '<YOUR_APP_KEY_TOKEN>',
|
|
70
66
|
});
|
|
71
67
|
|
|
72
|
-
client = new OneSignal.DefaultApi(configuration);
|
|
68
|
+
const client = new OneSignal.DefaultApi(configuration);
|
|
73
69
|
```
|
|
74
70
|
|
|
75
71
|
#### Advanced Usage: Creating a brand new app
|
|
76
|
-
If creating a new app via the client, the response will return the app's API key via the `basic_auth_key` response
|
|
72
|
+
If creating a new app via the client, the response will return the app's API key via the `basic_auth_key` response
|
|
73
|
+
parameter. You can then use this to modify your configuration object and create a new client that will have both user-level and app-level authentication set up.
|
|
77
74
|
|
|
78
75
|
```js
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
configuration = OneSignal.createConfiguration({
|
|
87
|
-
authMethods: {
|
|
88
|
-
user_key: {
|
|
89
|
-
tokenProvider: user_key_provider
|
|
90
|
-
},
|
|
91
|
-
app_key: {
|
|
92
|
-
tokenProvider: app_key_provider
|
|
93
|
-
}
|
|
94
|
-
}
|
|
76
|
+
const response = await client.createApp(newapp);
|
|
77
|
+
|
|
78
|
+
const configuration = OneSignal.createConfiguration({
|
|
79
|
+
userKey: '<YOUR_USER_KEY_TOKEN>',
|
|
80
|
+
appKey: response.basic_auth_key,
|
|
95
81
|
});
|
|
96
82
|
|
|
97
|
-
client = new OneSignal.DefaultApi(configuration);
|
|
83
|
+
const client = new OneSignal.DefaultApi(configuration);
|
|
98
84
|
```
|
|
99
85
|
|
|
100
86
|
---
|
|
101
87
|
## API Reference
|
|
102
|
-
|
|
88
|
+
|
|
89
|
+
To make stateful changes requests should take on the following pattern:
|
|
103
90
|
1. create or get an object
|
|
104
91
|
2. make changes to that object
|
|
105
|
-
3. pass the object to the request function to make the changes
|
|
92
|
+
3. pass the object to the request function to make the changes
|
|
106
93
|
|
|
107
94
|
Examples of important OneSignal objects include `App`, `Notification`, `Player`, and `Segment`.
|
|
108
95
|
|
|
109
|
-
For example, see the section below on creating an app. First an app object is created via the instantiation of the `App`
|
|
96
|
+
For example, see the section below on creating an app. First an app object is created via the instantiation of the `App`
|
|
97
|
+
class. Then, the app instance is modified directly. Finally, we use the `client` to create the app via a remote request.
|
|
98
|
+
|
|
99
|
+
| Function | HTTP Request | Description |
|
|
100
|
+
|---------------------------------------------------------|------------------------------------------------|-----------------------------------------------------|
|
|
101
|
+
| [cancelNotification](#canceling-a-notification) | Delete `/notifications/{notification_id}` | Stop a scheduled or currently outgoing notification |
|
|
102
|
+
| [createApp](#creating-an-app) | Post `/apps` | Create an app |
|
|
103
|
+
| [createNotification](#creating-a-notification) | Post `/notifications` | Create notification |
|
|
104
|
+
| [createPlayer](#creating-a-player) | Post `/players` | Add a device |
|
|
105
|
+
| [createSegments](#creating-a-segment) | Post `/apps/{app_id}/segments` | Create Segments |
|
|
106
|
+
| [deletePlayer](#deleting-a-player) | Delete `/players/{player_id}` | Delete a user record |
|
|
107
|
+
| [deleteSegments](#deleting-a-segment) | Delete `/apps/{app_id}/segments/{segment_id}` | Delete Segments |
|
|
108
|
+
| [exportPlayers](#exporting-a-player) | Post `/players/csv_export?app_id={app_id}` | CSV export |
|
|
109
|
+
| [getApp](#getting-an-app) | Get `/apps/{app_id}` | View an app |
|
|
110
|
+
| [getApps](#getting-multiple-apps) | Get `/apps` | View apps |
|
|
111
|
+
| [getNotification](#getting-a-notification) | Get `/notifications/{notification_id}` | View notification |
|
|
112
|
+
| [getNotificationHistory](#getting-notification-history) | Post `/notifications/{notification_id}/history` | Notification History |
|
|
113
|
+
| [getNotifications](#getting-a-notification) | Get `/notifications` | View notifications |
|
|
114
|
+
| [getOutcomes](#getting-outcomes) | Get `/apps/{app_id}/outcomes` | View Outcomes |
|
|
115
|
+
| [getPlayer](#getting-a-player) | Get `/players/{player_id}` | View device |
|
|
116
|
+
| [getPlayers](#getting-players) | Get `/players` | View devices |
|
|
117
|
+
| [updateApp](#getting-an-app) | Put `/apps/{app_id}` | Update an app |
|
|
118
|
+
| [updatePlayer](#updating-a-player) | Put `/players/{player_id}` | Edit device |
|
|
119
|
+
| [updatePlayerTags](#updating-player-tags) | Put `/apps/{app_id}/users/{external_user_id}` | Edit tags with external user id |
|
|
110
120
|
|
|
111
121
|
### Creating an app
|
|
112
122
|
Creates a new OneSignal app.
|
|
@@ -128,7 +138,15 @@ View the details of a single OneSignal app.
|
|
|
128
138
|
|
|
129
139
|
**Example**
|
|
130
140
|
```js
|
|
131
|
-
client.getApp('<app id>');
|
|
141
|
+
const app = await client.getApp('<app id>');
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Getting multiple apps
|
|
145
|
+
View apps.
|
|
146
|
+
|
|
147
|
+
**Example**
|
|
148
|
+
```js
|
|
149
|
+
const apps = await client.getApps();
|
|
132
150
|
```
|
|
133
151
|
|
|
134
152
|
### Updating an app
|
|
@@ -136,12 +154,34 @@ Updates the name or configuration settings of an existing OneSignal app.
|
|
|
136
154
|
|
|
137
155
|
**Example**
|
|
138
156
|
```js
|
|
139
|
-
|
|
157
|
+
const app = new OneSignal.App();
|
|
158
|
+
app.name = 'modified_app_name';
|
|
159
|
+
|
|
160
|
+
const udpateAppResponse = await client.updateApp('<existing_app_id>', app);
|
|
140
161
|
```
|
|
141
162
|
|
|
142
163
|
### Creating a notification
|
|
143
164
|
Sends a notification to your users.
|
|
144
165
|
|
|
166
|
+
**Example**
|
|
167
|
+
```js
|
|
168
|
+
const notification = new OneSignal.Notification();
|
|
169
|
+
notification.app_id = app.id;
|
|
170
|
+
// Name property may be required in some case, for instance when sending an SMS.
|
|
171
|
+
notification.name = "test_notification_name";
|
|
172
|
+
notification.contents = {
|
|
173
|
+
en: "Gig'em Ags"
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// required for Huawei
|
|
177
|
+
notification.headings = {
|
|
178
|
+
en: "Gig'em Ags"
|
|
179
|
+
}
|
|
180
|
+
const notification = await client.createNotification(notification);
|
|
181
|
+
```
|
|
182
|
+
### Creating a notification using Filters
|
|
183
|
+
Sends a notification to your users filtered by specific criteria.
|
|
184
|
+
|
|
145
185
|
**Example**
|
|
146
186
|
```js
|
|
147
187
|
const notification = new OneSignal.Notification();
|
|
@@ -155,15 +195,36 @@ notification.contents = {
|
|
|
155
195
|
notification.headings = {
|
|
156
196
|
en: "Gig'em Ags"
|
|
157
197
|
}
|
|
158
|
-
|
|
198
|
+
|
|
199
|
+
// Find all the users that have not spent any amount in USD on IAP.
|
|
200
|
+
// https://documentation.onesignal.com/reference/create-notification#send-to-users-based-on-filters
|
|
201
|
+
notification.filters = [
|
|
202
|
+
{
|
|
203
|
+
field: 'amount_spent',
|
|
204
|
+
relation: '=',
|
|
205
|
+
value: "0"
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
const notification = await client.createNotification(notification);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Canceling a notification
|
|
213
|
+
Stop a scheduled or currently outgoing notification.
|
|
214
|
+
|
|
215
|
+
**Example**
|
|
216
|
+
|
|
217
|
+
```js
|
|
218
|
+
const cancelNotificationResponse = await client.cancelNotification('<app id>', '<notification id>');
|
|
159
219
|
```
|
|
160
220
|
|
|
221
|
+
|
|
161
222
|
### Getting a notification
|
|
162
223
|
View the details of a single notification and outcomes associated with it.
|
|
163
224
|
|
|
164
225
|
**Example**
|
|
165
226
|
```js
|
|
166
|
-
client.getNotification('<app id>', '<notification id>');
|
|
227
|
+
await client.getNotification('<app id>', '<notification id>');
|
|
167
228
|
```
|
|
168
229
|
|
|
169
230
|
### Getting notifications
|
|
@@ -171,7 +232,7 @@ View the details of multiple notifications.
|
|
|
171
232
|
|
|
172
233
|
| Param | Type | Description |
|
|
173
234
|
|--------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
174
|
-
| app_id
|
|
235
|
+
| app_id | string | The OneSignal App ID for your app. Available in Keys & IDs. |
|
|
175
236
|
| limit | string | How many notifications to return. Max is 50. Default is 50. |
|
|
176
237
|
| offset | number | Page offset. Default is 0. Results are sorted by queued_at in descending order. `queued_at` is a representation of the time that the notification was queued at. |
|
|
177
238
|
| kind | number | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only |
|
|
@@ -179,16 +240,17 @@ View the details of multiple notifications.
|
|
|
179
240
|
|
|
180
241
|
**Example**
|
|
181
242
|
```js
|
|
182
|
-
client.getNotifications('<app id>', '50', 0, 1);
|
|
243
|
+
const notifications = await client.getNotifications('<app id>', '50', 0, 1);
|
|
183
244
|
```
|
|
184
245
|
|
|
185
246
|
### Getting notification history
|
|
186
247
|
View the devices sent a message - **OneSignal Paid Plan Required**
|
|
187
|
-
This method will return all devices that were sent the given `notification_id` of an Email or Push Notification if used
|
|
248
|
+
This method will return all devices that were sent the given `notification_id` of an Email or Push Notification if used
|
|
249
|
+
within 7 days of the date sent.
|
|
188
250
|
|
|
189
251
|
**Example**
|
|
190
252
|
```js
|
|
191
|
-
client.getNotificationHistory('<notification id>');
|
|
253
|
+
const notificationHistory = await client.getNotificationHistory('<notification id>');
|
|
192
254
|
```
|
|
193
255
|
|
|
194
256
|
### Creating a segment
|
|
@@ -203,50 +265,67 @@ segment.filters = [
|
|
|
203
265
|
{ field: 'tag', key: 'my_tag', relation: 'exists' }
|
|
204
266
|
]
|
|
205
267
|
|
|
206
|
-
client.createSegments(app.id, segment)
|
|
268
|
+
const segment = await client.createSegments(app.id, segment);
|
|
207
269
|
```
|
|
208
270
|
|
|
209
271
|
### Deleting a segment
|
|
210
272
|
Delete segments (not user devices) - **Required: OneSignal Paid Plan**
|
|
211
|
-
You can delete a segment under your app by calling this API. You must provide an API key in the Authorization header
|
|
273
|
+
You can delete a segment under your app by calling this API. You must provide an API key in the Authorization header
|
|
274
|
+
that has admin access on the app.
|
|
212
275
|
The `segment_id` can be found in the URL of the segment when viewing it in the dashboard.
|
|
213
276
|
|
|
214
277
|
**Example**
|
|
215
278
|
```js
|
|
216
|
-
client.deleteSegments('<app id>', '<segment id>');
|
|
279
|
+
const deleteSegmentsResponse = await client.deleteSegments('<app id>', '<segment id>');
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Creating a player
|
|
283
|
+
Add a device.
|
|
284
|
+
|
|
285
|
+
**Example**
|
|
286
|
+
```js
|
|
287
|
+
const player = new OneSignal.Player();
|
|
288
|
+
player.device_type = 1;
|
|
289
|
+
player.app_id = app_id;
|
|
290
|
+
player.identifier = '<identifier>';
|
|
291
|
+
const player = await client.createPlayer(player);
|
|
217
292
|
```
|
|
218
293
|
|
|
219
294
|
### Getting a player
|
|
220
|
-
View the details of an existing device in one of your OneSignal apps.
|
|
295
|
+
View the details of an existing device in one of your OneSignal apps.
|
|
296
|
+
The email and the hash is **only required if you have enabled Identity Verification and `device_type` is email**.
|
|
221
297
|
|
|
222
298
|
**Example**
|
|
223
299
|
```js
|
|
224
|
-
client.getPlayer('<app id>', '<player id>', '<email auth hash>');
|
|
300
|
+
const player = await client.getPlayer('<app id>', '<player id>', '<email auth hash>');
|
|
225
301
|
```
|
|
226
302
|
|
|
227
303
|
### Getting players
|
|
228
|
-
View the details of multiple devices in one of your OneSignal apps.
|
|
304
|
+
View the details of multiple devices in one of your OneSignal apps.
|
|
305
|
+
|
|
306
|
+
⚠️ Unavailable for Apps Over 80,000 Users.
|
|
229
307
|
|
|
230
|
-
| Param
|
|
231
|
-
|
|
232
|
-
| app_id
|
|
233
|
-
| limit
|
|
234
|
-
| offset
|
|
308
|
+
| Param | Type | Description |
|
|
309
|
+
|--------|--------|------------------------------------------------------------------|
|
|
310
|
+
| app_id | string | The OneSignal App ID for your app. Available in Keys & IDs. |
|
|
311
|
+
| limit | string | How many devices to return. Max is 300. Default is 300 |
|
|
312
|
+
| offset | number | Result offset. Default is 0. Results are sorted by id; |
|
|
235
313
|
|
|
236
314
|
|
|
237
315
|
**Example**
|
|
238
316
|
```js
|
|
239
|
-
client.getPlayers('<app id>', '300', 0);
|
|
317
|
+
const players = await client.getPlayers('<app id>', '300', 0);
|
|
240
318
|
```
|
|
241
319
|
|
|
242
320
|
### Exporting a player
|
|
243
|
-
Generate a compressed CSV export of all of your current user data. This method can be used to generate a compressed CSV
|
|
321
|
+
Generate a compressed CSV export of all of your current user data. This method can be used to generate a compressed CSV
|
|
322
|
+
export of all of your existing user data and is a better alternative to retrieving this data using the /players API endpoint.
|
|
244
323
|
|
|
245
324
|
See [full CSV Export Reference](https://documentation.onesignal.com/reference/csv-export)
|
|
246
325
|
|
|
247
326
|
**Example**
|
|
248
327
|
```js
|
|
249
|
-
client.exportPlayer('<app id>', {
|
|
328
|
+
const exportPlayerResponse = await client.exportPlayer('<app id>', {
|
|
250
329
|
extra_fields: ['location', 'external_user_id'],
|
|
251
330
|
last_active_since: 1469392779,
|
|
252
331
|
segment_name: "Subscribed Users"
|
|
@@ -259,24 +338,28 @@ Update an existing device in one of your OneSignal apps.
|
|
|
259
338
|
|
|
260
339
|
**Example**
|
|
261
340
|
```js
|
|
262
|
-
client.updatePlayer('<player id>', player);
|
|
341
|
+
const updatePlayerResponse = await client.updatePlayer('<player id>', player);
|
|
263
342
|
```
|
|
264
343
|
|
|
265
344
|
### Updating player tags
|
|
266
345
|
Update an existing device's tags in one of your OneSignal apps using the External User ID.
|
|
267
|
-
#### Warning - Android SDK Data Synchronization
|
|
268
|
-
Tags added through the Android SDK tagging methods may not update if using the API to change or update the same tag.
|
|
269
|
-
For example, if you use SDK method sendTag("key", "value1") then update the tag value to "value2" with this API endpoint. You will not be able to set the value back to "value1" through the SDK, you will need to change it to something different through the SDK to be reset.
|
|
270
346
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
2 - If you want to use the same key for both SDK and API updates, call the SDK getTags method first to update the device's tags.
|
|
347
|
+
```js
|
|
348
|
+
const playerToUpdate = new OneSignal.Player();
|
|
274
349
|
|
|
275
|
-
|
|
350
|
+
player.app_id = APP_ID;
|
|
351
|
+
player.device_type = 1;
|
|
276
352
|
|
|
353
|
+
playerToUpdate.external_user_id = 'your_player_external_id'; // setting the same external_user_id as before
|
|
354
|
+
const updatePlayerTagsRequestBody = new OneSignal.UpdatePlayerTagsRequestBody();
|
|
355
|
+
updatePlayerTagsRequestBody.tags = {'typescript_test_tag': 1};
|
|
356
|
+
const updatePlayerResponse = await api.updatePlayerTags(APP_ID, PLAYER_EXTERNAL_USER_ID, updatePlayerTagsRequestBody);
|
|
357
|
+
```
|
|
277
358
|
#### Deleting Tags
|
|
278
|
-
To delete a tag, include its key and set its value to blank. Omitting a key/value will not delete it.
|
|
279
|
-
|
|
359
|
+
To delete a tag, include its key and set its value to blank (""). Omitting a key/value will not delete it.
|
|
360
|
+
|
|
361
|
+
For example, if you wanted to delete two existing tags rank and category while simultaneously adding a new tag class, the
|
|
362
|
+
tags JSON would look like the following:
|
|
280
363
|
|
|
281
364
|
**Example**
|
|
282
365
|
```json
|
|
@@ -288,23 +371,23 @@ For example, if I wanted to delete two existing tags rank and category while sim
|
|
|
288
371
|
```
|
|
289
372
|
|
|
290
373
|
### Deleting a player
|
|
291
|
-
|
|
374
|
+
Deletes a user record.
|
|
292
375
|
|
|
293
376
|
**Example**
|
|
294
377
|
```js
|
|
295
|
-
client.deletePlayer(app.id, '<player id>')
|
|
378
|
+
const deletePlayerResponse = await client.deletePlayer(app.id, '<player id>')
|
|
296
379
|
```
|
|
297
380
|
|
|
298
381
|
### Getting outcomes
|
|
299
382
|
View the details of all the outcomes associated with your app.
|
|
300
383
|
|
|
301
|
-
🚧 **Requires
|
|
384
|
+
🚧 **Requires your OneSignal App's REST API Key, available in Keys & IDs** 🚧
|
|
302
385
|
|
|
303
|
-
Outcome
|
|
386
|
+
Outcome data are accessible for 30 days before being deleted from our servers. You can export this data monthly if you need it for a more extended period.
|
|
304
387
|
|
|
305
388
|
| Param | Type | Description |
|
|
306
389
|
|---------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
307
|
-
| app_id
|
|
390
|
+
| app_id | string | The OneSignal App ID for your app. Available in Keys & IDs. |
|
|
308
391
|
| outcome_names | string | Required Comma-separated list of names and the value (sum/count) for the returned outcome data. Note: Clicks only support count aggregation. For out-of-the-box OneSignal outcomes such as click and session duration, please use the “os” prefix with two underscores. For other outcomes, please use the name specified by the user. Example:os__session_duration.count,os__click.count,CustomOutcomeName.sum |
|
|
309
392
|
| outcome_names2 | string | If outcome names contain any commas, then please specify only one value at a time. Example: `outcome_names[]=os__click.count&outcome_names[]=Sales, Purchase.count` where “Sales, Purchase” is the custom outcomes with a comma in the name. |
|
|
310
393
|
| outcome_time_range | string | Optional Time range for the returned data. The values can be `1h` (for the last 1 hour data), `1d` (for the last 1 day data), or `1mo` (for the last 1 month data). Default is 1h if the parameter is omitted. |
|
|
@@ -313,5 +396,25 @@ Outcome Data Limitations Outcomes are only accessible for around 30 days before
|
|
|
313
396
|
|
|
314
397
|
**Example**
|
|
315
398
|
```js
|
|
316
|
-
client.getOutcomes(app.id, 'os__click.count,os_session_duration.count,my_outcome.sum');
|
|
399
|
+
const outcomes = await client.getOutcomes(app.id, 'os__click.count,os_session_duration.count,my_outcome.sum');
|
|
317
400
|
```
|
|
401
|
+
|
|
402
|
+
## Author
|
|
403
|
+
|
|
404
|
+
* Website: https://onesignal.com
|
|
405
|
+
* Twitter: [@onesignal](https://twitter.com/onesignal)
|
|
406
|
+
* Github: [@OneSignal](https://github.com/OneSignal)
|
|
407
|
+
|
|
408
|
+
## 🤝 Contributing
|
|
409
|
+
|
|
410
|
+
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/OneSignal/node-onesignal/issues).
|
|
411
|
+
|
|
412
|
+
## Show your support
|
|
413
|
+
|
|
414
|
+
Give a ⭐️ if this project helped you!
|
|
415
|
+
|
|
416
|
+
## 📝 License
|
|
417
|
+
|
|
418
|
+
Copyright © 2022 [OneSignal](https://github.com/OneSignal).
|
|
419
|
+
|
|
420
|
+
This project is [MIT](https://github.com/OneSignal/node-onesignal/blob/main/LICENSE) licensed.
|