Class: OneSignal::DefaultApi

Inherits:
Object
  • Object
show all
Defined in:
lib/onesignal/helpers.rb,
lib/onesignal/api/default_api.rb

Overview

Surface the idempotent-retry helper as an instance method so the call mirrors create_notification. Delegates to Helpers (single source of truth); reopening is load-order independent since the body runs at call time. See Helpers.create_notification_with_retry for the full contract.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ DefaultApi

Returns a new instance of DefaultApi.



19
20
21
# File 'lib/onesignal/api/default_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/onesignal/api/default_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#cancel_notification(app_id, notification_id, opts = {}) ⇒ GenericSuccessBoolResponse

Stop a scheduled or currently outgoing notification Used to stop a scheduled or currently outgoing notification

Parameters:

  • app_id (String)
  • notification_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



28
29
30
31
# File 'lib/onesignal/api/default_api.rb', line 28

def cancel_notification(app_id, notification_id, opts = {})
  data, _status_code, _headers = cancel_notification_with_http_info(app_id, notification_id, opts)
  data
end

#cancel_notification_with_http_info(app_id, notification_id, opts = {}) ⇒ Array<(GenericSuccessBoolResponse, Integer, Hash)>

Stop a scheduled or currently outgoing notification Used to stop a scheduled or currently outgoing notification

Parameters:

  • app_id (String)
  • notification_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(GenericSuccessBoolResponse, Integer, Hash)>)

    GenericSuccessBoolResponse data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/onesignal/api/default_api.rb', line 39

