@onesignal/node-onesignal 1.0.0-beta8 → 2.0.0-beta1

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.
Files changed (184) hide show
  1. package/.github/workflows/Zapier.yml +34 -0
  2. package/CHANGELOG.md +15 -0
  3. package/DefaultApi.md +988 -3
  4. package/README.md +152 -24
  5. package/apis/DefaultApi.ts +1339 -98
  6. package/dist/apis/DefaultApi.d.ts +39 -0
  7. package/dist/apis/DefaultApi.js +1490 -408
  8. package/dist/apis/DefaultApi.js.map +1 -1
  9. package/dist/models/BasicNotification.d.ts +4 -0
  10. package/dist/models/BasicNotification.js +12 -0
  11. package/dist/models/BasicNotification.js.map +1 -1
  12. package/dist/models/CreateNotificationSuccessResponse.d.ts +2 -2
  13. package/dist/models/CreateSubscriptionRequestBody.d.ts +19 -0
  14. package/dist/models/CreateSubscriptionRequestBody.js +28 -0
  15. package/dist/models/CreateSubscriptionRequestBody.js.map +1 -0
  16. package/dist/models/CreateUserConflictResponse.d.ts +18 -0
  17. package/dist/models/CreateUserConflictResponse.js +22 -0
  18. package/dist/models/CreateUserConflictResponse.js.map +1 -0
  19. package/dist/models/CreateUserConflictResponseErrorsInner.d.ts +20 -0
  20. package/dist/models/CreateUserConflictResponseErrorsInner.js +34 -0
  21. package/dist/models/CreateUserConflictResponseErrorsInner.js.map +1 -0
  22. package/dist/models/CreateUserConflictResponseErrorsItemsMeta.d.ts +17 -0
  23. package/dist/models/CreateUserConflictResponseErrorsItemsMeta.js +22 -0
  24. package/dist/models/CreateUserConflictResponseErrorsItemsMeta.js.map +1 -0
  25. package/dist/models/IdentifyUserConflictResponse.d.ts +18 -0
  26. package/dist/models/IdentifyUserConflictResponse.js +22 -0
  27. package/dist/models/IdentifyUserConflictResponse.js.map +1 -0
  28. package/dist/models/IdentifyUserConflictResponseErrorsInner.d.ts +18 -0
  29. package/dist/models/IdentifyUserConflictResponseErrorsInner.js +28 -0
  30. package/dist/models/IdentifyUserConflictResponseErrorsInner.js.map +1 -0
  31. package/dist/models/InlineResponse200.d.ts +19 -0
  32. package/dist/models/InlineResponse200.js +22 -0
  33. package/dist/models/InlineResponse200.js.map +1 -0
  34. package/dist/models/InlineResponse2003.d.ts +17 -0
  35. package/dist/models/InlineResponse2003.js +22 -0
  36. package/dist/models/InlineResponse2003.js.map +1 -0
  37. package/dist/models/InlineResponse201.d.ts +18 -0
  38. package/dist/models/InlineResponse201.js +22 -0
  39. package/dist/models/InlineResponse201.js.map +1 -0
  40. package/dist/models/InlineResponse202.d.ts +18 -0
  41. package/dist/models/InlineResponse202.js +22 -0
  42. package/dist/models/InlineResponse202.js.map +1 -0
  43. package/dist/models/Notification.d.ts +4 -0
  44. package/dist/models/Notification.js +12 -0
  45. package/dist/models/Notification.js.map +1 -1
  46. package/dist/models/NotificationTarget.d.ts +4 -0
  47. package/dist/models/NotificationTarget.js +12 -0
  48. package/dist/models/NotificationTarget.js.map +1 -1
  49. package/dist/models/NotificationWithMeta.d.ts +4 -0
  50. package/dist/models/NotificationWithMeta.js +12 -0
  51. package/dist/models/NotificationWithMeta.js.map +1 -1
  52. package/dist/models/ObjectSerializer.d.ts +21 -0
  53. package/dist/models/ObjectSerializer.js +69 -0
  54. package/dist/models/ObjectSerializer.js.map +1 -1
  55. package/dist/models/Player.d.ts +1 -1
  56. package/dist/models/Player.js +1 -1
  57. package/dist/models/Player.js.map +1 -1
  58. package/dist/models/PlayerNotificationTarget.d.ts +4 -0
  59. package/dist/models/PlayerNotificationTarget.js +12 -0
  60. package/dist/models/PlayerNotificationTarget.js.map +1 -1
  61. package/dist/models/PlayerNotificationTargetIncludeAliases.d.ts +17 -0
  62. package/dist/models/PlayerNotificationTargetIncludeAliases.js +22 -0
  63. package/dist/models/PlayerNotificationTargetIncludeAliases.js.map +1 -0
  64. package/dist/models/PropertiesDeltas.d.ts +20 -0
  65. package/dist/models/PropertiesDeltas.js +34 -0
  66. package/dist/models/PropertiesDeltas.js.map +1 -0
  67. package/dist/models/PropertiesObject.d.ts +30 -0
  68. package/dist/models/PropertiesObject.js +82 -0
  69. package/dist/models/PropertiesObject.js.map +1 -0
  70. package/dist/models/Purchase.d.ts +2 -1
  71. package/dist/models/Purchase.js +7 -1
  72. package/dist/models/Purchase.js.map +1 -1
  73. package/dist/models/SubscriptionObject.d.ts +34 -0
  74. package/dist/models/SubscriptionObject.js +118 -0
  75. package/dist/models/SubscriptionObject.js.map +1 -0
  76. package/dist/models/TransferSubscriptionRequestBody.d.ts +19 -0
  77. package/dist/models/TransferSubscriptionRequestBody.js +22 -0
  78. package/dist/models/TransferSubscriptionRequestBody.js.map +1 -0
  79. package/dist/models/UpdateSubscriptionRequestBody.d.ts +18 -0
  80. package/dist/models/UpdateSubscriptionRequestBody.js +22 -0
  81. package/dist/models/UpdateSubscriptionRequestBody.js.map +1 -0
  82. package/dist/models/UpdateUserRequest.d.ts +21 -0
  83. package/dist/models/UpdateUserRequest.js +34 -0
  84. package/dist/models/UpdateUserRequest.js.map +1 -0
  85. package/dist/models/User.d.ts +25 -0
  86. package/dist/models/User.js +40 -0
  87. package/dist/models/User.js.map +1 -0
  88. package/dist/models/UserIdentityRequestBody.d.ts +19 -0
  89. package/dist/models/UserIdentityRequestBody.js +22 -0
  90. package/dist/models/UserIdentityRequestBody.js.map +1 -0
  91. package/dist/models/UserIdentityResponse.d.ts +19 -0
  92. package/dist/models/UserIdentityResponse.js +22 -0
  93. package/dist/models/UserIdentityResponse.js.map +1 -0
  94. package/dist/models/UserSubscriptionOptions.d.ts +17 -0
  95. package/dist/models/UserSubscriptionOptions.js +22 -0
  96. package/dist/models/UserSubscriptionOptions.js.map +1 -0
  97. package/dist/models/all.d.ts +21 -0
  98. package/dist/models/all.js +21 -0
  99. package/dist/models/all.js.map +1 -1
  100. package/dist/types/ObjectParamAPI.d.ts +95 -0
  101. package/dist/types/ObjectParamAPI.js +42 -0
  102. package/dist/types/ObjectParamAPI.js.map +1 -1
  103. package/dist/types/ObservableAPI.d.ts +25 -0
  104. package/dist/types/ObservableAPI.js +383 -47
  105. package/dist/types/ObservableAPI.js.map +1 -1
  106. package/dist/types/PromiseAPI.d.ts +25 -0
  107. package/dist/types/PromiseAPI.js +56 -0
  108. package/dist/types/PromiseAPI.js.map +1 -1
  109. package/models/App.ts +1 -1
  110. package/models/BadRequestError.ts +1 -1
  111. package/models/BasicNotification.ts +17 -1
  112. package/models/BasicNotificationAllOf.ts +1 -1
  113. package/models/BasicNotificationAllOfAndroidBackgroundLayout.ts +1 -1
  114. package/models/BeginLiveActivityRequest.ts +1 -1
  115. package/models/Button.ts +1 -1
  116. package/models/CancelNotificationSuccessResponse.ts +1 -1
  117. package/models/CreateNotificationSuccessResponse.ts +3 -3
  118. package/models/CreatePlayerSuccessResponse.ts +1 -1
  119. package/models/CreateSegmentConflictResponse.ts +1 -1
  120. package/models/CreateSegmentSuccessResponse.ts +1 -1
  121. package/models/CreateSubscriptionRequestBody.ts +39 -0
  122. package/models/CreateUserConflictResponse.ts +32 -0
  123. package/models/CreateUserConflictResponseErrorsInner.ts +46 -0
  124. package/models/CreateUserConflictResponseErrorsItemsMeta.ts +31 -0
  125. package/models/DeletePlayerNotFoundResponse.ts +1 -1
  126. package/models/DeletePlayerSuccessResponse.ts +1 -1
  127. package/models/DeleteSegmentNotFoundResponse.ts +1 -1
  128. package/models/DeleteSegmentSuccessResponse.ts +1 -1
  129. package/models/DeliveryData.ts +1 -1
  130. package/models/ExportPlayersRequestBody.ts +1 -1
  131. package/models/ExportPlayersSuccessResponse.ts +1 -1
  132. package/models/Filter.ts +1 -1
  133. package/models/FilterExpressions.ts +1 -1
  134. package/models/GetNotificationRequestBody.ts +1 -1
  135. package/models/IdentifyUserConflictResponse.ts +32 -0
  136. package/models/IdentifyUserConflictResponseErrorsInner.ts +38 -0
  137. package/models/InlineResponse200.ts +31 -0
  138. package/models/InlineResponse2003.ts +31 -0
  139. package/models/InlineResponse201.ts +32 -0
  140. package/models/InlineResponse202.ts +32 -0
  141. package/models/InvalidIdentifierError.ts +1 -1
  142. package/models/Notification.ts +17 -1
  143. package/models/Notification200Errors.ts +1 -1
  144. package/models/NotificationAllOf.ts +1 -1
  145. package/models/NotificationHistorySuccessResponse.ts +1 -1
  146. package/models/NotificationSlice.ts +1 -1
  147. package/models/NotificationTarget.ts +19 -1
  148. package/models/NotificationWithMeta.ts +17 -1
  149. package/models/NotificationWithMetaAllOf.ts +1 -1
  150. package/models/ObjectSerializer.ts +74 -5
  151. package/models/Operator.ts +1 -1
  152. package/models/OutcomeData.ts +1 -1
  153. package/models/OutcomesData.ts +1 -1
  154. package/models/PlatformDeliveryData.ts +1 -1
  155. package/models/PlatformDeliveryDataEmailAllOf.ts +1 -1
  156. package/models/PlatformDeliveryDataSmsAllOf.ts +1 -1
  157. package/models/Player.ts +3 -3
  158. package/models/PlayerNotificationTarget.ts +19 -1
  159. package/models/PlayerNotificationTargetIncludeAliases.ts +31 -0
  160. package/models/PlayerSlice.ts +1 -1
  161. package/models/PropertiesDeltas.ts +46 -0
  162. package/models/PropertiesObject.ts +102 -0
  163. package/models/Purchase.ts +10 -3
  164. package/models/Segment.ts +1 -1
  165. package/models/SegmentNotificationTarget.ts +1 -1
  166. package/models/StringMap.ts +1 -1
  167. package/models/SubscriptionObject.ts +146 -0
  168. package/models/TransferSubscriptionRequestBody.ts +31 -0
  169. package/models/UpdateLiveActivityRequest.ts +1 -1
  170. package/models/UpdateLiveActivitySuccessResponse.ts +1 -1
  171. package/models/UpdatePlayerSuccessResponse.ts +1 -1
  172. package/models/UpdatePlayerTagsRequestBody.ts +1 -1
  173. package/models/UpdatePlayerTagsSuccessResponse.ts +1 -1
  174. package/models/UpdateSubscriptionRequestBody.ts +32 -0
  175. package/models/UpdateUserRequest.ts +47 -0
  176. package/models/User.ts +55 -0
  177. package/models/UserIdentityRequestBody.ts +31 -0
  178. package/models/UserIdentityResponse.ts +31 -0
  179. package/models/UserSubscriptionOptions.ts +31 -0
  180. package/models/all.ts +21 -0
  181. package/package.json +2 -2
  182. package/types/ObjectParamAPI.ts +427 -0
  183. package/types/ObservableAPI.ts +371 -0
  184. package/types/PromiseAPI.ts +175 -0
