@onesignal/node-onesignal
Version:
OpenAPI client for @onesignal/node-onesignal
1,074 lines (827 loc) • 161 kB
text/typescript
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http';
import * as FormData from "form-data";
import { URLSearchParams } from 'url';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {canConsumeForm, isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { App } from '../models/App';
import { CreateNotificationSuccessResponse } from '../models/CreateNotificationSuccessResponse';
import { CreateSegmentConflictResponse } from '../models/CreateSegmentConflictResponse';
import { CreateSegmentSuccessResponse } from '../models/CreateSegmentSuccessResponse';
import { CreateUserConflictResponse } from '../models/CreateUserConflictResponse';
import { ExportEventsSuccessResponse } from '../models/ExportEventsSuccessResponse';
import { ExportSubscriptionsRequestBody } from '../models/ExportSubscriptionsRequestBody';
import { ExportSubscriptionsSuccessResponse } from '../models/ExportSubscriptionsSuccessResponse';
import { GenericError } from '../models/GenericError';
import { GenericSuccessBoolResponse } from '../models/GenericSuccessBoolResponse';
import { GetNotificationHistoryRequestBody } from '../models/GetNotificationHistoryRequestBody';
import { GetSegmentsSuccessResponse } from '../models/GetSegmentsSuccessResponse';
import { Notification } from '../models/Notification';
import { NotificationHistorySuccessResponse } from '../models/NotificationHistorySuccessResponse';
import { NotificationSlice } from '../models/NotificationSlice';
import { NotificationWithMeta } from '../models/NotificationWithMeta';
import { OutcomesData } from '../models/OutcomesData';
import { PropertiesBody } from '../models/PropertiesBody';
import { RateLimitError } from '../models/RateLimitError';
import { Segment } from '../models/Segment';
import { SubscriptionBody } from '../models/SubscriptionBody';
import { TransferSubscriptionRequestBody } from '../models/TransferSubscriptionRequestBody';
import { UpdateLiveActivityRequest } from '../models/UpdateLiveActivityRequest';
import { UpdateLiveActivitySuccessResponse } from '../models/UpdateLiveActivitySuccessResponse';
import { UpdateUserRequest } from '../models/UpdateUserRequest';
import { User } from '../models/User';
import { UserIdentityBody } from '../models/UserIdentityBody';
/**
* no description
*/
export class DefaultApiRequestFactory extends BaseAPIRequestFactory {
/**
* Used to stop a scheduled or currently outgoing notification
* Stop a scheduled or currently outgoing notification
* @param appId
* @param notificationId
*/
public async cancelNotification(appId: string, notificationId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "cancelNotification", "appId");
}
// verify required parameter 'notificationId' is not null or undefined
if (notificationId === null || notificationId === undefined) {
throw new RequiredError("DefaultApi", "cancelNotification", "notificationId");
}
// Path Params
const localVarPath = '/notifications/{notification_id}'
.replace('{' + 'notification_id' + '}', encodeURIComponent(String(notificationId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Query Params
if (appId !== undefined) {
requestContext.setQueryParam("app_id", ObjectSerializer.serialize(appId, "string", ""));
}
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Upserts one or more Aliases to an existing User identified by (:alias_label, :alias_id).
* @param appId
* @param aliasLabel
* @param aliasId
* @param userIdentityBody
*/
public async createAlias(appId: string, aliasLabel: string, aliasId: string, userIdentityBody: UserIdentityBody, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "createAlias", "appId");
}
// verify required parameter 'aliasLabel' is not null or undefined
if (aliasLabel === null || aliasLabel === undefined) {
throw new RequiredError("DefaultApi", "createAlias", "aliasLabel");
}
// verify required parameter 'aliasId' is not null or undefined
if (aliasId === null || aliasId === undefined) {
throw new RequiredError("DefaultApi", "createAlias", "aliasId");
}
// verify required parameter 'userIdentityBody' is not null or undefined
if (userIdentityBody === null || userIdentityBody === undefined) {
throw new RequiredError("DefaultApi", "createAlias", "userIdentityBody");
}
// Path Params
const localVarPath = '/apps/{app_id}/users/by/{alias_label}/{alias_id}/identity'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)))
.replace('{' + 'alias_label' + '}', encodeURIComponent(String(aliasLabel)))
.replace('{' + 'alias_id' + '}', encodeURIComponent(String(aliasId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PATCH);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(userIdentityBody, "UserIdentityBody", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Upserts one or more Aliases for the User identified by :subscription_id.
* @param appId
* @param subscriptionId
* @param userIdentityBody
*/
public async createAliasBySubscription(appId: string, subscriptionId: string, userIdentityBody: UserIdentityBody, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "createAliasBySubscription", "appId");
}
// verify required parameter 'subscriptionId' is not null or undefined
if (subscriptionId === null || subscriptionId === undefined) {
throw new RequiredError("DefaultApi", "createAliasBySubscription", "subscriptionId");
}
// verify required parameter 'userIdentityBody' is not null or undefined
if (userIdentityBody === null || userIdentityBody === undefined) {
throw new RequiredError("DefaultApi", "createAliasBySubscription", "userIdentityBody");
}
// Path Params
const localVarPath = '/apps/{app_id}/subscriptions/{subscription_id}/user/identity'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)))
.replace('{' + 'subscription_id' + '}', encodeURIComponent(String(subscriptionId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PATCH);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(userIdentityBody, "UserIdentityBody", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Creates a new OneSignal app
* Create an app
* @param app
*/
public async createApp(app: App, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'app' is not null or undefined
if (app === null || app === undefined) {
throw new RequiredError("DefaultApi", "createApp", "app");
}
// Path Params
const localVarPath = '/apps';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(app, "App", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["organization_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Sends notifications to your users
* Create notification
* @param notification
*/
public async createNotification(notification: Notification, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'notification' is not null or undefined
if (notification === null || notification === undefined) {
throw new RequiredError("DefaultApi", "createNotification", "notification");
}
// Path Params
const localVarPath = '/notifications';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(notification, "Notification", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Create a segment visible and usable in the dashboard and API - Required: OneSignal Paid Plan The Create Segment method is used when you want your server to programmatically create a segment instead of using the OneSignal Dashboard UI. Just like creating Segments from the dashboard you can pass in filters with multiple \"AND\" or \"OR\" operator\'s. 🚧 Does Not Update Segments This endpoint will only create segments, it does not edit or update currently created Segments. You will need to use the Delete Segment endpoint and re-create it with this endpoint to edit.
* Create Segment
* @param appId The OneSignal App ID for your app. Available in Keys & IDs.
* @param segment
*/
public async createSegment(appId: string, segment?: Segment, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "createSegment", "appId");
}
// Path Params
const localVarPath = '/apps/{app_id}/segments'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(segment, "Segment", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Creates a new Subscription under the User provided. Useful to add email addresses and SMS numbers to the User.
* @param appId
* @param aliasLabel
* @param aliasId
* @param subscriptionBody
*/
public async createSubscription(appId: string, aliasLabel: string, aliasId: string, subscriptionBody: SubscriptionBody, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "createSubscription", "appId");
}
// verify required parameter 'aliasLabel' is not null or undefined
if (aliasLabel === null || aliasLabel === undefined) {
throw new RequiredError("DefaultApi", "createSubscription", "aliasLabel");
}
// verify required parameter 'aliasId' is not null or undefined
if (aliasId === null || aliasId === undefined) {
throw new RequiredError("DefaultApi", "createSubscription", "aliasId");
}
// verify required parameter 'subscriptionBody' is not null or undefined
if (subscriptionBody === null || subscriptionBody === undefined) {
throw new RequiredError("DefaultApi", "createSubscription", "subscriptionBody");
}
// Path Params
const localVarPath = '/apps/{app_id}/users/by/{alias_label}/{alias_id}/subscriptions'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)))
.replace('{' + 'alias_label' + '}', encodeURIComponent(String(aliasLabel)))
.replace('{' + 'alias_id' + '}', encodeURIComponent(String(aliasId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(subscriptionBody, "SubscriptionBody", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Creates a User, optionally Subscriptions owned by the User as well as Aliases. Aliases provided in the payload will be used to look up an existing User.
* @param appId
* @param user
*/
public async createUser(appId: string, user: User, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "createUser", "appId");
}
// verify required parameter 'user' is not null or undefined
if (user === null || user === undefined) {
throw new RequiredError("DefaultApi", "createUser", "user");
}
// Path Params
const localVarPath = '/apps/{app_id}/users'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(user, "User", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Deletes an alias by alias label
* @param appId
* @param aliasLabel
* @param aliasId
* @param aliasLabelToDelete
*/
public async deleteAlias(appId: string, aliasLabel: string, aliasId: string, aliasLabelToDelete: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "deleteAlias", "appId");
}
// verify required parameter 'aliasLabel' is not null or undefined
if (aliasLabel === null || aliasLabel === undefined) {
throw new RequiredError("DefaultApi", "deleteAlias", "aliasLabel");
}
// verify required parameter 'aliasId' is not null or undefined
if (aliasId === null || aliasId === undefined) {
throw new RequiredError("DefaultApi", "deleteAlias", "aliasId");
}
// verify required parameter 'aliasLabelToDelete' is not null or undefined
if (aliasLabelToDelete === null || aliasLabelToDelete === undefined) {
throw new RequiredError("DefaultApi", "deleteAlias", "aliasLabelToDelete");
}
// Path Params
const localVarPath = '/apps/{app_id}/users/by/{alias_label}/{alias_id}/identity/{alias_label_to_delete}'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)))
.replace('{' + 'alias_label' + '}', encodeURIComponent(String(aliasLabel)))
.replace('{' + 'alias_id' + '}', encodeURIComponent(String(aliasId)))
.replace('{' + 'alias_label_to_delete' + '}', encodeURIComponent(String(aliasLabelToDelete)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Delete a segment (not user devices) - Required: OneSignal Paid Plan You can delete a segment under your app by calling this API. You must provide an API key in the Authorization header that has admin access on the app. The segment_id can be found in the URL of the segment when viewing it in the dashboard.
* Delete Segment
* @param appId The OneSignal App ID for your app. Available in Keys & IDs.
* @param segmentId The segment_id can be found in the URL of the segment when viewing it in the dashboard.
*/
public async deleteSegment(appId: string, segmentId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "deleteSegment", "appId");
}
// verify required parameter 'segmentId' is not null or undefined
if (segmentId === null || segmentId === undefined) {
throw new RequiredError("DefaultApi", "deleteSegment", "segmentId");
}
// Path Params
const localVarPath = '/apps/{app_id}/segments/{segment_id}'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)))
.replace('{' + 'segment_id' + '}', encodeURIComponent(String(segmentId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Deletes the Subscription.
* @param appId
* @param subscriptionId
*/
public async deleteSubscription(appId: string, subscriptionId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "deleteSubscription", "appId");
}
// verify required parameter 'subscriptionId' is not null or undefined
if (subscriptionId === null || subscriptionId === undefined) {
throw new RequiredError("DefaultApi", "deleteSubscription", "subscriptionId");
}
// Path Params
const localVarPath = '/apps/{app_id}/subscriptions/{subscription_id}'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)))
.replace('{' + 'subscription_id' + '}', encodeURIComponent(String(subscriptionId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Removes the User identified by (:alias_label, :alias_id), and all Subscriptions and Aliases
* @param appId
* @param aliasLabel
* @param aliasId
*/
public async deleteUser(appId: string, aliasLabel: string, aliasId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "deleteUser", "appId");
}
// verify required parameter 'aliasLabel' is not null or undefined
if (aliasLabel === null || aliasLabel === undefined) {
throw new RequiredError("DefaultApi", "deleteUser", "aliasLabel");
}
// verify required parameter 'aliasId' is not null or undefined
if (aliasId === null || aliasId === undefined) {
throw new RequiredError("DefaultApi", "deleteUser", "aliasId");
}
// Path Params
const localVarPath = '/apps/{app_id}/users/by/{alias_label}/{alias_id}'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)))
.replace('{' + 'alias_label' + '}', encodeURIComponent(String(aliasLabel)))
.replace('{' + 'alias_id' + '}', encodeURIComponent(String(aliasId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Generate a compressed CSV report of all of the events data for a notification. This will return a URL immediately upon success but it may take several minutes for the CSV to become available at that URL depending on the volume of data. Only one export can be in-progress per OneSignal account at any given time.
* Export CSV of Events
* @param notificationId The ID of the notification to export events from.
* @param appId The ID of the app that the notification belongs to.
*/
public async exportEvents(notificationId: string, appId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'notificationId' is not null or undefined
if (notificationId === null || notificationId === undefined) {
throw new RequiredError("DefaultApi", "exportEvents", "notificationId");
}
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "exportEvents", "appId");
}
// Path Params
const localVarPath = '/notifications/{notification_id}/export_events?app_id={app_id}'
.replace('{' + 'notification_id' + '}', encodeURIComponent(String(notificationId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Query Params
if (appId !== undefined) {
requestContext.setQueryParam("app_id", ObjectSerializer.serialize(appId, "string", ""));
}
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Generate a compressed CSV export of all of your current user data This method can be used to generate a compressed CSV export of all of your current user data. It is a much faster alternative than retrieving this data using the /players API endpoint. The file will be compressed using GZip. The file may take several minutes to generate depending on the number of users in your app. The URL generated will be available for 3 days and includes random v4 uuid as part of the resource name to be unguessable. 🚧 403 Error Responses You can test if it is complete by making a GET request to the csv_file_url value. This file may take time to generate depending on how many device records are being pulled. If the file is not ready, a 403 error will be returned. Otherwise the file itself will be returned. 🚧 Requires Authentication Key Requires your OneSignal App\'s REST API Key, available in Keys & IDs. 🚧 Concurrent Exports Only one concurrent export is allowed per OneSignal account. Please ensure you have successfully downloaded the .csv.gz file before exporting another app. CSV File Format: - Default Columns: | Field | Details | | --- | --- | | id | OneSignal Player Id | | identifier | Push Token | | session_count | Number of times they visited the app or site | language | Device language code | | timezone | Number of seconds away from UTC. Example: -28800 | | game_version | Version of your mobile app gathered from Android Studio versionCode in your App/build.gradle and iOS uses kCFBundleVersionKey in Xcode. | | device_os | Device Operating System Version. Example: 80 = Chrome 80, 9 = Android 9 | | device_type | Device Operating System Type | | device_model | Device Hardware String Code. Example: Mobile Web Subscribers will have `Linux armv` | | ad_id | Based on the Google Advertising Id for Android, identifierForVendor for iOS. OptedOut means user turned off Advertising tracking on the device. | | tags | Current OneSignal Data Tags on the device. | | last_active | Date and time the user last opened the mobile app or visited the site. | | playtime | Total amount of time in seconds the user had the mobile app open. | | amount_spent | Mobile only - amount spent in USD on In-App Purchases. | | created_at | Date and time the device record was created in OneSignal. Mobile - first time they opened the app with OneSignal SDK. Web - first time the user subscribed to the site. | | invalid_identifier | t = unsubscribed, f = subscibed | | badge_count | Current number of badges on the device | - Extra Columns: | Field | Details | | --- | --- | | external_user_id | Your User Id set on the device | | notification_types | Notification types | | location | Location points (Latitude and Longitude) set on the device. | | country | Country code | | rooted | Android device rooted or not | | ip | IP Address of the device if being tracked. See Handling Personal Data. | | web_auth | Web Only authorization key. | | web_p256 | Web Only p256 key. |
* Export CSV of Subscriptions
* @param appId The app ID that you want to export devices from
* @param exportSubscriptionsRequestBody
*/
public async exportSubscriptions(appId: string, exportSubscriptionsRequestBody?: ExportSubscriptionsRequestBody, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "exportSubscriptions", "appId");
}
// Path Params
const localVarPath = '/players/csv_export?app_id={app_id}'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(exportSubscriptionsRequestBody, "ExportSubscriptionsRequestBody", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Lists all Aliases for the User identified by (:alias_label, :alias_id).
* @param appId
* @param aliasLabel
* @param aliasId
*/
public async getAliases(appId: string, aliasLabel: string, aliasId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "getAliases", "appId");
}
// verify required parameter 'aliasLabel' is not null or undefined
if (aliasLabel === null || aliasLabel === undefined) {
throw new RequiredError("DefaultApi", "getAliases", "aliasLabel");
}
// verify required parameter 'aliasId' is not null or undefined
if (aliasId === null || aliasId === undefined) {
throw new RequiredError("DefaultApi", "getAliases", "aliasId");
}
// Path Params
const localVarPath = '/apps/{app_id}/users/by/{alias_label}/{alias_id}/identity'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)))
.replace('{' + 'alias_label' + '}', encodeURIComponent(String(aliasLabel)))
.replace('{' + 'alias_id' + '}', encodeURIComponent(String(aliasId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Lists all Aliases for the User identified by :subscription_id.
* @param appId
* @param subscriptionId
*/
public async getAliasesBySubscription(appId: string, subscriptionId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "getAliasesBySubscription", "appId");
}
// verify required parameter 'subscriptionId' is not null or undefined
if (subscriptionId === null || subscriptionId === undefined) {
throw new RequiredError("DefaultApi", "getAliasesBySubscription", "subscriptionId");
}
// Path Params
const localVarPath = '/apps/{app_id}/subscriptions/{subscription_id}/user/identity'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)))
.replace('{' + 'subscription_id' + '}', encodeURIComponent(String(subscriptionId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* View the details of a single OneSignal app
* View an app
* @param appId An app id
*/
public async getApp(appId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "getApp", "appId");
}
// Path Params
const localVarPath = '/apps/{app_id}'
.replace('{' + 'app_id' + '}', encodeURIComponent(String(appId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["organization_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* View the details of all of your current OneSignal apps
* View apps
*/
public async getApps(_options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// Path Params
const localVarPath = '/apps';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["organization_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* View the details of a single notification and outcomes associated with it
* View notification
* @param appId
* @param notificationId
*/
public async getNotification(appId: string, notificationId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'appId' is not null or undefined
if (appId === null || appId === undefined) {
throw new RequiredError("DefaultApi", "getNotification", "appId");
}
// verify required parameter 'notificationId' is not null or undefined
if (notificationId === null || notificationId === undefined) {
throw new RequiredError("DefaultApi", "getNotification", "notificationId");
}
// Path Params
const localVarPath = '/notifications/{notification_id}'
.replace('{' + 'notification_id' + '}', encodeURIComponent(String(notificationId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Always add the One Signal telemetry to the request.
requestContext.setHeaderParam("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-typescript, version=5.2.0-beta1");
// Query Params
if (appId !== undefined) {
requestContext.setQueryParam("app_id", ObjectSerializer.serialize(appId, "string", ""));
}
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["rest_api_key"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: Secu