def cancel_notification_with_http_info(app_id, notification_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.cancel_notification ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.cancel_notification"
  end
  # verify the required parameter 'notification_id' is set
  if @api_client.config.client_side_validation && notification_id.nil?
    fail ArgumentError, "Missing the required parameter 'notification_id' when calling DefaultApi.cancel_notification"
  end
  # resource path
  local_var_path = '/notifications/{notification_id}'.sub('{' + 'notification_id' + '}', CGI.escape(notification_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'app_id'] = app_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GenericSuccessBoolResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.cancel_notification",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#cancel_notification\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#copy_template_to_app(template_id, app_id, copy_template_request, opts = {}) ⇒ TemplateResource

Copy template to another app Copy a template to a destination app.

Parameters:

  • template_id (String)
  • app_id (String)
  • copy_template_request (CopyTemplateRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



99
100
101
102
# File 'lib/onesignal/api/default_api.rb', line 99

def copy_template_to_app(template_id, app_id, copy_template_request, opts = {})
  data, _status_code, _headers = copy_template_to_app_with_http_info(template_id, app_id, copy_template_request, opts)
  data
end

#copy_template_to_app_with_http_info(template_id, app_id, copy_template_request, opts = {}) ⇒ Array<(TemplateResource, Integer, Hash)>

Copy template to another app Copy a template to a destination app.

Parameters:

  • template_id (String)
  • app_id (String)
  • copy_template_request (CopyTemplateRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateResource, Integer, Hash)>)

    TemplateResource data, response status code and response headers



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/onesignal/api/default_api.rb', line 111

def copy_template_to_app_with_http_info(template_id, app_id, copy_template_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.copy_template_to_app ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling DefaultApi.copy_template_to_app"
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.copy_template_to_app"
  end
  # verify the required parameter 'copy_template_request' is set
  if @api_client.config.client_side_validation && copy_template_request.nil?
    fail ArgumentError, "Missing the required parameter 'copy_template_request' when calling DefaultApi.copy_template_to_app"
  end
  # resource path
  local_var_path = '/templates/{template_id}/copy_to_app'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'app_id'] = app_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(copy_template_request)

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateResource'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.copy_template_to_app",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#copy_template_to_app\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_alias(app_id, alias_label, alias_id, user_identity_body, opts = {}) ⇒ UserIdentityBody

Upserts one or more Aliases to an existing User identified by (:alias_label, :alias_id).

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • user_identity_body (UserIdentityBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



180
181
182
183
# File 'lib/onesignal/api/default_api.rb', line 180

def create_alias(app_id, alias_label, alias_id, user_identity_body, opts = {})
  data, _status_code, _headers = create_alias_with_http_info(app_id, alias_label, alias_id, user_identity_body, opts)
  data
end

#create_alias_by_subscription(app_id, subscription_id, user_identity_body, opts = {}) ⇒ UserIdentityBody

Upserts one or more Aliases for the User identified by :subscription_id.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • user_identity_body (UserIdentityBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



263
264
265
266
# File 'lib/onesignal/api/default_api.rb', line 263

def create_alias_by_subscription(app_id, subscription_id, user_identity_body, opts = {})
  data, _status_code, _headers = create_alias_by_subscription_with_http_info(app_id, subscription_id, user_identity_body, opts)
  data
end

#create_alias_by_subscription_with_http_info(app_id, subscription_id, user_identity_body, opts = {}) ⇒ Array<(UserIdentityBody, Integer, Hash)>

Upserts one or more Aliases for the User identified by :subscription_id.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • user_identity_body (UserIdentityBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(UserIdentityBody, Integer, Hash)>)

    UserIdentityBody data, response status code and response headers



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/onesignal/api/default_api.rb', line 274

def create_alias_by_subscription_with_http_info(app_id, subscription_id, user_identity_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_alias_by_subscription ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.create_alias_by_subscription"
  end
  # verify the required parameter 'subscription_id' is set
  if @api_client.config.client_side_validation && subscription_id.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_id' when calling DefaultApi.create_alias_by_subscription"
  end
  # verify the required parameter 'user_identity_body' is set
  if @api_client.config.client_side_validation && user_identity_body.nil?
    fail ArgumentError, "Missing the required parameter 'user_identity_body' when calling DefaultApi.create_alias_by_subscription"
  end
  # resource path
  local_var_path = '/apps/{app_id}/subscriptions/{subscription_id}/user/identity'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'subscription_id' + '}', CGI.escape(subscription_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(user_identity_body)

  # return_type
  return_type = opts[:debug_return_type] || 'UserIdentityBody'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_alias_by_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_alias_by_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_alias_with_http_info(app_id, alias_label, alias_id, user_identity_body, opts = {}) ⇒ Array<(UserIdentityBody, Integer, Hash)>

Upserts one or more Aliases to an existing User identified by (:alias_label, :alias_id).

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • user_identity_body (UserIdentityBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(UserIdentityBody, Integer, Hash)>)

    UserIdentityBody data, response status code and response headers



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/onesignal/api/default_api.rb', line 192

def create_alias_with_http_info(app_id, alias_label, alias_id, user_identity_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_alias ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.create_alias"
  end
  # verify the required parameter 'alias_label' is set
  if @api_client.config.client_side_validation && alias_label.nil?
    fail ArgumentError, "Missing the required parameter 'alias_label' when calling DefaultApi.create_alias"
  end
  # verify the required parameter 'alias_id' is set
  if @api_client.config.client_side_validation && alias_id.nil?
    fail ArgumentError, "Missing the required parameter 'alias_id' when calling DefaultApi.create_alias"
  end
  # verify the required parameter 'user_identity_body' is set
  if @api_client.config.client_side_validation && user_identity_body.nil?
    fail ArgumentError, "Missing the required parameter 'user_identity_body' when calling DefaultApi.create_alias"
  end
  # resource path
  local_var_path = '/apps/{app_id}/users/by/{alias_label}/{alias_id}/identity'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'alias_label' + '}', CGI.escape(alias_label.to_s)).sub('{' + 'alias_id' + '}', CGI.escape(alias_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(user_identity_body)

  # return_type
  return_type = opts[:debug_return_type] || 'UserIdentityBody'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_alias",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_alias\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_api_key(app_id, create_api_key_request, opts = {}) ⇒ CreateApiKeyResponse

Create API key Use this API to create a new App API Key (also called a Rich Authentication Token) for a specific OneSignal app. These keys are used to authenticate API requests at the app level and offer enhanced security features, including optional IP allowlisting.

Parameters:

  • app_id (String)
  • create_api_key_request (CreateApiKeyRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



341
342
343
344
# File 'lib/onesignal/api/default_api.rb', line 341

def create_api_key(app_id, create_api_key_request, opts = {})
  data, _status_code, _headers = create_api_key_with_http_info(app_id, create_api_key_request, opts)
  data
end

#create_api_key_with_http_info(app_id, create_api_key_request, opts = {}) ⇒ Array<(CreateApiKeyResponse, Integer, Hash)>

Create API key Use this API to create a new App API Key (also called a Rich Authentication Token) for a specific OneSignal app. These keys are used to authenticate API requests at the app level and offer enhanced security features, including optional IP allowlisting.

Parameters:

  • app_id (String)
  • create_api_key_request (CreateApiKeyRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(CreateApiKeyResponse, Integer, Hash)>)

    CreateApiKeyResponse data, response status code and response headers



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/onesignal/api/default_api.rb', line 352

def create_api_key_with_http_info(app_id, create_api_key_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_api_key ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.create_api_key"
  end
  # verify the required parameter 'create_api_key_request' is set
  if @api_client.config.client_side_validation && create_api_key_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_api_key_request' when calling DefaultApi.create_api_key"
  end
  # resource path
  local_var_path = '/apps/{app_id}/auth/tokens'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_api_key_request)

  # return_type
  return_type = opts[:debug_return_type] || 'CreateApiKeyResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_api_key",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_api_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_app(app, opts = {}) ⇒ App

Create an app Creates a new OneSignal app

Parameters:

  • app (App)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



414
415
416
417
# File 'lib/onesignal/api/default_api.rb', line 414

def create_app(app, opts = {})
  data, _status_code, _headers = create_app_with_http_info(app, opts)
  data
end

#create_app_with_http_info(app, opts = {}) ⇒ Array<(App, Integer, Hash)>

Create an app Creates a new OneSignal app

Parameters:

  • app (App)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(App, Integer, Hash)>)

    App data, response status code and response headers



424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/onesignal/api/default_api.rb', line 424

def create_app_with_http_info(app, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_app ...'
  end
  # verify the required parameter 'app' is set
  if @api_client.config.client_side_validation && app.nil?
    fail ArgumentError, "Missing the required parameter 'app' when calling DefaultApi.create_app"
  end
  # resource path
  local_var_path = '/apps'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(app)

  # return_type
  return_type = opts[:debug_return_type] || 'App'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_app",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_app\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_custom_events(app_id, custom_events_request, opts = {}) ⇒ Object

Create custom events The Custom Events API allows you to record user events. Custom events can represent any action users take in your application, such as completing a purchase, viewing content, or achieving milestones.

Parameters:

  • app_id (String)

    Your OneSignal App ID in UUID v4 format.

  • custom_events_request (CustomEventsRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


483
484
485
486
# File 'lib/onesignal/api/default_api.rb', line 483

def create_custom_events(app_id, custom_events_request, opts = {})
  data, _status_code, _headers = create_custom_events_with_http_info(app_id, custom_events_request, opts)
  data
end

#create_custom_events_with_http_info(app_id, custom_events_request, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Create custom events The Custom Events API allows you to record user events. Custom events can represent any action users take in your application, such as completing a purchase, viewing content, or achieving milestones.

Parameters:

  • app_id (String)

    Your OneSignal App ID in UUID v4 format.

  • custom_events_request (CustomEventsRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/onesignal/api/default_api.rb', line 494

def create_custom_events_with_http_info(app_id, custom_events_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_custom_events ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.create_custom_events"
  end
  # verify the required parameter 'custom_events_request' is set
  if @api_client.config.client_side_validation && custom_events_request.nil?
    fail ArgumentError, "Missing the required parameter 'custom_events_request' when calling DefaultApi.create_custom_events"
  end
  # resource path
  local_var_path = '/apps/{app_id}/integrations/custom_events'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(custom_events_request)

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_custom_events",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_custom_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_notification(notification, opts = {}) ⇒ CreateNotificationSuccessResponse

Create notification Sends notifications to your users. Target by External ID (push example): set include_aliases to { \"external_id\": [\"your-user-id\"] } and set target_channel to push (or email / sms for those channels). Alias object keys must match API labels exactly (for example external_id, not camelCase). Do not confuse the notification-level external_id field with External ID targeting: top-level external_id / idempotency_key are for idempotent notification requests only, not for selecting recipients. Targeting compatibility: include_aliases must not be combined with other targeting modes (segments, filters, subscription IDs, legacy player IDs, etc.). Clients should send only one targeting strategy per request.

Parameters:

  • notification (Notification)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



556
557
558
559
# File 'lib/onesignal/api/default_api.rb', line 556

def create_notification(notification, opts = {})
  data, _status_code, _headers = create_notification_with_http_info(notification, opts)
  data
end

#create_notification_with_http_info(notification, opts = {}) ⇒ Array<(CreateNotificationSuccessResponse, Integer, Hash)>

Create notification Sends notifications to your users. Target by External ID (push example): set `include_aliases` to `{ &quot;external_id&quot;: [&quot;your-user-id&quot;] }` and set `target_channel` to `push` (or `email` / `sms` for those channels). Alias object keys must match API labels exactly (for example `external_id`, not camelCase). Do not confuse the notification-level `external_id` field with External ID targeting: top-level `external_id` / `idempotency_key` are for idempotent notification requests only, not for selecting recipients. Targeting compatibility: `include_aliases` must not be combined with other targeting modes (segments, filters, subscription IDs, legacy player IDs, etc.). Clients should send only one targeting strategy per request.

Parameters:

  • notification (Notification)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
# File 'lib/onesignal/api/default_api.rb', line 566

def create_notification_with_http_info(notification, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_notification ...'
  end
  # verify the required parameter 'notification' is set
  if @api_client.config.client_side_validation && notification.nil?
    fail ArgumentError, "Missing the required parameter 'notification' when calling DefaultApi.create_notification"
  end
  # resource path
  local_var_path = '/notifications'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(notification)

  # return_type
  return_type = opts[:debug_return_type] || 'CreateNotificationSuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_notification",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_notification\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_notification_with_retry(notification, max_retries: 3, base_delay: 1.0) ⇒ Object



112
113
114
# File 'lib/onesignal/helpers.rb', line 112

def create_notification_with_retry(notification, max_retries: 3, base_delay: 1.0)
  Helpers.create_notification_with_retry(self, notification, max_retries: max_retries, base_delay: base_delay)
end

#create_segment(app_id, opts = {}) ⇒ CreateSegmentSuccessResponse

Create Segment 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.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



625
626
627
628
# File 'lib/onesignal/api/default_api.rb', line 625

def create_segment(app_id, opts = {})
  data, _status_code, _headers = create_segment_with_http_info(app_id, opts)
  data
end

#create_segment_with_http_info(app_id, opts = {}) ⇒ Array<(CreateSegmentSuccessResponse, Integer, Hash)>

Create Segment 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 &quot;AND&quot; or &quot;OR&quot; operator's. &#x1F6A7; 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.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# File 'lib/onesignal/api/default_api.rb', line 636

def create_segment_with_http_info(app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_segment ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.create_segment"
  end
  # resource path
  local_var_path = '/apps/{app_id}/segments'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'segment'])

  # return_type
  return_type = opts[:debug_return_type] || 'CreateSegmentSuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_segment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_segment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_subscription(app_id, alias_label, alias_id, subscription_body, opts = {}) ⇒ SubscriptionBody

Creates a new Subscription under the User provided. Useful to add email addresses and SMS numbers to the User.

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • subscription_body (SubscriptionBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



696
697
698
699
# File 'lib/onesignal/api/default_api.rb', line 696

def create_subscription(app_id, alias_label, alias_id, subscription_body, opts = {})
  data, _status_code, _headers = create_subscription_with_http_info(app_id, alias_label, alias_id, subscription_body, opts)
  data
end

#create_subscription_with_http_info(app_id, alias_label, alias_id, subscription_body, opts = {}) ⇒ Array<(SubscriptionBody, Integer, Hash)>

Creates a new Subscription under the User provided. Useful to add email addresses and SMS numbers to the User.

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • subscription_body (SubscriptionBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(SubscriptionBody, Integer, Hash)>)

    SubscriptionBody data, response status code and response headers



708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
# File 'lib/onesignal/api/default_api.rb', line 708

def create_subscription_with_http_info(app_id, alias_label, alias_id, subscription_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_subscription ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.create_subscription"
  end
  # verify the required parameter 'alias_label' is set
  if @api_client.config.client_side_validation && alias_label.nil?
    fail ArgumentError, "Missing the required parameter 'alias_label' when calling DefaultApi.create_subscription"
  end
  # verify the required parameter 'alias_id' is set
  if @api_client.config.client_side_validation && alias_id.nil?
    fail ArgumentError, "Missing the required parameter 'alias_id' when calling DefaultApi.create_subscription"
  end
  # verify the required parameter 'subscription_body' is set
  if @api_client.config.client_side_validation && subscription_body.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_body' when calling DefaultApi.create_subscription"
  end
  # resource path
  local_var_path = '/apps/{app_id}/users/by/{alias_label}/{alias_id}/subscriptions'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'alias_label' + '}', CGI.escape(alias_label.to_s)).sub('{' + 'alias_id' + '}', CGI.escape(alias_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(subscription_body)

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionBody'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_template(create_template_request, opts = {}) ⇒ TemplateResource

Create template Create reusable message templates for push, email, and SMS channels.

Parameters:

  • create_template_request (CreateTemplateRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



778
779
780
781
# File 'lib/onesignal/api/default_api.rb', line 778

def create_template(create_template_request, opts = {})
  data, _status_code, _headers = create_template_with_http_info(create_template_request, opts)
  data
end

#create_template_with_http_info(create_template_request, opts = {}) ⇒ Array<(TemplateResource, Integer, Hash)>

Create template Create reusable message templates for push, email, and SMS channels.

Parameters:

  • create_template_request (CreateTemplateRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateResource, Integer, Hash)>)

    TemplateResource data, response status code and response headers



788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
# File 'lib/onesignal/api/default_api.rb', line 788

def create_template_with_http_info(create_template_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_template ...'
  end
  # verify the required parameter 'create_template_request' is set
  if @api_client.config.client_side_validation && create_template_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_template_request' when calling DefaultApi.create_template"
  end
  # resource path
  local_var_path = '/templates'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_template_request)

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateResource'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_user(app_id, user, opts = {}) ⇒ User

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.

Parameters:

  • app_id (String)
  • user (User)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



846
847
848
849
# File 'lib/onesignal/api/default_api.rb', line 846

def create_user(app_id, user, opts = {})
  data, _status_code, _headers = create_user_with_http_info(app_id, user, opts)
  data
end

#create_user_with_http_info(app_id, user, opts = {}) ⇒ Array<(User, Integer, Hash)>

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.

Parameters:

  • app_id (String)
  • user (User)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(User, Integer, Hash)>)

    User data, response status code and response headers



856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
# File 'lib/onesignal/api/default_api.rb', line 856

def create_user_with_http_info(app_id, user, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.create_user ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.create_user"
  end
  # verify the required parameter 'user' is set
  if @api_client.config.client_side_validation && user.nil?
    fail ArgumentError, "Missing the required parameter 'user' when calling DefaultApi.create_user"
  end
  # resource path
  local_var_path = '/apps/{app_id}/users'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(user)

  # return_type
  return_type = opts[:debug_return_type] || 'User'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.create_user",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#create_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_alias(app_id, alias_label, alias_id, alias_label_to_delete, opts = {}) ⇒ UserIdentityBody

Deletes an alias by alias label

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • alias_label_to_delete (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



920
921
922
923
# File 'lib/onesignal/api/default_api.rb', line 920

def delete_alias(app_id, alias_label, alias_id, alias_label_to_delete, opts = {})
  data, _status_code, _headers = delete_alias_with_http_info(app_id, alias_label, alias_id, alias_label_to_delete, opts)
  data
end

#delete_alias_with_http_info(app_id, alias_label, alias_id, alias_label_to_delete, opts = {}) ⇒ Array<(UserIdentityBody, Integer, Hash)>

Deletes an alias by alias label

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • alias_label_to_delete (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(UserIdentityBody, Integer, Hash)>)

    UserIdentityBody data, response status code and response headers



932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
# File 'lib/onesignal/api/default_api.rb', line 932

def delete_alias_with_http_info(app_id, alias_label, alias_id, alias_label_to_delete, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.delete_alias ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.delete_alias"
  end
  # verify the required parameter 'alias_label' is set
  if @api_client.config.client_side_validation && alias_label.nil?
    fail ArgumentError, "Missing the required parameter 'alias_label' when calling DefaultApi.delete_alias"
  end
  # verify the required parameter 'alias_id' is set
  if @api_client.config.client_side_validation && alias_id.nil?
    fail ArgumentError, "Missing the required parameter 'alias_id' when calling DefaultApi.delete_alias"
  end
  # verify the required parameter 'alias_label_to_delete' is set
  if @api_client.config.client_side_validation && alias_label_to_delete.nil?
    fail ArgumentError, "Missing the required parameter 'alias_label_to_delete' when calling DefaultApi.delete_alias"
  end
  # resource path
  local_var_path = '/apps/{app_id}/users/by/{alias_label}/{alias_id}/identity/{alias_label_to_delete}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'alias_label' + '}', CGI.escape(alias_label.to_s)).sub('{' + 'alias_id' + '}', CGI.escape(alias_id.to_s)).sub('{' + 'alias_label_to_delete' + '}', CGI.escape(alias_label_to_delete.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UserIdentityBody'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.delete_alias",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#delete_alias\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_api_key(app_id, token_id, opts = {}) ⇒ Object

Delete API key Delete a specific Rich Authentication Token (App API Key) for a OneSignal app. Requires your Organization API Key and the token’s unique ID, not the token value itself.

Parameters:

  • app_id (String)
  • token_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


998
999
1000
1001
# File 'lib/onesignal/api/default_api.rb', line 998

def delete_api_key(app_id, token_id, opts = {})
  data, _status_code, _headers = delete_api_key_with_http_info(app_id, token_id, opts)
  data
end

#delete_api_key_with_http_info(app_id, token_id, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Delete API key Delete a specific Rich Authentication Token (App API Key) for a OneSignal app. Requires your Organization API Key and the token’s unique ID, not the token value itself.

Parameters:

  • app_id (String)
  • token_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
# File 'lib/onesignal/api/default_api.rb', line 1009

def delete_api_key_with_http_info(app_id, token_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.delete_api_key ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.delete_api_key"
  end
  # verify the required parameter 'token_id' is set
  if @api_client.config.client_side_validation && token_id.nil?
    fail ArgumentError, "Missing the required parameter 'token_id' when calling DefaultApi.delete_api_key"
  end
  # resource path
  local_var_path = '/apps/{app_id}/auth/tokens/{token_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'token_id' + '}', CGI.escape(token_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.delete_api_key",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#delete_api_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_segment(app_id, segment_id, opts = {}) ⇒ GenericSuccessBoolResponse

Delete Segment 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.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • segment_id (String)

    The segment_id can be found in the URL of the segment when viewing it in the dashboard.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1067
1068
1069
1070
# File 'lib/onesignal/api/default_api.rb', line 1067

def delete_segment(app_id, segment_id, opts = {})
  data, _status_code, _headers = delete_segment_with_http_info(app_id, segment_id, opts)
  data
end

#delete_segment_with_http_info(app_id, segment_id, opts = {}) ⇒ Array<(GenericSuccessBoolResponse, Integer, Hash)>

Delete Segment 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.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • segment_id (String)

    The segment_id can be found in the URL of the segment when viewing it in the dashboard.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(GenericSuccessBoolResponse, Integer, Hash)>)

    GenericSuccessBoolResponse data, response status code and response headers



1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
# File 'lib/onesignal/api/default_api.rb', line 1078

def delete_segment_with_http_info(app_id, segment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.delete_segment ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.delete_segment"
  end
  # verify the required parameter 'segment_id' is set
  if @api_client.config.client_side_validation && segment_id.nil?
    fail ArgumentError, "Missing the required parameter 'segment_id' when calling DefaultApi.delete_segment"
  end
  # resource path
  local_var_path = '/apps/{app_id}/segments/{segment_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'segment_id' + '}', CGI.escape(segment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GenericSuccessBoolResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.delete_segment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#delete_segment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_subscription(app_id, subscription_id, opts = {}) ⇒ nil

Deletes the Subscription.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


1135
1136
1137
1138
# File 'lib/onesignal/api/default_api.rb', line 1135

def delete_subscription(app_id, subscription_id, opts = {})
  delete_subscription_with_http_info(app_id, subscription_id, opts)
  nil
end

#delete_subscription_with_http_info(app_id, subscription_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Deletes the Subscription.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
# File 'lib/onesignal/api/default_api.rb', line 1145

def delete_subscription_with_http_info(app_id, subscription_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.delete_subscription ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.delete_subscription"
  end
  # verify the required parameter 'subscription_id' is set
  if @api_client.config.client_side_validation && subscription_id.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_id' when calling DefaultApi.delete_subscription"
  end
  # resource path
  local_var_path = '/apps/{app_id}/subscriptions/{subscription_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'subscription_id' + '}', CGI.escape(subscription_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.delete_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#delete_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_template(template_id, app_id, opts = {}) ⇒ GenericSuccessBoolResponse

Delete template Delete a template by id.

Parameters:

  • template_id (String)
  • app_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1203
1204
1205
1206
# File 'lib/onesignal/api/default_api.rb', line 1203

def delete_template(template_id, app_id, opts = {})
  data, _status_code, _headers = delete_template_with_http_info(template_id, app_id, opts)
  data
end

#delete_template_with_http_info(template_id, app_id, opts = {}) ⇒ Array<(GenericSuccessBoolResponse, Integer, Hash)>

Delete template Delete a template by id.

Parameters:

  • template_id (String)
  • app_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(GenericSuccessBoolResponse, Integer, Hash)>)

    GenericSuccessBoolResponse data, response status code and response headers



1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
# File 'lib/onesignal/api/default_api.rb', line 1214

def delete_template_with_http_info(template_id, app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.delete_template ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling DefaultApi.delete_template"
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.delete_template"
  end
  # resource path
  local_var_path = '/templates/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'app_id'] = app_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GenericSuccessBoolResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.delete_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#delete_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_user(app_id, alias_label, alias_id, opts = {}) ⇒ nil

Removes the User identified by (:alias_label, :alias_id), and all Subscriptions and Aliases

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


1273
1274
1275
1276
# File 'lib/onesignal/api/default_api.rb', line 1273

def delete_user(app_id, alias_label, alias_id, opts = {})
  delete_user_with_http_info(app_id, alias_label, alias_id, opts)
  nil
end

#delete_user_with_http_info(app_id, alias_label, alias_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Removes the User identified by (:alias_label, :alias_id), and all Subscriptions and Aliases

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
# File 'lib/onesignal/api/default_api.rb', line 1284

def delete_user_with_http_info(app_id, alias_label, alias_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.delete_user ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.delete_user"
  end
  # verify the required parameter 'alias_label' is set
  if @api_client.config.client_side_validation && alias_label.nil?
    fail ArgumentError, "Missing the required parameter 'alias_label' when calling DefaultApi.delete_user"
  end
  # verify the required parameter 'alias_id' is set
  if @api_client.config.client_side_validation && alias_id.nil?
    fail ArgumentError, "Missing the required parameter 'alias_id' when calling DefaultApi.delete_user"
  end
  # resource path
  local_var_path = '/apps/{app_id}/users/by/{alias_label}/{alias_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'alias_label' + '}', CGI.escape(alias_label.to_s)).sub('{' + 'alias_id' + '}', CGI.escape(alias_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.delete_user",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#export_events(notification_id, app_id, opts = {}) ⇒ ExportEventsSuccessResponse

Export CSV of Events 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.

Parameters:

  • notification_id (String)

    The ID of the notification to export events from.

  • app_id (String)

    The ID of the app that the notification belongs to.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1346
1347
1348
1349
# File 'lib/onesignal/api/default_api.rb', line 1346

def export_events(notification_id, app_id, opts = {})
  data, _status_code, _headers = export_events_with_http_info(notification_id, app_id, opts)
  data
end

#export_events_with_http_info(notification_id, app_id, opts = {}) ⇒ Array<(ExportEventsSuccessResponse, Integer, Hash)>

Export CSV of Events 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.

Parameters:

  • notification_id (String)

    The ID of the notification to export events from.

  • app_id (String)

    The ID of the app that the notification belongs to.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(ExportEventsSuccessResponse, Integer, Hash)>)

    ExportEventsSuccessResponse data, response status code and response headers



1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
# File 'lib/onesignal/api/default_api.rb', line 1357

def export_events_with_http_info(notification_id, app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.export_events ...'
  end
  # verify the required parameter 'notification_id' is set
  if @api_client.config.client_side_validation && notification_id.nil?
    fail ArgumentError, "Missing the required parameter 'notification_id' when calling DefaultApi.export_events"
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.export_events"
  end
  # resource path
  local_var_path = '/notifications/{notification_id}/export_events'.sub('{' + 'notification_id' + '}', CGI.escape(notification_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'app_id'] = app_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ExportEventsSuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.export_events",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#export_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#export_subscriptions(app_id, opts = {}) ⇒ ExportSubscriptionsSuccessResponse

Export CSV of Subscriptions 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. |

Parameters:

  • app_id (String)

    The app ID that you want to export devices from

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



1416
1417
1418
1419
# File 'lib/onesignal/api/default_api.rb', line 1416

def export_subscriptions(app_id, opts = {})
  data, _status_code, _headers = export_subscriptions_with_http_info(app_id, opts)
  data
end

#export_subscriptions_with_http_info(app_id, opts = {}) ⇒ Array<(ExportSubscriptionsSuccessResponse, Integer, Hash)>

Export CSV of Subscriptions 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. &#x1F6A7; 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. &#x1F6A7; Requires Authentication Key Requires your OneSignal App's REST API Key, available in Keys & IDs. &#x1F6A7; 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. |

Parameters:

  • app_id (String)

    The app ID that you want to export devices from

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
# File 'lib/onesignal/api/default_api.rb', line 1427

def export_subscriptions_with_http_info(app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.export_subscriptions ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.export_subscriptions"
  end
  # resource path
  local_var_path = '/players/csv_export?app_id={app_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'export_subscriptions_request_body'])

  # return_type
  return_type = opts[:debug_return_type] || 'ExportSubscriptionsSuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.export_subscriptions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#export_subscriptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_aliases(app_id, alias_label, alias_id, opts = {}) ⇒ UserIdentityBody

Lists all Aliases for the User identified by (:alias_label, :alias_id).

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1486
1487
1488
1489
# File 'lib/onesignal/api/default_api.rb', line 1486

def get_aliases(app_id, alias_label, alias_id, opts = {})
  data, _status_code, _headers = get_aliases_with_http_info(app_id, alias_label, alias_id, opts)
  data
end

#get_aliases_by_subscription(app_id, subscription_id, opts = {}) ⇒ UserIdentityBody

Lists all Aliases for the User identified by :subscription_id.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1558
1559
1560
1561
# File 'lib/onesignal/api/default_api.rb', line 1558

def get_aliases_by_subscription(app_id, subscription_id, opts = {})
  data, _status_code, _headers = get_aliases_by_subscription_with_http_info(app_id, subscription_id, opts)
  data
end

#get_aliases_by_subscription_with_http_info(app_id, subscription_id, opts = {}) ⇒ Array<(UserIdentityBody, Integer, Hash)>

Lists all Aliases for the User identified by :subscription_id.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(UserIdentityBody, Integer, Hash)>)

    UserIdentityBody data, response status code and response headers



1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
# File 'lib/onesignal/api/default_api.rb', line 1568

def get_aliases_by_subscription_with_http_info(app_id, subscription_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_aliases_by_subscription ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_aliases_by_subscription"
  end
  # verify the required parameter 'subscription_id' is set
  if @api_client.config.client_side_validation && subscription_id.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_id' when calling DefaultApi.get_aliases_by_subscription"
  end
  # resource path
  local_var_path = '/apps/{app_id}/subscriptions/{subscription_id}/user/identity'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'subscription_id' + '}', CGI.escape(subscription_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UserIdentityBody'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_aliases_by_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_aliases_by_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_aliases_with_http_info(app_id, alias_label, alias_id, opts = {}) ⇒ Array<(UserIdentityBody, Integer, Hash)>

Lists all Aliases for the User identified by (:alias_label, :alias_id).

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(UserIdentityBody, Integer, Hash)>)

    UserIdentityBody data, response status code and response headers



1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
# File 'lib/onesignal/api/default_api.rb', line 1497

def get_aliases_with_http_info(app_id, alias_label, alias_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_aliases ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_aliases"
  end
  # verify the required parameter 'alias_label' is set
  if @api_client.config.client_side_validation && alias_label.nil?
    fail ArgumentError, "Missing the required parameter 'alias_label' when calling DefaultApi.get_aliases"
  end
  # verify the required parameter 'alias_id' is set
  if @api_client.config.client_side_validation && alias_id.nil?
    fail ArgumentError, "Missing the required parameter 'alias_id' when calling DefaultApi.get_aliases"
  end
  # resource path
  local_var_path = '/apps/{app_id}/users/by/{alias_label}/{alias_id}/identity'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'alias_label' + '}', CGI.escape(alias_label.to_s)).sub('{' + 'alias_id' + '}', CGI.escape(alias_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UserIdentityBody'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_aliases",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_aliases\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_app(app_id, opts = {}) ⇒ App

View an app View the details of a single OneSignal app

Parameters:

  • app_id (String)

    An app id

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1625
1626
1627
1628
# File 'lib/onesignal/api/default_api.rb', line 1625

def get_app(app_id, opts = {})
  data, _status_code, _headers = get_app_with_http_info(app_id, opts)
  data
end

#get_app_with_http_info(app_id, opts = {}) ⇒ Array<(App, Integer, Hash)>

View an app View the details of a single OneSignal app

Parameters:

  • app_id (String)

    An app id

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(App, Integer, Hash)>)

    App data, response status code and response headers



1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
# File 'lib/onesignal/api/default_api.rb', line 1635

def get_app_with_http_info(app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_app ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_app"
  end
  # resource path
  local_var_path = '/apps/{app_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'App'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_app",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_app\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_apps(opts = {}) ⇒ Array<App>

View apps View the details of all of your current OneSignal apps

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1687
1688
1689
1690
# File 'lib/onesignal/api/default_api.rb', line 1687

def get_apps(opts = {})
  data, _status_code, _headers = get_apps_with_http_info(opts)
  data
end

#get_apps_with_http_info(opts = {}) ⇒ Array<(Array<App>, Integer, Hash)>

View apps View the details of all of your current OneSignal apps

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Array<App>, Integer, Hash)>)

    Array data, response status code and response headers



1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
# File 'lib/onesignal/api/default_api.rb', line 1696

def get_apps_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_apps ...'
  end
  # resource path
  local_var_path = '/apps'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<App>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_apps",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_apps\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_notification(app_id, notification_id, opts = {}) ⇒ NotificationWithMeta

View notification View the details of a single notification and outcomes associated with it

Parameters:

  • app_id (String)
  • notification_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1746
1747
1748
1749
# File 'lib/onesignal/api/default_api.rb', line 1746

def get_notification(app_id, notification_id, opts = {})
  data, _status_code, _headers = get_notification_with_http_info(app_id, notification_id, opts)
  data
end

#get_notification_history(notification_id, get_notification_history_request_body, opts = {}) ⇒ NotificationHistorySuccessResponse

Notification History -> View the devices sent a message - OneSignal Paid Plan Required This method will return all devices that were sent the given notification_id of an Email or Push Notification if used within 7 days of the date sent. After 7 days of the sending date, the message history data will be unavailable. After a successful response is received, the destination url may be polled until the file becomes available. Most exports are done in ~1-3 minutes, so setting a poll interval of 10 seconds should be adequate. For use cases that are not meant to be consumed by a script, an email will be sent to the supplied email address. đźš§ Requirements A OneSignal Paid Plan. Turn on Send History via OneSignal API in Settings -> Analytics. Cannot get data before this was turned on. Must be called within 7 days after sending the message. Messages targeting under 1000 recipients will not have "sent" events recorded, but will show "clicked" events. Requires your OneSignal App's REST API Key, available in Keys & IDs.

Parameters:

  • notification_id (String)

    The &quot;id&quot; of the message found in the Notification object

  • get_notification_history_request_body (GetNotificationHistoryRequestBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1816
1817
1818
1819
# File 'lib/onesignal/api/default_api.rb', line 1816

def get_notification_history(notification_id, get_notification_history_request_body, opts = {})
  data, _status_code, _headers = get_notification_history_with_http_info(notification_id, get_notification_history_request_body, opts)
  data
end

#get_notification_history_with_http_info(notification_id, get_notification_history_request_body, opts = {}) ⇒ Array<(NotificationHistorySuccessResponse, Integer, Hash)>

Notification History -> View the devices sent a message - OneSignal Paid Plan Required This method will return all devices that were sent the given notification_id of an Email or Push Notification if used within 7 days of the date sent. After 7 days of the sending date, the message history data will be unavailable. After a successful response is received, the destination url may be polled until the file becomes available. Most exports are done in ~1-3 minutes, so setting a poll interval of 10 seconds should be adequate. For use cases that are not meant to be consumed by a script, an email will be sent to the supplied email address. &#x1F6A7; Requirements A OneSignal Paid Plan. Turn on Send History via OneSignal API in Settings -> Analytics. Cannot get data before this was turned on. Must be called within 7 days after sending the message. Messages targeting under 1000 recipients will not have &quot;sent&quot; events recorded, but will show &quot;clicked&quot; events. Requires your OneSignal App's REST API Key, available in Keys & IDs.

Parameters:

  • notification_id (String)

    The &quot;id&quot; of the message found in the Notification object

  • get_notification_history_request_body (GetNotificationHistoryRequestBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
# File 'lib/onesignal/api/default_api.rb', line 1827

def get_notification_history_with_http_info(notification_id, get_notification_history_request_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_notification_history ...'
  end
  # verify the required parameter 'notification_id' is set
  if @api_client.config.client_side_validation && notification_id.nil?
    fail ArgumentError, "Missing the required parameter 'notification_id' when calling DefaultApi.get_notification_history"
  end
  # verify the required parameter 'get_notification_history_request_body' is set
  if @api_client.config.client_side_validation && get_notification_history_request_body.nil?
    fail ArgumentError, "Missing the required parameter 'get_notification_history_request_body' when calling DefaultApi.get_notification_history"
  end
  # resource path
  local_var_path = '/notifications/{notification_id}/history'.sub('{' + 'notification_id' + '}', CGI.escape(notification_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(get_notification_history_request_body)

  # return_type
  return_type = opts[:debug_return_type] || 'NotificationHistorySuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_notification_history",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_notification_history\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_notification_with_http_info(app_id, notification_id, opts = {}) ⇒ Array<(NotificationWithMeta, Integer, Hash)>

View notification View the details of a single notification and outcomes associated with it

Parameters:

  • app_id (String)
  • notification_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(NotificationWithMeta, Integer, Hash)>)

    NotificationWithMeta data, response status code and response headers



1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
# File 'lib/onesignal/api/default_api.rb', line 1757

def get_notification_with_http_info(app_id, notification_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_notification ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_notification"
  end
  # verify the required parameter 'notification_id' is set
  if @api_client.config.client_side_validation && notification_id.nil?
    fail ArgumentError, "Missing the required parameter 'notification_id' when calling DefaultApi.get_notification"
  end
  # resource path
  local_var_path = '/notifications/{notification_id}'.sub('{' + 'notification_id' + '}', CGI.escape(notification_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'app_id'] = app_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'NotificationWithMeta'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_notification",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_notification\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_notifications(app_id, opts = {}) ⇒ NotificationSlice

View notifications View the details of multiple notifications

Parameters:

  • app_id (String)

    The app ID that you want to view notifications from

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    How many notifications to return. Max is 50. Default is 50.

  • :offset (Integer)

    Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at.

  • :kind (Integer)

    Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only

  • :time_offset (String)

    Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned.

Returns:



1893
1894
1895
1896
# File 'lib/onesignal/api/default_api.rb', line 1893

def get_notifications(app_id, opts = {})
  data, _status_code, _headers = get_notifications_with_http_info(app_id, opts)
  data
end

#get_notifications_with_http_info(app_id, opts = {}) ⇒ Array<(NotificationSlice, Integer, Hash)>

View notifications View the details of multiple notifications

Parameters:

  • app_id (String)

    The app ID that you want to view notifications from

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    How many notifications to return. Max is 50. Default is 50.

  • :offset (Integer)

    Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at.

  • :kind (Integer)

    Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only

  • :time_offset (String)

    Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned.

Returns:

  • (Array<(NotificationSlice, Integer, Hash)>)

    NotificationSlice data, response status code and response headers



1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
# File 'lib/onesignal/api/default_api.rb', line 1907

def get_notifications_with_http_info(app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_notifications ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_notifications"
  end
  allowable_values = [0, 1, 3]
  if @api_client.config.client_side_validation && opts[:'kind'] && !allowable_values.include?(opts[:'kind'])
    fail ArgumentError, "invalid value for \"kind\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/notifications'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'app_id'] = app_id
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'kind'] = opts[:'kind'] if !opts[:'kind'].nil?
  query_params[:'time_offset'] = opts[:'time_offset'] if !opts[:'time_offset'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'NotificationSlice'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_notifications",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_notifications\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_outcomes(app_id, outcome_names, opts = {}) ⇒ OutcomesData

View Outcomes View the details of all the outcomes associated with your app đźš§ Requires Authentication Key Requires your OneSignal App's REST API Key, available in Keys & IDs. đźš§ Outcome Data Limitations Outcomes are only accessible for around 30 days before deleted from our servers. You will need to export this data every month if you want to keep it.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • outcome_names (String)

    Required Comma-separated list of names and the value (sum/count) for the returned outcome data. Note: Clicks only support count aggregation. For out-of-the-box OneSignal outcomes such as click and session duration, please use the &quot;os&quot; prefix with two underscores. For other outcomes, please use the name specified by the user. Example:os__session_duration.count,os__click.count,CustomOutcomeName.sum

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :outcome_names2 (String)

    Optional If outcome names contain any commas, then please specify only one value at a time. Example: outcome_names=os__click.count&outcome_names=Sales, Purchase.count where &quot;Sales, Purchase&quot; is the custom outcomes with a comma in the name.

  • :outcome_time_range (String)

    Optional Time range for the returned data. The values can be 1h (for the last 1 hour data), 1d (for the last 1 day data), or 1mo (for the last 1 month data). Default is 1h if the parameter is omitted.

  • :outcome_platforms (String)

    Optional Platform id. Refer device's platform ids for values. Example: outcome_platform=0 for iOS outcome_platform=7,8 for Safari and Firefox Default is data from all platforms if the parameter is omitted.

  • :outcome_attribution (String)

    Optional Attribution type for the outcomes. The values can be direct or influenced or unattributed. Example: outcome_attribution=direct Default is total (returns direct+influenced+unattributed) if the parameter is omitted.

Returns:



1974
1975
1976
1977
# File 'lib/onesignal/api/default_api.rb', line 1974

def get_outcomes(app_id, outcome_names, opts = {})
  data, _status_code, _headers = get_outcomes_with_http_info(app_id, outcome_names, opts)
  data
end

#get_outcomes_with_http_info(app_id, outcome_names, opts = {}) ⇒ Array<(OutcomesData, Integer, Hash)>

View Outcomes View the details of all the outcomes associated with your app &#x1F6A7; Requires Authentication Key Requires your OneSignal App's REST API Key, available in Keys & IDs. &#x1F6A7; Outcome Data Limitations Outcomes are only accessible for around 30 days before deleted from our servers. You will need to export this data every month if you want to keep it.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • outcome_names (String)

    Required Comma-separated list of names and the value (sum/count) for the returned outcome data. Note: Clicks only support count aggregation. For out-of-the-box OneSignal outcomes such as click and session duration, please use the &quot;os&quot; prefix with two underscores. For other outcomes, please use the name specified by the user. Example:os__session_duration.count,os__click.count,CustomOutcomeName.sum

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :outcome_names2 (String)

    Optional If outcome names contain any commas, then please specify only one value at a time. Example: outcome_names=os__click.count&outcome_names=Sales, Purchase.count where &quot;Sales, Purchase&quot; is the custom outcomes with a comma in the name.

  • :outcome_time_range (String)

    Optional Time range for the returned data. The values can be 1h (for the last 1 hour data), 1d (for the last 1 day data), or 1mo (for the last 1 month data). Default is 1h if the parameter is omitted.

  • :outcome_platforms (String)

    Optional Platform id. Refer device's platform ids for values. Example: outcome_platform=0 for iOS outcome_platform=7,8 for Safari and Firefox Default is data from all platforms if the parameter is omitted.

  • :outcome_attribution (String)

    Optional Attribution type for the outcomes. The values can be direct or influenced or unattributed. Example: outcome_attribution=direct Default is total (returns direct+influenced+unattributed) if the parameter is omitted.

Returns:

  • (Array<(OutcomesData, Integer, Hash)>)

    OutcomesData data, response status code and response headers



1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
# File 'lib/onesignal/api/default_api.rb', line 1989

def get_outcomes_with_http_info(app_id, outcome_names, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_outcomes ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_outcomes"
  end
  # verify the required parameter 'outcome_names' is set
  if @api_client.config.client_side_validation && outcome_names.nil?
    fail ArgumentError, "Missing the required parameter 'outcome_names' when calling DefaultApi.get_outcomes"
  end
  # resource path
  local_var_path = '/apps/{app_id}/outcomes'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'outcome_names'] = outcome_names
  query_params[:'outcome_names[]'] = opts[:'outcome_names2'] if !opts[:'outcome_names2'].nil?
  query_params[:'outcome_time_range'] = opts[:'outcome_time_range'] if !opts[:'outcome_time_range'].nil?
  query_params[:'outcome_platforms'] = opts[:'outcome_platforms'] if !opts[:'outcome_platforms'].nil?
  query_params[:'outcome_attribution'] = opts[:'outcome_attribution'] if !opts[:'outcome_attribution'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'OutcomesData'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_outcomes",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_outcomes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_segment(app_id, segment_id, opts = {}) ⇒ GetSegmentSuccessResponse

View Segment Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • segment_id (String)

    The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :include_segment_detail (Boolean)

    Set to true to include segment metadata and filters in the response.

Returns:



2053
2054
2055
2056
# File 'lib/onesignal/api/default_api.rb', line 2053

def get_segment(app_id, segment_id, opts = {})
  data, _status_code, _headers = get_segment_with_http_info(app_id, segment_id, opts)
  data
end

#get_segment_with_http_info(app_id, segment_id, opts = {}) ⇒ Array<(GetSegmentSuccessResponse, Integer, Hash)>

View Segment Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • segment_id (String)

    The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :include_segment_detail (Boolean)

    Set to true to include segment metadata and filters in the response.

Returns:

  • (Array<(GetSegmentSuccessResponse, Integer, Hash)>)

    GetSegmentSuccessResponse data, response status code and response headers



2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
# File 'lib/onesignal/api/default_api.rb', line 2065

def get_segment_with_http_info(app_id, segment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_segment ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_segment"
  end
  # verify the required parameter 'segment_id' is set
  if @api_client.config.client_side_validation && segment_id.nil?
    fail ArgumentError, "Missing the required parameter 'segment_id' when calling DefaultApi.get_segment"
  end
  # resource path
  local_var_path = '/apps/{app_id}/segments/{segment_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'segment_id' + '}', CGI.escape(segment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'include-segment-detail'] = opts[:'include_segment_detail'] if !opts[:'include_segment_detail'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetSegmentSuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_segment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_segment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_segments(app_id, opts = {}) ⇒ GetSegmentsSuccessResponse

Get Segments Returns an array of segments from an app.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :offset (Integer)

    Segments are listed in ascending order of created_at date. offset will omit that number of segments from the beginning of the list. Eg offset 5, will remove the 5 earliest created Segments.

  • :limit (Integer)

    The amount of Segments in the response. Maximum 300.

Returns:



2125
2126
2127
2128
# File 'lib/onesignal/api/default_api.rb', line 2125

def get_segments(app_id, opts = {})
  data, _status_code, _headers = get_segments_with_http_info(app_id, opts)
  data
end

#get_segments_with_http_info(app_id, opts = {}) ⇒ Array<(GetSegmentsSuccessResponse, Integer, Hash)>

Get Segments Returns an array of segments from an app.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :offset (Integer)

    Segments are listed in ascending order of created_at date. offset will omit that number of segments from the beginning of the list. Eg offset 5, will remove the 5 earliest created Segments.

  • :limit (Integer)

    The amount of Segments in the response. Maximum 300.

Returns:

  • (Array<(GetSegmentsSuccessResponse, Integer, Hash)>)

    GetSegmentsSuccessResponse data, response status code and response headers



2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
# File 'lib/onesignal/api/default_api.rb', line 2137

def get_segments_with_http_info(app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_segments ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_segments"
  end
  # resource path
  local_var_path = '/apps/{app_id}/segments'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetSegmentsSuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_segments",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_segments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_user(app_id, alias_label, alias_id, opts = {}) ⇒ User

Returns the User’s properties, Aliases, and Subscriptions.

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



2193
2194
2195
2196
# File 'lib/onesignal/api/default_api.rb', line 2193

def get_user(app_id, alias_label, alias_id, opts = {})
  data, _status_code, _headers = get_user_with_http_info(app_id, alias_label, alias_id, opts)
  data
end

#get_user_with_http_info(app_id, alias_label, alias_id, opts = {}) ⇒ Array<(User, Integer, Hash)>

Returns the User’s properties, Aliases, and Subscriptions.

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(User, Integer, Hash)>)

    User data, response status code and response headers



2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
# File 'lib/onesignal/api/default_api.rb', line 2204

def get_user_with_http_info(app_id, alias_label, alias_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.get_user ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.get_user"
  end
  # verify the required parameter 'alias_label' is set
  if @api_client.config.client_side_validation && alias_label.nil?
    fail ArgumentError, "Missing the required parameter 'alias_label' when calling DefaultApi.get_user"
  end
  # verify the required parameter 'alias_id' is set
  if @api_client.config.client_side_validation && alias_id.nil?
    fail ArgumentError, "Missing the required parameter 'alias_id' when calling DefaultApi.get_user"
  end
  # resource path
  local_var_path = '/apps/{app_id}/users/by/{alias_label}/{alias_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'alias_label' + '}', CGI.escape(alias_label.to_s)).sub('{' + 'alias_id' + '}', CGI.escape(alias_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'User'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.get_user",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_audit_logs(organization_id, opts = {}) ⇒ ListAuditLogsSuccessResponse

List audit logs Retrieve a paginated, time-scoped list of audit log events for an organization. Requires an Enterprise plan with the audit logs entitlement enabled.

Parameters:

  • organization_id (String)

    The UUID of the organization to retrieve audit logs for. Must match the authenticated Organization API Key.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start_time (String)

    Start of the time range in ISO 8601 format (e.g. 2026-02-01T00:00:00Z). Required unless cursor is provided. Must be within the last 90 days.

  • :end_time (String)

    End of the time range in ISO 8601 format. Defaults to the current time. Must be after start_time.

  • :cursor (String)

    Pagination cursor returned in a previous response as next_cursor. When provided, start_time and end_time are ignored.

  • :limit (Integer)

    Maximum number of events to return per page. Minimum 1, maximum 100. Values outside this range are clamped automatically by the server.

  • :app_ids (Array<String>)

    Filter events by app UUID. Accepts up to 10 values. Org-level events are always included.

  • :actions (Array<String>)

    Filter by action type (e.g. notification.sent, segment.created). Accepts up to 20 values.

  • :actor_ids (Array<String>)

    Filter by actor UUID (the user or service that performed the action). Accepts up to 10 values.

  • :actor_emails (Array<String>)

    Filter by actor email address. Accepts up to 10 values.

  • :target_types (Array<String>)

    Filter by the type of resource the action was performed on (e.g. notification, segment, journey). Accepts up to 10 values.

  • :target_ids (Array<String>)

    Filter by the UUID of the resource the action was performed on. Accepts up to 10 values.

  • :ip_addresses (Array<String>)

    Filter by the IP address the action originated from. Accepts up to 10 values.

Returns:



2276
2277
2278
2279
# File 'lib/onesignal/api/default_api.rb', line 2276

def list_audit_logs(organization_id, opts = {})
  data, _status_code, _headers = list_audit_logs_with_http_info(organization_id, opts)
  data
end

#list_audit_logs_with_http_info(organization_id, opts = {}) ⇒ Array<(ListAuditLogsSuccessResponse, Integer, Hash)>

List audit logs Retrieve a paginated, time-scoped list of audit log events for an organization. Requires an Enterprise plan with the audit logs entitlement enabled.

Parameters:

  • organization_id (String)

    The UUID of the organization to retrieve audit logs for. Must match the authenticated Organization API Key.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start_time (String)

    Start of the time range in ISO 8601 format (e.g. 2026-02-01T00:00:00Z). Required unless cursor is provided. Must be within the last 90 days.

  • :end_time (String)

    End of the time range in ISO 8601 format. Defaults to the current time. Must be after start_time.

  • :cursor (String)

    Pagination cursor returned in a previous response as next_cursor. When provided, start_time and end_time are ignored.

  • :limit (Integer)

    Maximum number of events to return per page. Minimum 1, maximum 100. Values outside this range are clamped automatically by the server.

  • :app_ids (Array<String>)

    Filter events by app UUID. Accepts up to 10 values. Org-level events are always included.

  • :actions (Array<String>)

    Filter by action type (e.g. notification.sent, segment.created). Accepts up to 20 values.

  • :actor_ids (Array<String>)

    Filter by actor UUID (the user or service that performed the action). Accepts up to 10 values.

  • :actor_emails (Array<String>)

    Filter by actor email address. Accepts up to 10 values.

  • :target_types (Array<String>)

    Filter by the type of resource the action was performed on (e.g. notification, segment, journey). Accepts up to 10 values.

  • :target_ids (Array<String>)

    Filter by the UUID of the resource the action was performed on. Accepts up to 10 values.

  • :ip_addresses (Array<String>)

    Filter by the IP address the action originated from. Accepts up to 10 values.

Returns:



2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
# File 'lib/onesignal/api/default_api.rb', line 2297

def list_audit_logs_with_http_info(organization_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.list_audit_logs ...'
  end
  # verify the required parameter 'organization_id' is set
  if @api_client.config.client_side_validation && organization_id.nil?
    fail ArgumentError, "Missing the required parameter 'organization_id' when calling DefaultApi.list_audit_logs"
  end
  if @api_client.config.client_side_validation && !opts[:'app_ids'].nil? && opts[:'app_ids'].length > 10
    fail ArgumentError, 'invalid value for "opts[:"app_ids"]" when calling DefaultApi.list_audit_logs, number of items must be less than or equal to 10.'
  end

  if @api_client.config.client_side_validation && !opts[:'actions'].nil? && opts[:'actions'].length > 20
    fail ArgumentError, 'invalid value for "opts[:"actions"]" when calling DefaultApi.list_audit_logs, number of items must be less than or equal to 20.'
  end

  if @api_client.config.client_side_validation && !opts[:'actor_ids'].nil? && opts[:'actor_ids'].length > 10
    fail ArgumentError, 'invalid value for "opts[:"actor_ids"]" when calling DefaultApi.list_audit_logs, number of items must be less than or equal to 10.'
  end

  if @api_client.config.client_side_validation && !opts[:'actor_emails'].nil? && opts[:'actor_emails'].length > 10
    fail ArgumentError, 'invalid value for "opts[:"actor_emails"]" when calling DefaultApi.list_audit_logs, number of items must be less than or equal to 10.'
  end

  if @api_client.config.client_side_validation && !opts[:'target_types'].nil? && opts[:'target_types'].length > 10
    fail ArgumentError, 'invalid value for "opts[:"target_types"]" when calling DefaultApi.list_audit_logs, number of items must be less than or equal to 10.'
  end

  if @api_client.config.client_side_validation && !opts[:'target_ids'].nil? && opts[:'target_ids'].length > 10
    fail ArgumentError, 'invalid value for "opts[:"target_ids"]" when calling DefaultApi.list_audit_logs, number of items must be less than or equal to 10.'
  end

  if @api_client.config.client_side_validation && !opts[:'ip_addresses'].nil? && opts[:'ip_addresses'].length > 10
    fail ArgumentError, 'invalid value for "opts[:"ip_addresses"]" when calling DefaultApi.list_audit_logs, number of items must be less than or equal to 10.'
  end

  # resource path
  local_var_path = '/organizations/{organization_id}/audit_logs'.sub('{' + 'organization_id' + '}', CGI.escape(organization_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = opts[:'start_time'] if !opts[:'start_time'].nil?
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'app_ids'] = @api_client.build_collection_param(opts[:'app_ids'], :multi) if !opts[:'app_ids'].nil?
  query_params[:'actions'] = @api_client.build_collection_param(opts[:'actions'], :multi) if !opts[:'actions'].nil?
  query_params[:'actor_ids'] = @api_client.build_collection_param(opts[:'actor_ids'], :multi) if !opts[:'actor_ids'].nil?
  query_params[:'actor_emails'] = @api_client.build_collection_param(opts[:'actor_emails'], :multi) if !opts[:'actor_emails'].nil?
  query_params[:'target_types'] = @api_client.build_collection_param(opts[:'target_types'], :multi) if !opts[:'target_types'].nil?
  query_params[:'target_ids'] = @api_client.build_collection_param(opts[:'target_ids'], :multi) if !opts[:'target_ids'].nil?
  query_params[:'ip_addresses'] = @api_client.build_collection_param(opts[:'ip_addresses'], :multi) if !opts[:'ip_addresses'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListAuditLogsSuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.list_audit_logs",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#list_audit_logs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#rotate_api_key(app_id, token_id, opts = {}) ⇒ CreateApiKeyResponse

Rotate API key Rotate a Rich Authentication Token (App API Key) for a OneSignal app. Rotating a key revokes the current token and generates a new one under the same configuration—ideal when a token is lost or compromised but you don’t want to recreate and reconfigure it from scratch.

Parameters:

  • app_id (String)
  • token_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



2390
2391
2392
2393
# File 'lib/onesignal/api/default_api.rb', line 2390

def rotate_api_key(app_id, token_id, opts = {})
  data, _status_code, _headers = rotate_api_key_with_http_info(app_id, token_id, opts)
  data
end

#rotate_api_key_with_http_info(app_id, token_id, opts = {}) ⇒ Array<(CreateApiKeyResponse, Integer, Hash)>

Rotate API key Rotate a Rich Authentication Token (App API Key) for a OneSignal app. Rotating a key revokes the current token and generates a new one under the same configuration—ideal when a token is lost or compromised but you don’t want to recreate and reconfigure it from scratch.

Parameters:

  • app_id (String)
  • token_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(CreateApiKeyResponse, Integer, Hash)>)

    CreateApiKeyResponse data, response status code and response headers



2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
# File 'lib/onesignal/api/default_api.rb', line 2401

def rotate_api_key_with_http_info(app_id, token_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.rotate_api_key ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.rotate_api_key"
  end
  # verify the required parameter 'token_id' is set
  if @api_client.config.client_side_validation && token_id.nil?
    fail ArgumentError, "Missing the required parameter 'token_id' when calling DefaultApi.rotate_api_key"
  end
  # resource path
  local_var_path = '/apps/{app_id}/auth/tokens/{token_id}/rotate'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'token_id' + '}', CGI.escape(token_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'CreateApiKeyResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.rotate_api_key",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#rotate_api_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#start_live_activity(app_id, activity_type, start_live_activity_request, opts = {}) ⇒ StartLiveActivitySuccessResponse

Start Live Activity Remotely start a Live Activity on iOS devices via OneSignal’s REST API.

Parameters:

  • app_id (String)

    Your OneSignal App ID in UUID v4 format.

  • activity_type (String)

    The name of the Live Activity defined in your app. This should match the attributes struct used in your app's Live Activity implementation.

  • start_live_activity_request (StartLiveActivityRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



2460
2461
2462
2463
# File 'lib/onesignal/api/default_api.rb', line 2460

def start_live_activity(app_id, activity_type, start_live_activity_request, opts = {})
  data, _status_code, _headers = start_live_activity_with_http_info(app_id, activity_type, start_live_activity_request, opts)
  data
end

#start_live_activity_with_http_info(app_id, activity_type, start_live_activity_request, opts = {}) ⇒ Array<(StartLiveActivitySuccessResponse, Integer, Hash)>

Start Live Activity Remotely start a Live Activity on iOS devices via OneSignal’s REST API.

Parameters:

  • app_id (String)

    Your OneSignal App ID in UUID v4 format.

  • activity_type (String)

    The name of the Live Activity defined in your app. This should match the attributes struct used in your app's Live Activity implementation.

  • start_live_activity_request (StartLiveActivityRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
# File 'lib/onesignal/api/default_api.rb', line 2472

def start_live_activity_with_http_info(app_id, activity_type, start_live_activity_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.start_live_activity ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.start_live_activity"
  end
  # verify the required parameter 'activity_type' is set
  if @api_client.config.client_side_validation && activity_type.nil?
    fail ArgumentError, "Missing the required parameter 'activity_type' when calling DefaultApi.start_live_activity"
  end
  # verify the required parameter 'start_live_activity_request' is set
  if @api_client.config.client_side_validation && start_live_activity_request.nil?
    fail ArgumentError, "Missing the required parameter 'start_live_activity_request' when calling DefaultApi.start_live_activity"
  end
  # resource path
  local_var_path = '/apps/{app_id}/activities/activity/{activity_type}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'activity_type' + '}', CGI.escape(activity_type.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(start_live_activity_request)

  # return_type
  return_type = opts[:debug_return_type] || 'StartLiveActivitySuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.start_live_activity",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#start_live_activity\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#transfer_subscription(app_id, subscription_id, transfer_subscription_request_body, opts = {}) ⇒ UserIdentityBody

Transfers this Subscription to the User identified by the identity in the payload.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • transfer_subscription_request_body (TransferSubscriptionRequestBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



2539
2540
2541
2542
# File 'lib/onesignal/api/default_api.rb', line 2539

def transfer_subscription(app_id, subscription_id, transfer_subscription_request_body, opts = {})
  data, _status_code, _headers = transfer_subscription_with_http_info(app_id, subscription_id, transfer_subscription_request_body, opts)
  data
end

#transfer_subscription_with_http_info(app_id, subscription_id, transfer_subscription_request_body, opts = {}) ⇒ Array<(UserIdentityBody, Integer, Hash)>

Transfers this Subscription to the User identified by the identity in the payload.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • transfer_subscription_request_body (TransferSubscriptionRequestBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(UserIdentityBody, Integer, Hash)>)

    UserIdentityBody data, response status code and response headers



2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
# File 'lib/onesignal/api/default_api.rb', line 2550

def transfer_subscription_with_http_info(app_id, subscription_id, transfer_subscription_request_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.transfer_subscription ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.transfer_subscription"
  end
  # verify the required parameter 'subscription_id' is set
  if @api_client.config.client_side_validation && subscription_id.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_id' when calling DefaultApi.transfer_subscription"
  end
  # verify the required parameter 'transfer_subscription_request_body' is set
  if @api_client.config.client_side_validation && transfer_subscription_request_body.nil?
    fail ArgumentError, "Missing the required parameter 'transfer_subscription_request_body' when calling DefaultApi.transfer_subscription"
  end
  # resource path
  local_var_path = '/apps/{app_id}/subscriptions/{subscription_id}/owner'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'subscription_id' + '}', CGI.escape(subscription_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(transfer_subscription_request_body)

  # return_type
  return_type = opts[:debug_return_type] || 'UserIdentityBody'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.transfer_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#transfer_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#unsubscribe_email_with_token(app_id, notification_id, token, opts = {}) ⇒ GenericSuccessBoolResponse

Unsubscribe with token Unsubscribe an email with a token when using your own custom email unsubscribe landing page

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • notification_id (String)

    The id of the message found in the creation notification POST response, View Notifications GET response, or URL within the Message Report.

  • token (String)

    The unsubscribe token that is generated via liquid syntax in OneSignal::DefaultApi.{subscription{subscription.unsubscribe_token} when personalizing an email.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



2618
2619
2620
2621
# File 'lib/onesignal/api/default_api.rb', line 2618

def unsubscribe_email_with_token(app_id, notification_id, token, opts = {})
  data, _status_code, _headers = unsubscribe_email_with_token_with_http_info(app_id, notification_id, token, opts)
  data
end

#unsubscribe_email_with_token_with_http_info(app_id, notification_id, token, opts = {}) ⇒ Array<(GenericSuccessBoolResponse, Integer, Hash)>

Unsubscribe with token Unsubscribe an email with a token when using your own custom email unsubscribe landing page

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • notification_id (String)

    The id of the message found in the creation notification POST response, View Notifications GET response, or URL within the Message Report.

  • token (String)

    The unsubscribe token that is generated via liquid syntax in OneSignal::DefaultApi.{subscription{subscription.unsubscribe_token} when personalizing an email.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(GenericSuccessBoolResponse, Integer, Hash)>)

    GenericSuccessBoolResponse data, response status code and response headers



2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
# File 'lib/onesignal/api/default_api.rb', line 2630

def unsubscribe_email_with_token_with_http_info(app_id, notification_id, token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.unsubscribe_email_with_token ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.unsubscribe_email_with_token"
  end
  # verify the required parameter 'notification_id' is set
  if @api_client.config.client_side_validation && notification_id.nil?
    fail ArgumentError, "Missing the required parameter 'notification_id' when calling DefaultApi.unsubscribe_email_with_token"
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling DefaultApi.unsubscribe_email_with_token"
  end
  # resource path
  local_var_path = '/apps/{app_id}/notifications/{notification_id}/unsubscribe'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'notification_id' + '}', CGI.escape(notification_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'token'] = token

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GenericSuccessBoolResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.unsubscribe_email_with_token",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#unsubscribe_email_with_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_api_key(app_id, token_id, update_api_key_request, opts = {}) ⇒ Object

Update API key Update a Rich Authentication Token (App API Key) for a OneSignal app.

Parameters:

  • app_id (String)
  • token_id (String)
  • update_api_key_request (UpdateApiKeyRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


2694
2695
2696
2697
# File 'lib/onesignal/api/default_api.rb', line 2694

def update_api_key(app_id, token_id, update_api_key_request, opts = {})
  data, _status_code, _headers = update_api_key_with_http_info(app_id, token_id, update_api_key_request, opts)
  data
end

#update_api_key_with_http_info(app_id, token_id, update_api_key_request, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Update API key Update a Rich Authentication Token (App API Key) for a OneSignal app.

Parameters:

  • app_id (String)
  • token_id (String)
  • update_api_key_request (UpdateApiKeyRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
# File 'lib/onesignal/api/default_api.rb', line 2706

def update_api_key_with_http_info(app_id, token_id, update_api_key_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.update_api_key ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.update_api_key"
  end
  # verify the required parameter 'token_id' is set
  if @api_client.config.client_side_validation && token_id.nil?
    fail ArgumentError, "Missing the required parameter 'token_id' when calling DefaultApi.update_api_key"
  end
  # verify the required parameter 'update_api_key_request' is set
  if @api_client.config.client_side_validation && update_api_key_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_api_key_request' when calling DefaultApi.update_api_key"
  end
  # resource path
  local_var_path = '/apps/{app_id}/auth/tokens/{token_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'token_id' + '}', CGI.escape(token_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_api_key_request)

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.update_api_key",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#update_api_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_app(app_id, app, opts = {}) ⇒ App

Update an app Updates the name or configuration settings of an existing OneSignal app

Parameters:

  • app_id (String)

    An app id

  • app (App)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



2773
2774
2775
2776
# File 'lib/onesignal/api/default_api.rb', line 2773

def update_app(app_id, app, opts = {})
  data, _status_code, _headers = update_app_with_http_info(app_id, app, opts)
  data
end

#update_app_with_http_info(app_id, app, opts = {}) ⇒ Array<(App, Integer, Hash)>

Update an app Updates the name or configuration settings of an existing OneSignal app

Parameters:

  • app_id (String)

    An app id

  • app (App)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(App, Integer, Hash)>)

    App data, response status code and response headers



2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
# File 'lib/onesignal/api/default_api.rb', line 2784

def update_app_with_http_info(app_id, app, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.update_app ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.update_app"
  end
  # verify the required parameter 'app' is set
  if @api_client.config.client_side_validation && app.nil?
    fail ArgumentError, "Missing the required parameter 'app' when calling DefaultApi.update_app"
  end
  # resource path
  local_var_path = '/apps/{app_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(app)

  # return_type
  return_type = opts[:debug_return_type] || 'App'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.update_app",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#update_app\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_live_activity(app_id, activity_id, update_live_activity_request, opts = {}) ⇒ UpdateLiveActivitySuccessResponse

Update a Live Activity via Push Updates a specified live activity.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • activity_id (String)

    Live Activity record ID

  • update_live_activity_request (UpdateLiveActivityRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



2848
2849
2850
2851
# File 'lib/onesignal/api/default_api.rb', line 2848

def update_live_activity(app_id, activity_id, update_live_activity_request, opts = {})
  data, _status_code, _headers = update_live_activity_with_http_info(app_id, activity_id, update_live_activity_request, opts)
  data
end

#update_live_activity_with_http_info(app_id, activity_id, update_live_activity_request, opts = {}) ⇒ Array<(UpdateLiveActivitySuccessResponse, Integer, Hash)>

Update a Live Activity via Push Updates a specified live activity.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • activity_id (String)

    Live Activity record ID

  • update_live_activity_request (UpdateLiveActivityRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
# File 'lib/onesignal/api/default_api.rb', line 2860

def update_live_activity_with_http_info(app_id, activity_id, update_live_activity_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.update_live_activity ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.update_live_activity"
  end
  # verify the required parameter 'activity_id' is set
  if @api_client.config.client_side_validation && activity_id.nil?
    fail ArgumentError, "Missing the required parameter 'activity_id' when calling DefaultApi.update_live_activity"
  end
  # verify the required parameter 'update_live_activity_request' is set
  if @api_client.config.client_side_validation && update_live_activity_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_live_activity_request' when calling DefaultApi.update_live_activity"
  end
  # resource path
  local_var_path = '/apps/{app_id}/live_activities/{activity_id}/notifications'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'activity_id' + '}', CGI.escape(activity_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_live_activity_request)

  # return_type
  return_type = opts[:debug_return_type] || 'UpdateLiveActivitySuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.update_live_activity",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#update_live_activity\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_segment(app_id, segment_id, opts = {}) ⇒ UpdateSegmentSuccessResponse

Update Segment Update an existing segment's name and/or filters. The name parameter is always required. When filters are provided, all existing filters are replaced with the new ones.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • segment_id (String)

    The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



2928
2929
2930
2931
# File 'lib/onesignal/api/default_api.rb', line 2928

def update_segment(app_id, segment_id, opts = {})
  data, _status_code, _headers = update_segment_with_http_info(app_id, segment_id, opts)
  data
end

#update_segment_with_http_info(app_id, segment_id, opts = {}) ⇒ Array<(UpdateSegmentSuccessResponse, Integer, Hash)>

Update Segment Update an existing segment's name and/or filters. The name parameter is always required. When filters are provided, all existing filters are replaced with the new ones.

Parameters:

  • app_id (String)

    The OneSignal App ID for your app. Available in Keys & IDs.

  • segment_id (String)

    The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
# File 'lib/onesignal/api/default_api.rb', line 2940

def update_segment_with_http_info(app_id, segment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.update_segment ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.update_segment"
  end
  # verify the required parameter 'segment_id' is set
  if @api_client.config.client_side_validation && segment_id.nil?
    fail ArgumentError, "Missing the required parameter 'segment_id' when calling DefaultApi.update_segment"
  end
  # resource path
  local_var_path = '/apps/{app_id}/segments/{segment_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'segment_id' + '}', CGI.escape(segment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'update_segment_request'])

  # return_type
  return_type = opts[:debug_return_type] || 'UpdateSegmentSuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.update_segment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#update_segment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_subscription(app_id, subscription_id, subscription_body, opts = {}) ⇒ nil

Updates an existing Subscription’s properties.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • subscription_body (SubscriptionBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


3003
3004
3005
3006
# File 'lib/onesignal/api/default_api.rb', line 3003

def update_subscription(app_id, subscription_id, subscription_body, opts = {})
  update_subscription_with_http_info(app_id, subscription_id, subscription_body, opts)
  nil
end

#update_subscription_by_token(app_id, token_type, token, subscription_body, opts = {}) ⇒ Object

Update subscription by token Update properties on an existing OneSignal subscription using its token.

Parameters:

  • app_id (String)

    Your OneSignal App ID in UUID v4 format.

  • token_type (String)

    The type of token to use when looking up the subscription. See Subscription Types.

  • token (String)

    The value of the token to lookup by (e.g., email address, phone number).

  • subscription_body (SubscriptionBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


3083
3084
3085
3086
# File 'lib/onesignal/api/default_api.rb', line 3083

def update_subscription_by_token(app_id, token_type, token, subscription_body, opts = {})
  data, _status_code, _headers = update_subscription_by_token_with_http_info(app_id, token_type, token, subscription_body, opts)
  data
end

#update_subscription_by_token_with_http_info(app_id, token_type, token, subscription_body, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Update subscription by token Update properties on an existing OneSignal subscription using its token.

Parameters:

  • app_id (String)

    Your OneSignal App ID in UUID v4 format.

  • token_type (String)

    The type of token to use when looking up the subscription. See Subscription Types.

  • token (String)

    The value of the token to lookup by (e.g., email address, phone number).

  • subscription_body (SubscriptionBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
# File 'lib/onesignal/api/default_api.rb', line 3096

def update_subscription_by_token_with_http_info(app_id, token_type, token, subscription_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.update_subscription_by_token ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.update_subscription_by_token"
  end
  # verify the required parameter 'token_type' is set
  if @api_client.config.client_side_validation && token_type.nil?
    fail ArgumentError, "Missing the required parameter 'token_type' when calling DefaultApi.update_subscription_by_token"
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling DefaultApi.update_subscription_by_token"
  end
  # verify the required parameter 'subscription_body' is set
  if @api_client.config.client_side_validation && subscription_body.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_body' when calling DefaultApi.update_subscription_by_token"
  end
  # resource path
  local_var_path = '/apps/{app_id}/subscriptions_by_token/{token_type}/{token}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'token_type' + '}', CGI.escape(token_type.to_s)).sub('{' + 'token' + '}', CGI.escape(token.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(subscription_body)

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.update_subscription_by_token",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#update_subscription_by_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_subscription_with_http_info(app_id, subscription_id, subscription_body, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Updates an existing Subscription’s properties.

Parameters:

  • app_id (String)
  • subscription_id (String)
  • subscription_body (SubscriptionBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
# File 'lib/onesignal/api/default_api.rb', line 3014

def update_subscription_with_http_info(app_id, subscription_id, subscription_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.update_subscription ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.update_subscription"
  end
  # verify the required parameter 'subscription_id' is set
  if @api_client.config.client_side_validation && subscription_id.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_id' when calling DefaultApi.update_subscription"
  end
  # verify the required parameter 'subscription_body' is set
  if @api_client.config.client_side_validation && subscription_body.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_body' when calling DefaultApi.update_subscription"
  end
  # resource path
  local_var_path = '/apps/{app_id}/subscriptions/{subscription_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'subscription_id' + '}', CGI.escape(subscription_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(subscription_body)

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.update_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#update_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_template(template_id, app_id, update_template_request, opts = {}) ⇒ TemplateResource

Update template Update an existing template.

Parameters:

  • template_id (String)
  • app_id (String)
  • update_template_request (UpdateTemplateRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



3168
3169
3170
3171
# File 'lib/onesignal/api/default_api.rb', line 3168

def update_template(template_id, app_id, update_template_request, opts = {})
  data, _status_code, _headers = update_template_with_http_info(template_id, app_id, update_template_request, opts)
  data
end

#update_template_with_http_info(template_id, app_id, update_template_request, opts = {}) ⇒ Array<(TemplateResource, Integer, Hash)>

Update template Update an existing template.

Parameters:

  • template_id (String)
  • app_id (String)
  • update_template_request (UpdateTemplateRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateResource, Integer, Hash)>)

    TemplateResource data, response status code and response headers



3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
# File 'lib/onesignal/api/default_api.rb', line 3180

def update_template_with_http_info(template_id, app_id, update_template_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.update_template ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling DefaultApi.update_template"
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.update_template"
  end
  # verify the required parameter 'update_template_request' is set
  if @api_client.config.client_side_validation && update_template_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_template_request' when calling DefaultApi.update_template"
  end
  # resource path
  local_var_path = '/templates/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'app_id'] = app_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_template_request)

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateResource'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.update_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#update_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_user(app_id, alias_label, alias_id, update_user_request, opts = {}) ⇒ PropertiesBody

Updates an existing User’s properties.

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • update_user_request (UpdateUserRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



3249
3250
3251
3252
# File 'lib/onesignal/api/default_api.rb', line 3249

def update_user(app_id, alias_label, alias_id, update_user_request, opts = {})
  data, _status_code, _headers = update_user_with_http_info(app_id, alias_label, alias_id, update_user_request, opts)
  data
end

#update_user_with_http_info(app_id, alias_label, alias_id, update_user_request, opts = {}) ⇒ Array<(PropertiesBody, Integer, Hash)>

Updates an existing User’s properties.

Parameters:

  • app_id (String)
  • alias_label (String)
  • alias_id (String)
  • update_user_request (UpdateUserRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(PropertiesBody, Integer, Hash)>)

    PropertiesBody data, response status code and response headers



3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
# File 'lib/onesignal/api/default_api.rb', line 3261

def update_user_with_http_info(app_id, alias_label, alias_id, update_user_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.update_user ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.update_user"
  end
  # verify the required parameter 'alias_label' is set
  if @api_client.config.client_side_validation && alias_label.nil?
    fail ArgumentError, "Missing the required parameter 'alias_label' when calling DefaultApi.update_user"
  end
  # verify the required parameter 'alias_id' is set
  if @api_client.config.client_side_validation && alias_id.nil?
    fail ArgumentError, "Missing the required parameter 'alias_id' when calling DefaultApi.update_user"
  end
  # verify the required parameter 'update_user_request' is set
  if @api_client.config.client_side_validation && update_user_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_user_request' when calling DefaultApi.update_user"
  end
  # resource path
  local_var_path = '/apps/{app_id}/users/by/{alias_label}/{alias_id}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'alias_label' + '}', CGI.escape(alias_label.to_s)).sub('{' + 'alias_id' + '}', CGI.escape(alias_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_user_request)

  # return_type
  return_type = opts[:debug_return_type] || 'PropertiesBody'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.update_user",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#update_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#view_api_keys(app_id, opts = {}) ⇒ ApiKeyTokensListResponse

View API keys View the details of all of your current app API keys (Rich Authentication Token) for a single OneSignal app.

Parameters:

  • app_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



3331
3332
3333
3334
# File 'lib/onesignal/api/default_api.rb', line 3331

def view_api_keys(app_id, opts = {})
  data, _status_code, _headers = view_api_keys_with_http_info(app_id, opts)
  data
end

#view_api_keys_with_http_info(app_id, opts = {}) ⇒ Array<(ApiKeyTokensListResponse, Integer, Hash)>

View API keys View the details of all of your current app API keys (Rich Authentication Token) for a single OneSignal app.

Parameters:

  • app_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(ApiKeyTokensListResponse, Integer, Hash)>)

    ApiKeyTokensListResponse data, response status code and response headers



3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
# File 'lib/onesignal/api/default_api.rb', line 3341

def view_api_keys_with_http_info(app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.view_api_keys ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.view_api_keys"
  end
  # resource path
  local_var_path = '/apps/{app_id}/auth/tokens'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ApiKeyTokensListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['organization_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.view_api_keys",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#view_api_keys\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#view_template(template_id, app_id, opts = {}) ⇒ TemplateResource

View template Fetch a single template by id.

Parameters:

  • template_id (String)
  • app_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



3395
3396
3397
3398
# File 'lib/onesignal/api/default_api.rb', line 3395

def view_template(template_id, app_id, opts = {})
  data, _status_code, _headers = view_template_with_http_info(template_id, app_id, opts)
  data
end

#view_template_with_http_info(template_id, app_id, opts = {}) ⇒ Array<(TemplateResource, Integer, Hash)>

View template Fetch a single template by id.

Parameters:

  • template_id (String)
  • app_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateResource, Integer, Hash)>)

    TemplateResource data, response status code and response headers



3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
# File 'lib/onesignal/api/default_api.rb', line 3406

def view_template_with_http_info(template_id, app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.view_template ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling DefaultApi.view_template"
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.view_template"
  end
  # resource path
  local_var_path = '/templates/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'app_id'] = app_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateResource'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.view_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#view_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#view_templates(app_id, opts = {}) ⇒ TemplatesListResponse

View templates List templates for an app.

Parameters:

  • app_id (String)

    Your OneSignal App ID in UUID v4 format.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Maximum number of templates. Default and max is 50. (default to 50)

  • :offset (Integer)

    Pagination offset. (default to 0)

  • :channel (String)

    Filter by delivery channel.

Returns:



3467
3468
3469
3470
# File 'lib/onesignal/api/default_api.rb', line 3467

def view_templates(app_id, opts = {})
  data, _status_code, _headers = view_templates_with_http_info(app_id, opts)
  data
end

#view_templates_with_http_info(app_id, opts = {}) ⇒ Array<(TemplatesListResponse, Integer, Hash)>

View templates List templates for an app.

Parameters:

  • app_id (String)

    Your OneSignal App ID in UUID v4 format.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Maximum number of templates. Default and max is 50. (default to 50)

  • :offset (Integer)

    Pagination offset. (default to 0)

  • :channel (String)

    Filter by delivery channel.

Returns:

  • (Array<(TemplatesListResponse, Integer, Hash)>)

    TemplatesListResponse data, response status code and response headers



3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
# File 'lib/onesignal/api/default_api.rb', line 3480

def view_templates_with_http_info(app_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.view_templates ...'
  end
  # verify the required parameter 'app_id' is set
  if @api_client.config.client_side_validation && app_id.nil?
    fail ArgumentError, "Missing the required parameter 'app_id' when calling DefaultApi.view_templates"
  end
  allowable_values = ["push", "email", "sms"]
  if @api_client.config.client_side_validation && opts[:'channel'] && !allowable_values.include?(opts[:'channel'])
    fail ArgumentError, "invalid value for \"channel\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/templates'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'app_id'] = app_id
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'channel'] = opts[:'channel'] if !opts[:'channel'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TemplatesListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['rest_api_key']

  new_options = opts.merge(
    :operation => :"DefaultApi.view_templates",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#view_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end