@@ -5,8 +5,8 @@ A powerful way to send personalized messages at scale and build effective custom
5
5
## Overview
6
6
This API client was generated by the [ OpenAPI Generator] ( https://openapi-generator.tech ) project. By using the [ OpenAPI spec] ( https://openapis.org ) from a remote server, you can easily generate an API client.
7
7
8
- - API version: 1.0.2
9
- - Package version: 1 .0.4
8
+ - API version: 1.2.1
9
+ - Package version: 2 .0.0
10
10
- Build package: org.openapitools.codegen.languages.CppRestSdkClientCodegen
11
11
For more information, please visit [ https://onesignal.com ] ( https://onesignal.com )
12
12
@@ -60,6 +60,9 @@ cmake -DCMAKE_CXX_FLAGS="-I/usr/local/include -I/usr/local/Cellar/include -I/usr
60
60
make
61
61
```
62
62
63
+ > Note, if you are getting compilation errors related to missing dependencies, and you installed them using different package managers
64
+ like Homebrew, you may need to alter cmake flags with appropriate paths.
65
+
63
66
### Build on Windows with Visual Studio (VS2017)
64
67
65
68
- Right click on folder containing source code
@@ -106,7 +109,9 @@ static DefaultApi * createApi() {
106
109
107
110
```
108
111
109
- ### Creating a notification
112
+ > If you use this library synchronously, make sure you call .get() to wait for the response and wrap it in a try-catch block, so you can see the errors if there are any.
113
+
114
+ ### Creating a notification model
110
115
``` cpp
111
116
static std::shared_ptr<Notification> createNotification () {
112
117
const auto notification = std::make_shared<Notification>();
@@ -275,26 +280,23 @@ const auto api = createApi();
275
280
const auto segment = createSegment(" <test_segment_name>" );
276
281
277
282
// Send a create request
278
- const auto createResponse = api->createSegments (APP_ID, segment);
279
- const auto & createResponseData = createResponse.get();
283
+ const auto createResponse = api->createSegments (APP_ID, segment).get();
280
284
281
285
sleep(10);
282
286
283
287
// Send a delete request
284
- const auto deleteResponse = api->deleteSegments(APP_ID, createResponseData->getId());
285
- const auto & deleteResponseData = deleteResponse.get();
288
+ const auto deleteResponse = api->deleteSegments(APP_ID, createResponse->getId()).get();
286
289
287
290
// Check the result
288
- CHECK(deleteResponseData ->isSuccess());
291
+ CHECK(deleteResponse ->isSuccess());
289
292
```
290
293
291
294
### Getting an App
292
295
```cpp
293
296
const auto api = createApi();
294
297
295
298
// Send a get request
296
- const auto getResponse = api->getApp(APP_ID);
297
- const auto & app = getResponse.get();
299
+ const auto app = api->getApp(APP_ID).get();
298
300
299
301
// Check the result
300
302
CHECK(app->getId() == APP_ID);
@@ -349,6 +351,147 @@ api->updateLiveActivity(APP_ID, "activity id example", updateLiveActivityRequest
349
351
api->endLiveActivity(APP_ID, "activity id example", "player id example");
350
352
```
351
353
354
+ ## Users
355
+ ### Create User
356
+ ``` cpp
357
+ // Creating a user model to be send to the server
358
+ const auto user = std::make_shared<User>();
359
+ const auto aliasLabel = " <ALIAS_LABEL>" ;
360
+ const auto aliasId = " <ALIAS_ID>" ;
361
+ const auto pushToken = " <DEVICE_PUSH_TOKEN>" ;
362
+
363
+ std::map<utility::string_t , utility::string_t > identity = {};
364
+ identity[aliasLabel] = aliasId;
365
+ user->setIdentity (identity);
366
+
367
+ com::onesignal::client::model::SubscriptionObject subscriptionObject;
368
+ subscriptionObject.setToken(pushToken);
369
+ subscriptionObject.setType("iOSPush");
370
+ std::vector< std::shared_ptr<com::onesignal::client::model::SubscriptionObject > > subscriptions = {
371
+ std::make_shared< com::onesignal::client::model::SubscriptionObject > (subscriptionObject)
372
+ };
373
+
374
+ // Sending to to the server
375
+ const auto createUserResponse = api->createUser(APP_ID, user).get();
376
+ ```
377
+
378
+ ### Fetch user by alias
379
+ ```cpp
380
+ const auto fetchUserResponse = api->fetchUser(APP_ID, <ALIAS_LABEL>, <ALIAS_ID>).get();
381
+ ```
382
+
383
+ ### Update user
384
+ ``` cpp
385
+ const auto updateUserRequest = std::make_shared<UpdateUserRequest>();
386
+ const auto propertiesObject = std::make_shared<PropertiesObject>();
387
+ propertiesObject->setLanguage ("fr");
388
+ updateUserRequest->setProperties(propertiesObject);
389
+
390
+ const auto updateUserResponse = api->updateUser(APP_ID, "<ALIAS_LABEL>", "<ALIAS_ID>", updateUserRequest).get();
391
+ CHECK(updateUserResponse->getProperties()->getLanguage() == "fr");
392
+ ```
393
+
394
+ ### Delete user
395
+ ```cpp
396
+ api->deleteUser(APP_ID, "<ALIAS_LABEL>", "<ALIAS_ID>").get();
397
+ ```
398
+
399
+ ### Create subscription
400
+ ``` cpp
401
+ const auto subscriptionObject = std::make_shared<SubscriptionObject>();
402
+ subscriptionObject->setType ("AndroidPush");
403
+ subscriptionObject->setToken("<DEVICE_PUSH_TOKEN>");
404
+ const auto createSubscriptionRequestBody = std::make_shared<CreateSubscriptionRequestBody >();
405
+ createSubscriptionRequestBody->setSubscription(subscriptionObject);
406
+
407
+ const auto createSubscriptionResponse = api->createSubscription(APP_ID, "<ALIAS_LABEL>", "<ALIAS_ID>",
408
+ createSubscriptionRequestBody).get();
409
+
410
+ CHECK(createSubscriptionResponse->getSubscription()->getToken().length() != 0);
411
+ ```
412
+
413
+ ### Update subscription
414
+ ```cpp
415
+ subscriptionObject->setType("AndroidPush");
416
+ subscriptionObject->setToken("<DEVICE_PUSH_TOKEN>");
417
+ const auto updateSubscriptionRequestBody = std::make_shared<UpdateSubscriptionRequestBody>();
418
+ updateSubscriptionRequestBody->setSubscription(subscriptionObject);
419
+
420
+ api->updateSubscription(APP_ID, "<SUBSCRIPTION_ID>", updateSubscriptionRequestBody).get();
421
+ ```
422
+
423
+ ### Delete subscription
424
+ ``` cpp
425
+ api->deleteSubscription (APP_ID, "<SUBSCRIPTION_ID>").get();
426
+ ```
427
+
428
+ ### Fetch aliases by subscription id
429
+ ```cpp
430
+ const auto fetchAliasesResponse = api->fetchAliases(APP_ID, "<SUBSCRIPTION_ID>").get();
431
+ ```
432
+
433
+ ### Fetch aliases by an alias
434
+ ``` cpp
435
+ const auto fetchUserIdentityResponse = api->fetchUserIdentity (APP_ID, "<ALIAS_LABEL>", "<ALIAS_ID>").get();
436
+ ```
437
+
438
+ ### Fetch aliases by subscription id
439
+ ```cpp
440
+ const auto fetchAliasesResponse = api->fetchAliases(APP_ID, "<SUBSCRIPTION_ID>").get();
441
+ ```
442
+
443
+ ### Identify user by subscription id
444
+ Basically means that you want to add an alias to the user using subscription id.
445
+ ``` cpp
446
+ const auto subscriptionId = " <SUBSCRIPTION_ID>" ;
447
+ const auto newAliasLabel = " <NEW_ALIAS_LABEL>" ;
448
+ const auto newAliasId = " <NEW_ALIAS_ID>" ;
449
+ std::map<utility::string_t , utility::string_t > identity = {};
450
+ identity[newAliasLabel] = newAliasId;
451
+ user->setIdentity (identity);
452
+ const auto userIdentityRequestBody = std::make_shared<UserIdentityRequestBody >();
453
+ userIdentityRequestBody->setIdentity(identity);
454
+
455
+ const auto identifyUserBySubscriptionIdResponse =
456
+ api->identifyUserBySubscriptionId(APP_ID, subscriptionId, userIdentityRequestBody).get();
457
+
458
+ CHECK(identifyUserBySubscriptionIdResponse->getIdentity()[ newAliasLabel] == newAliasId);
459
+ ```
460
+
461
+ ### Identify user by an alias
462
+ Basically means that you want to add an alias to the user using another alias.
463
+ ```cpp
464
+ const auto subscriptionId = "<SUBSCRIPTION_ID>";
465
+ const auto newAliasLabel = "<NEW_ALIAS_LABEL>";
466
+ const auto newAliasId = "<NEW_ALIAS_ID>";
467
+ std::map<utility::string_t, utility::string_t> identity = {};
468
+ identity[newAliasLabel] = newAliasId;
469
+ user->setIdentity(identity);
470
+ const auto userIdentityRequestBody = std::make_shared<UserIdentityRequestBody>();
471
+ userIdentityRequestBody->setIdentity(identity);
472
+
473
+ const auto identifyUserBySubscriptionIdResponse =
474
+ api->identifyUserByAlias(APP_ID, "<ALIAS_LABEL>", "<ALIAS_ID>", userIdentityRequestBody).get();
475
+
476
+ CHECK(identifyUserBySubscriptionIdResponse->getIdentity()[newAliasLabel] == newAliasId);
477
+ ```
478
+
479
+ ### Transfers subscription ownership
480
+ ``` cpp
481
+ const auto transferSubscriptionRequestBody = std::make_shared<TransferSubscriptionRequestBody>();
482
+ std::map<utility::string_t , utility::string_t > identity = {};
483
+ identity[" <USER_FROM_ALIAS_LABEL>" ] = " <USER_FROM_ALIAS_ID>" ;
484
+ transferSubscriptionRequestBody->setIdentity (identity);
485
+
486
+ const auto identifyUserByAliasResponse =
487
+ api->transferSubscription(APP_ID, "<USER_TO_SUBSCRIPTION_ID>", transferSubscriptionRequestBody).get();
488
+ ```
489
+
490
+ ### Fetch IAMs
491
+ ```cpp
492
+ api->getEligibleIams(APP_ID, "<SUBSCRIPTION_ID>").get();
493
+ ```
494
+
352
495
## Author
353
496
354
497
0 commit comments