Skip to content

Commit 25fbe76

Browse files
authored
Merge pull request #31 from OneSignal/api
Dependency Update
2 parents dfd2b46 + 937b421 commit 25fbe76

19 files changed

+135
-516
lines changed

.github/workflows/npm_deploy.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: NPM Publish
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: 19
16+
- name: Publish package
17+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
18+
uses: JS-DevTools/npm-publish@v1
19+
with:
20+
token: ${{ secrets.NPM }}

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
## January 2022
5+
6+
### `1.0.0-beta4` - 02/25/2022
7+
#### Added
8+
- .npmignore file
9+
10+
#### Fixed
11+
- Missing `dist` directory since npm was ignoring it due to lack of .npmignore
12+
13+
### `1.0.0-beta5` - 10/1/2022
14+
#### Api Changes
15+
- Configuration setup has been simplified and streamlined. Now it looks like this:
16+
```js
17+
const configuration = OneSignal.createConfiguration({
18+
userKey: USER_KEY_TOKEN,
19+
appKey: APP_KEY_TOKEN,
20+
});
21+
```
22+
- Player ID is no longer required when creating a player
23+
24+
#### Fixed
25+
- Bug in the OpenAPI schema not allowing users to use filters when creating a notification.
26+
- Bug in the OpenAPI schema not allowing to set the notification name.

README.md

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,25 @@ const udpateAppResponse = await client.updateApp('<existing_app_id>', app);
163163
### Creating a notification
164164
Sends a notification to your users.
165165

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+
166185
**Example**
167186
```js
168187
const notification = new OneSignal.Notification();
@@ -176,6 +195,17 @@ notification.contents = {
176195
notification.headings = {
177196
en: "Gig'em Ags"
178197
}
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+
179209
const notification = await client.createNotification(notification);
180210
```
181211

@@ -313,19 +343,18 @@ const updatePlayerResponse = await client.updatePlayer('<player id>', player);
313343

314344
### Updating player tags
315345
Update an existing device's tags in one of your OneSignal apps using the External User ID.
316-
#### ⚠️ Android SDK Data Synchronization
317-
Tags added through the Android SDK tagging methods may not update if using the API to change or update the same tag.
318-
For example, if you use SDK method sendTag("key", "value1") then update the tag value to "value2" with this API endpoint.
319-
You will not be able to set the value back to "value1" through the SDK, you will need to change it to something different
320-
through the SDK to be reset.
321346

322-
Recommendations if using this Endpoint on Android Mobile Apps:
323-
1. Do not use the same tag keys for SDK and API updates
324-
2. If you want to use the same key for both SDK and API updates, call the SDK getTags method first to update the
325-
device's tags.
347+
```js
348+
const playerToUpdate = new OneSignal.Player();
326349

327-
⚠️ This is only applicable on the Android Mobile App SDKs.
350+
player.app_id = APP_ID;
351+
player.device_type = 1;
328352

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+
```
329358
#### Deleting Tags
330359
To delete a tag, include its key and set its value to blank (""). Omitting a key/value will not delete it.
331360

models/App.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { HttpFile } from '../http/http';
1010