package/README.md CHANGED
@@ -68,7 +68,7 @@ const configuration = OneSignal.createConfiguration({
68
68
  const client = new OneSignal.DefaultApi(configuration);
69
69
  ```
70
70
 
71
- #### Advanced Usage: Creating a brand new app
71
+ #### Advanced Usage: Creating a brand-new app
72
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
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.
74
74
 
@@ -86,6 +86,8 @@ const client = new OneSignal.DefaultApi(configuration);
86
86
  ---
87
87
  ## API Reference
88
88
 
89
+ > See the full list of [API Endpoints](DefaultApi.MD).
90
+
89
91
  To make stateful changes requests should take on the following pattern:
90
92
  1. create or get an object
91
93
  2. make changes to that object
@@ -96,28 +98,6 @@ Examples of important OneSignal objects include `App`, `Notification`, `Player`,
96
98
  For example, see the section below on creating an app. First an app object is created via the instantiation of the `App`
97
99
  class. Then, the app instance is modified directly. Finally, we use the `client` to create the app via a remote request.
98
100
 
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 |
120
-
121
101
  ### Creating an app
122
102
  Creates a new OneSignal app.
123
103
 
@@ -440,6 +420,154 @@ const subscriptionId = '<subscription_id>'; // player id
440
420
  await api.endLiveActivity('<app_id>', '<activity_id>', subscriptionId);
441
421
  ```
442
422
 
423
+ ### Subscription types
424
+ * iOSPush
425
+ * AndroidPush
426
+ * FireOSPush
427
+ * ChromeExtensionPush
428
+ * ChromePush
429
+ * WindowsPush
430
+ * SafariLegacyPush
431
+ * FirefoxPush
432
+ * macOSPush
433
+ * HuaweiPush
434
+ * SafariPush
435
+ * Email
436
+ * SMS
437
+
438
+ ## Users
439
+ ### Creating a OneSignal User
440
+ ```js
441
+ const user = new OneSignal.User();
442
+
443
+ const aliasLabel = '<alias_label>';
444
+ const aliasId = '<alias_id>';
445
+ const subscriptionToken = '<subscription_token>';
446
+
447
+ user.identity = {
448
+ [aliasLabel]: aliasId,
449
+ };
450
+
451
+ user.subscriptions = [
452
+ {
453
+ type: "iOSPush",
454
+ token: subscriptionToken,
455
+ }
456
+ ];
457
+
458
+ const createdUser = await api.createUser('<app_id>', user);
459
+ assert(createdUser.identity!['onesignal_id'] != null);
460
+ ```
461
+
462
+ ### Getting a user by `onesignal_id`
463
+ ```js
464
+ const oneisgnalAliasLabel = "onesignal_id";
465
+ const onesignalAliasId = createdUser.identity!['onesignal_id'];
466
+
467
+ const fetchedUser = await api.fetchUser('<app_id>', oneisgnalAliasLabel, onesignalAliasId);
468
+ ```
469
+
470
+ ### Getting a user by an alias
471
+ ```js
472
+ const fetchedUser = await api.fetchUser('<app_id>', alias_label, alias_id);
473
+ ```
474
+
475
+ ### Updating a user
476
+ ```js
477
+ const updateUserRequest: UpdateUserRequest = {
478
+ properties: {
479
+ language: 'fr'
480
+ }
481
+ };
482
+
483
+ const updatedUser = await api.updateUser('<app_id>', aliasLabel, aliasId, updateUserRequest);
484
+ ```
485
+
486
+ ### Deleting a user
487
+ ```js
488
+ await api.deleteUser('<app_id>', aliasLabel, aliasId);
489
+ ```
490
+
491
+ ## Subscriptions
492
+ ### Creating a subscription for existing user
493
+ ```js
494
+ const createSubscriptionRequestBody: CreateSubscriptionRequestBody = {
495
+ subscription: {
496
+ type: "AndroidPush",
497
+ token: '<subscription_token>',
498
+ }
499
+ };
500
+
501
+ const response = await api.createSubscription('<app_id>', '<alias_label>', '<alias_id>', createSubscriptionRequestBody);
502
+ ```
503
+
504
+ ### Updating a subscription
505
+ ```js
506
+ const updateSubscriptionRequestBody: UpdateSubscriptionRequestBody = {
507
+ subscription: {
508
+ type: "iOSPush",
509
+ token: '<new-subscription-token>',
510
+ }
511
+ };
512
+
513
+ await api.updateSubscription('<app_id>', '<existing_subscription_id>', updateSubscriptionRequestBody);
514
+ ```
515
+
516
+ ### Deleting a subscription
517
+ ```js
518
+ await api.deleteSubscription('<app_id>', '<subscription_id>');
519
+ ```
520
+
521
+ ### Transfer subscription ownership
522
+ Transfers the subscription from one user to another.
523
+ ```js
524
+ // Setting the user for transfering the subscription to. User is identyfied by an IdentityObject.
525
+ const transferSubscriptionRequestBody: TransferSubscriptionRequestBody = {
526
+ identity: otherUserIdentityObject
527
+ };
528
+
529
+ const transferResponse = await api.transferSubscription('<app_id>', '<subscription_id>', transferSubscriptionRequestBody);
530
+ ```
531
+
532
+ ## Aliases
533
+ ### Fetching aliases for a user
534
+ ```js
535
+ const fetchResponse = await api.fetchAliases('<app_id>', '<subscription_id>');
536
+ ```
537
+
538
+ ### Fetching user identity
539
+ ```js
540
+ const fetchResponse = await api.fetchUserIdentity('<app_id>', '<alias_label>', '<alias_id>');
541
+ ```
542
+ ### Identifying user by alias
543
+ ```js
544
+ const userIdentityRequestBody: UserIdentityRequestBody = {
545
+ identity: {
546
+ ['<new_alias_label>']: '<new_alias_id>'
547
+ }
548
+ };
549
+
550
+ const identifyResponse = await api.identifyUserByAlias('<app_id>',
551
+ '<existing_alias_label>',
552
+ '<existing_alias_id>',
553
+ userIdentityRequestBody);
554
+ ```
555
+
556
+ ### Identifying user by subscription id
557
+ ```js
558
+ const userIdentityRequestBody: UserIdentityRequestBody = {
559
+ identity: {
560
+ ['<new_alias_label>']: '<new_alias_id>'
561
+ }
562
+ };
563
+
564
+ const identifyResponse = await api.identifyUserBySubscriptionId('<app_id>', '<existing_subscription_id>', userIdentityRequestBody);
565
+ ```
566
+
567
+ ### Deleting an alias
568
+ ```js
569
+ await api.deleteAlias('<app_id>', '<alias_label>', '<alias_id>', '<alias_label_to_delete>');
570
+ ```
443
571
  ## Author
444
572
 
445
573
  * Website: https://onesignal.com
@@ -456,6 +584,6 @@ Give a ⭐️ if this project helped you!
456
584
 
457
585
  ## 📝 License
458
586
 
459
- Copyright © 2022 [OneSignal](https://github.com/OneSignal).
587
+ Copyright © 2023 [OneSignal](https://github.com/OneSignal).
460
588
 
461
589
  This project is [MIT](https://github.com/OneSignal/node-onesignal/blob/main/LICENSE) licensed.