Skip to content

Commit 7146cea

Browse files
onesignal-deployOneSignal
and
OneSignal
authored
Update CPP API (#13)
Co-authored-by: OneSignal <[email protected]>
1 parent ef5c4fc commit 7146cea

File tree

162 files changed

+10006
-495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+10006
-495
lines changed

.github/workflows/Zapier.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
# Triggers the workflow on push or pull request events but only for the "main" branch
88
issues:
99
types: [closed]
10-
10+
1111
permissions:
1212
issues: read
1313

@@ -31,4 +31,4 @@ jobs:
3131
--header 'Accept: application/json' \
3232
--data-raw '{
3333
"task_name" : "$ISSUE_TITLE"
34-
}'
34+
}'

README.md

+153-10
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ A powerful way to send personalized messages at scale and build effective custom
55
## Overview
66
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.
77

8-
- API version: 1.0.2
9-
- Package version: 1.0.4
8+
- API version: 1.2.1
9+
- Package version: 2.0.0
1010
- Build package: org.openapitools.codegen.languages.CppRestSdkClientCodegen
1111
For more information, please visit [https://onesignal.com](https://onesignal.com)
1212

@@ -60,6 +60,9 @@ cmake -DCMAKE_CXX_FLAGS="-I/usr/local/include -I/usr/local/Cellar/include -I/usr
6060
make
6161
```
6262

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+
6366
### Build on Windows with Visual Studio (VS2017)
6467

6568
- Right click on folder containing source code
@@ -106,7 +109,9 @@ static DefaultApi * createApi() {
106109

107110
```
108111

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
110115
```cpp
111116
static std::shared_ptr<Notification> createNotification() {
112117
const auto notification = std::make_shared<Notification>();
@@ -275,26 +280,23 @@ const auto api = createApi();
275280
const auto segment = createSegment("<test_segment_name>");
276281

277282
// 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();
280284

281285
sleep(10);
282286

283287
// 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();
286289

287290
// Check the result
288-
CHECK(deleteResponseData->isSuccess());
291+
CHECK(deleteResponse->isSuccess());
289292
```
290293
291294
### Getting an App
292295
```cpp
293296
const auto api = createApi();
294297
295298
// 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();
298300
299301
// Check the result
300302
CHECK(app->getId() == APP_ID);
@@ -349,6 +351,147 @@ api->updateLiveActivity(APP_ID, "activity id example", updateLiveActivityRequest
349351
api->endLiveActivity(APP_ID, "activity id example", "player id example");
350352
```
351353

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+
352495
## Author
353496

354497

include/CppRestOneSignalAPIClient/ApiClient.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 1.0.2
5+
* The version of the OpenAPI document: 1.2.1
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.

include/CppRestOneSignalAPIClient/ApiConfiguration.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 1.0.2
5+
* The version of the OpenAPI document: 1.2.1
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.

include/CppRestOneSignalAPIClient/ApiException.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 1.0.2
5+
* The version of the OpenAPI document: 1.2.1
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.

include/CppRestOneSignalAPIClient/HttpContent.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 1.0.2
5+
* The version of the OpenAPI document: 1.2.1
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.

include/CppRestOneSignalAPIClient/IHttpBody.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 1.0.2
5+
* The version of the OpenAPI document: 1.2.1
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.

include/CppRestOneSignalAPIClient/JsonBody.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 1.0.2
5+
* The version of the OpenAPI document: 1.2.1
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.

include/CppRestOneSignalAPIClient/ModelBase.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 1.0.2
5+
* The version of the OpenAPI document: 1.2.1
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.

include/CppRestOneSignalAPIClient/MultipartFormData.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 1.0.2
5+
* The version of the OpenAPI document: 1.2.1
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.

include/CppRestOneSignalAPIClient/Object.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 1.0.2
5+
* The version of the OpenAPI document: 1.2.1
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.

0 commit comments

Comments
 (0)