1111
export class App {
12-
'id': string;
12+
'id'?: string;
1313
/**
1414
* The name of your app, as displayed on your apps list on the dashboard. This can be renamed.
1515
*/

models/BasicNotification.ts

Lines changed: 8 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { BasicNotificationAllOf } from './BasicNotificationAllOf';
1010
import { BasicNotificationAllOfAndroidBackgroundLayout } from './BasicNotificationAllOfAndroidBackgroundLayout';
1111
import { Button } from './Button';
12+
import { Filter } from './Filter';
1213
import { NotificationTarget } from './NotificationTarget';
1314
import { StringMap } from './StringMap';
1415
import { HttpFile } from '../http/http';
@@ -23,54 +24,6 @@ export class BasicNotification {
2324
*/
2425
'excluded_segments'?: Array<string>;
2526
/**
26-
* relation = \">\" or \"<\" hours_ago = number of hours before or after the users last session. Example: \"1.1\"
27-
*/
28-
'last_session'?: string;
29-
/**
30-
* relation = \">\" or \"<\" hours_ago = number of hours before or after the users first session. Example: \"1.1\"
31-
*/
32-
'first_session'?: string;
33-
/**
34-
* relation = \">\", \"<\", \"=\" or \"!=\" value = number sessions. Example: \"1\"
35-
*/
36-
'session_count'?: string;
37-
/**
38-
* relation = \">\", \"<\", \"=\" or \"!=\" value = Time in seconds the user has been in your app. Example: \"3600\"
39-
*/
40-
'session_time'?: string;
41-
/**
42-
* relation = \">\", \"<\", or \"=\" value = Amount in USD a user has spent on IAP (In App Purchases). Example: \"0.99\"
43-
*/
44-
'amount_spent'?: string;
45-
/**
46-
* relation = \">\", \"<\" or \"=\" key = SKU purchased in your app as an IAP (In App Purchases). Example: \"com.domain.100coinpack\" value = value of SKU to compare to. Example: \"0.99\"
47-
*/
48-
'bought_sku'?: string;
49-
/**
50-
* relation = \">\", \"<\", \"=\", \"!=\", \"exists\", \"not_exists\", \"time_elapsed_gt\" (paid plan only) or \"time_elapsed_lt\" (paid plan only) See Time Operators key = Tag key to compare. value = Tag value to compare. Not required for \"exists\" or \"not_exists\". Example: See Formatting Filters
51-
*/
52-
'tag'?: string;
53-
/**
54-
* relation = \"=\" or \"!=\" value = 2 character language code. Example: \"en\". For a list of all language codes see Language & Localization.
55-
*/
56-
'language'?: string;
57-
/**
58-
* relation = \">\", \"<\", \"=\" or \"!=\" value = app version. Example: \"1.0.0\"
59-
*/
60-
'app_version'?: string;
61-
/**
62-
* radius = in meters lat = latitude long = longitude
63-
*/
64-
'location'?: string;
65-
/**
66-
* value = email address Only for sending Push Notifications Use this for targeting push subscribers associated with an email set with all SDK setEmail methods To send emails to specific email addresses use include_email_tokens parameter
67-
*/
68-
'email'?: string;
69-
/**
70-
* relation = \"=\" value = 2-digit Country code Example: \"field\": \"country\", \"relation\": \"=\", \"value\", \"US\"
71-
*/
72-
'country'?: string;
73-
/**
7427
* Specific playerids to send your notification to. _Does not require API Auth Key. Do not combine with other targeting parameters. Not compatible with any other targeting parameters. Example: [\"1dd608f2-c6a1-11e3-851d-000c2940e62c\"] Limit of 2,000 entries per REST API call
7528
*/
7629
'include_player_ids'?: Array<string>;
@@ -441,6 +394,7 @@ export class BasicNotification {
441394
* Channel: SMS URLs for the media files to be attached to the SMS content. Limit: 10 media urls with a total max. size of 5MBs.
442395
*/
443396
'sms_media_urls'?: Array<string>;
397+
'filters'?: Array<Filter>;
444398

445399
static readonly discriminator: string | undefined = undefined;
446400

@@ -457,78 +411,6 @@ export class BasicNotification {
457411
"type": "Array<string>",
458412
"format": ""
459413
},
460-
{
461-
"name": "last_session",
462-
"baseName": "last_session",
463-
"type": "string",
464-
"format": ""
465-
},
466-
{
467-
"name": "first_session",
468-
"baseName": "first_session",
469-
"type": "string",
470-
"format": ""
471-
},
472-
{
473-
"name": "session_count",
474-
"baseName": "session_count",
475-
"type": "string",
476-
"format": ""
477-
},
478-
{
479-
"name": "session_time",
480-
"baseName": "session_time",
481-
"type": "string",
482-
"format": ""
483-
},
484-
{
485-
"name": "amount_spent",
486-
"baseName": "amount_spent",
487-
"type": "string",
488-
"format": ""
489-
},
490-
{
491-
"name": "bought_sku",
492-
"baseName": "bought_sku",
493-
"type": "string",
494-
"format": ""
495-
},
496-
{
497-
"name": "tag",
498-
"baseName": "tag",
499-
"type": "string",
500-
"format": ""
501-
},
502-
{
503-
"name": "language",
504-
"baseName": "language",
505-
"type": "string",
506-
"format": ""
507-
},
508-
{
509-
"name": "app_version",
510-
"baseName": "app_version",
511-
"type": "string",
512-
"format": ""
513-
},
514-
{
515-
"name": "location",
516-
"baseName": "location",
517-
"type": "string",
518-
"format": ""
519-
},
520-
{
521-
"name": "email",
522-
"baseName": "email",
523-
"type": "string",
524-
"format": ""
525-
},
526-
{
527-
"name": "country",
528-
"baseName": "country",
529-
"type": "string",
530-
"format": ""
531-
},
532414
{
533415
"name": "include_player_ids",
534416
"baseName": "include_player_ids",
@@ -1116,6 +998,12 @@ export class BasicNotification {
1116998
"baseName": "sms_media_urls",
1117999
"type": "Array<string>",
11181000
"format": ""
1001+
},
1002+
{
1003+
"name": "filters",
1004+
"baseName": "filters",
1005+
"type": "Array<Filter>",
1006+
"format": ""
11191007
} ];
11201008

11211009
static getAttributeTypeMap() {

models/BasicNotificationAllOf.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { BasicNotificationAllOfAndroidBackgroundLayout } from './BasicNotificationAllOfAndroidBackgroundLayout';
1010
import { Button } from './Button';
11+
import { Filter } from './Filter';
1112
import { StringMap } from './StringMap';
1213
import { HttpFile } from '../http/http';
1314

@@ -343,6 +344,7 @@ export class BasicNotificationAllOf {
343344
* Channel: SMS URLs for the media files to be attached to the SMS content. Limit: 10 media urls with a total max. size of 5MBs.
344345
*/
345346
'sms_media_urls'?: Array<string>;
347+
'filters'?: Array<Filter>;
346348

347349
static readonly discriminator: string | undefined = undefined;
348350

@@ -874,6 +876,12 @@ export class BasicNotificationAllOf {
874876
"baseName": "sms_media_urls",
875877
"type": "Array<string>",
876878
"format": ""
879+
},
880+
{
881+
"name": "filters",
882+
"baseName": "filters",
883+
"type": "Array<Filter>",
884+
"format": ""
877885
} ];
878886

879887
static getAttributeTypeMap() {

models/Filter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class Filter {
1818
*/
1919
'key'?: string;
2020
/**
21-
* Constant value to use as the second operand in the filter expression. This value is *required* when the relation operator is a binary operator.
21+
* Constant value to use as the second operand in the filter expression. This value is *required* when the relation operator is a binary operator.
2222
*/
2323
'value'?: string;
2424
/**
@@ -63,5 +63,5 @@ export class Filter {
6363
}
6464

6565

66-
export type FilterRelationEnum = "&gt;" | "&lt;" | "&#x3D;" | "!&#x3D;" | "exists" | "not_exists" | "time_elapsed_gt" | "time_elapsed_lt" ;
66+
export type FilterRelationEnum = ">" | "<" | "=" | "!=" | "exists" | "not_exists" | "time_elapsed_gt" | "time_elapsed_lt" ;
6767

models/FilterExpressions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class FilterExpressions {
2020
*/
2121
'key'?: string;
2222
/**
23-
* Constant value to use as the second operand in the filter expression. This value is *required* when the relation operator is a binary operator.
23+
* Constant value to use as the second operand in the filter expression. This value is *required* when the relation operator is a binary operator.
2424
*/
2525
'value'?: string;
2626
/**
@@ -75,6 +75,6 @@ export class FilterExpressions {
7575
}
7676

7777

78-
export type FilterExpressionsRelationEnum = "&gt;" | "&lt;" | "&#x3D;" | "!&#x3D;" | "exists" | "not_exists" | "time_elapsed_gt" | "time_elapsed_lt" ;
78+
export type FilterExpressionsRelationEnum = ">" | "<" | "=" | "!=" | "exists" | "not_exists" | "time_elapsed_gt" | "time_elapsed_lt" ;
7979
export type FilterExpressionsOperatorEnum = "OR" | "AND" ;
8080

0 commit comments

Comments
 (0)