Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 55 additions & 184 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,215 +1,86 @@
# onesignal

OneSignal - the Ruby gem for the OneSignal
OneSignal - the Ruby gem for OneSignal

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 5.3.0
- Package version: 5.3.0
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
For more information, please visit [https://onesignal.com](https://onesignal.com)

## Installation

### Build a gem

To build the Ruby code into a gem:

```shell
gem build onesignal.gemspec
```

Then either install the gem locally:
Add to your `Gemfile`:

```shell
gem install ./onesignal-5.3.0.gem
```ruby
gem 'onesignal', '~> 5.3.0'
```

(for development, run `gem install --dev ./onesignal-5.3.0.gem` to install the development dependencies)
Then run `bundle install`.

or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
## Configuration

Finally add this to the Gemfile:
Every SDK requires authentication via API keys. Two key types are available:

gem 'onesignal', '~> 5.3.0'
- **REST API Key** — required for most endpoints (sending notifications, managing users, etc.). Found in your app's **Settings > Keys & IDs**.
- **Organization API Key** — only required for organization-level endpoints like creating or listing apps. Found in **Organization Settings**.

### Install from Git
> **Warning:** Store your API keys in environment variables or a secrets manager. Never commit them to source control.

If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:

gem 'onesignal', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'

### Include the Ruby code directly
```ruby
require 'onesignal'

Include the Ruby code directly using `-I` as follows:
OneSignal.configure do |config|
config.rest_api_key = 'YOUR_REST_API_KEY'
config.organization_api_key = 'YOUR_ORGANIZATION_API_KEY'
end

```shell
ruby -Ilib script.rb
client = OneSignal::DefaultApi.new
```

## Getting Started

Please follow the [installation](#installation) procedure and then run the following code:
## Send a push notification

```ruby
# Load the gem
require 'onesignal'
notification = OneSignal::Notification.new({
app_id: 'YOUR_APP_ID',
contents: { en: 'Hello from OneSignal!' },
headings: { en: 'Push Notification' },
included_segments: ['Subscribed Users']
})

response = client.create_notification(notification)
puts "Notification ID: #{response.id}"
```

# Setup authorization
OneSignal.configure do |config|
# Configure Bearer authorization: organization_api_key
config.organization_api_key = 'ORGANIZATION_API_KEY' # Organization key is only required for creating new apps and other top-level endpoints
# Configure Bearer authorization: rest_api_key
config.rest_api_key = 'REST_API_KEY' # App REST API key required for most endpoints
end
## Send an email

api_instance = OneSignal::DefaultApi.new
app_id = 'app_id_example' # String |
notification_id = 'notification_id_example' # String |
```ruby
notification = OneSignal::Notification.new({
app_id: 'YOUR_APP_ID',
email_subject: 'Important Update',
email_body: '<h1>Hello!</h1><p>This is an HTML email.</p>',
included_segments: ['Subscribed Users'],
channel_for_external_user_ids: 'email'
})

response = client.create_notification(notification)
```

begin
#Stop a scheduled or currently outgoing notification
result = api_instance.cancel_notification(app_id, notification_id)
p result
rescue OneSignal::ApiError => e
puts "Exception when calling DefaultApi->cancel_notification: #{e}"
end
## Send an SMS

```ruby
notification = OneSignal::Notification.new({
app_id: 'YOUR_APP_ID',
contents: { en: 'Your SMS message content here' },
included_segments: ['Subscribed Users'],
channel_for_external_user_ids: 'sms',
sms_from: '+15551234567'
})

response = client.create_notification(notification)
```

## Documentation for API Endpoints

All URIs are relative to *https://api.onesignal.com*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*OneSignal::DefaultApi* | [**cancel_notification**](docs/DefaultApi.md#cancel_notification) | **DELETE** /notifications/{notification_id} | Stop a scheduled or currently outgoing notification
*OneSignal::DefaultApi* | [**copy_template_to_app**](docs/DefaultApi.md#copy_template_to_app) | **POST** /templates/{template_id}/copy_to_app | Copy template to another app
*OneSignal::DefaultApi* | [**create_alias**](docs/DefaultApi.md#create_alias) | **PATCH** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity |
*OneSignal::DefaultApi* | [**create_alias_by_subscription**](docs/DefaultApi.md#create_alias_by_subscription) | **PATCH** /apps/{app_id}/subscriptions/{subscription_id}/user/identity |
*OneSignal::DefaultApi* | [**create_api_key**](docs/DefaultApi.md#create_api_key) | **POST** /apps/{app_id}/auth/tokens | Create API key
*OneSignal::DefaultApi* | [**create_app**](docs/DefaultApi.md#create_app) | **POST** /apps | Create an app
*OneSignal::DefaultApi* | [**create_custom_events**](docs/DefaultApi.md#create_custom_events) | **POST** /apps/{app_id}/integrations/custom_events | Create custom events
*OneSignal::DefaultApi* | [**create_notification**](docs/DefaultApi.md#create_notification) | **POST** /notifications | Create notification
*OneSignal::DefaultApi* | [**create_segment**](docs/DefaultApi.md#create_segment) | **POST** /apps/{app_id}/segments | Create Segment
*OneSignal::DefaultApi* | [**create_subscription**](docs/DefaultApi.md#create_subscription) | **POST** /apps/{app_id}/users/by/{alias_label}/{alias_id}/subscriptions |
*OneSignal::DefaultApi* | [**create_template**](docs/DefaultApi.md#create_template) | **POST** /templates | Create template
*OneSignal::DefaultApi* | [**create_user**](docs/DefaultApi.md#create_user) | **POST** /apps/{app_id}/users |
*OneSignal::DefaultApi* | [**delete_alias**](docs/DefaultApi.md#delete_alias) | **DELETE** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity/{alias_label_to_delete} |
*OneSignal::DefaultApi* | [**delete_api_key**](docs/DefaultApi.md#delete_api_key) | **DELETE** /apps/{app_id}/auth/tokens/{token_id} | Delete API key
*OneSignal::DefaultApi* | [**delete_segment**](docs/DefaultApi.md#delete_segment) | **DELETE** /apps/{app_id}/segments/{segment_id} | Delete Segment
*OneSignal::DefaultApi* | [**delete_subscription**](docs/DefaultApi.md#delete_subscription) | **DELETE** /apps/{app_id}/subscriptions/{subscription_id} |
*OneSignal::DefaultApi* | [**delete_template**](docs/DefaultApi.md#delete_template) | **DELETE** /templates/{template_id} | Delete template
*OneSignal::DefaultApi* | [**delete_user**](docs/DefaultApi.md#delete_user) | **DELETE** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
*OneSignal::DefaultApi* | [**export_events**](docs/DefaultApi.md#export_events) | **POST** /notifications/{notification_id}/export_events?app_id&#x3D;{app_id} | Export CSV of Events
*OneSignal::DefaultApi* | [**export_subscriptions**](docs/DefaultApi.md#export_subscriptions) | **POST** /players/csv_export?app_id&#x3D;{app_id} | Export CSV of Subscriptions
*OneSignal::DefaultApi* | [**get_aliases**](docs/DefaultApi.md#get_aliases) | **GET** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity |
*OneSignal::DefaultApi* | [**get_aliases_by_subscription**](docs/DefaultApi.md#get_aliases_by_subscription) | **GET** /apps/{app_id}/subscriptions/{subscription_id}/user/identity |
*OneSignal::DefaultApi* | [**get_app**](docs/DefaultApi.md#get_app) | **GET** /apps/{app_id} | View an app
*OneSignal::DefaultApi* | [**get_apps**](docs/DefaultApi.md#get_apps) | **GET** /apps | View apps
*OneSignal::DefaultApi* | [**get_notification**](docs/DefaultApi.md#get_notification) | **GET** /notifications/{notification_id} | View notification
*OneSignal::DefaultApi* | [**get_notification_history**](docs/DefaultApi.md#get_notification_history) | **POST** /notifications/{notification_id}/history | Notification History
*OneSignal::DefaultApi* | [**get_notifications**](docs/DefaultApi.md#get_notifications) | **GET** /notifications | View notifications
*OneSignal::DefaultApi* | [**get_outcomes**](docs/DefaultApi.md#get_outcomes) | **GET** /apps/{app_id}/outcomes | View Outcomes
*OneSignal::DefaultApi* | [**get_segments**](docs/DefaultApi.md#get_segments) | **GET** /apps/{app_id}/segments | Get Segments
*OneSignal::DefaultApi* | [**get_user**](docs/DefaultApi.md#get_user) | **GET** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
*OneSignal::DefaultApi* | [**rotate_api_key**](docs/DefaultApi.md#rotate_api_key) | **POST** /apps/{app_id}/auth/tokens/{token_id}/rotate | Rotate API key
*OneSignal::DefaultApi* | [**start_live_activity**](docs/DefaultApi.md#start_live_activity) | **POST** /apps/{app_id}/activities/activity/{activity_type} | Start Live Activity
*OneSignal::DefaultApi* | [**transfer_subscription**](docs/DefaultApi.md#transfer_subscription) | **PATCH** /apps/{app_id}/subscriptions/{subscription_id}/owner |
*OneSignal::DefaultApi* | [**unsubscribe_email_with_token**](docs/DefaultApi.md#unsubscribe_email_with_token) | **POST** /apps/{app_id}/notifications/{notification_id}/unsubscribe | Unsubscribe with token
*OneSignal::DefaultApi* | [**update_api_key**](docs/DefaultApi.md#update_api_key) | **PATCH** /apps/{app_id}/auth/tokens/{token_id} | Update API key
*OneSignal::DefaultApi* | [**update_app**](docs/DefaultApi.md#update_app) | **PUT** /apps/{app_id} | Update an app
*OneSignal::DefaultApi* | [**update_live_activity**](docs/DefaultApi.md#update_live_activity) | **POST** /apps/{app_id}/live_activities/{activity_id}/notifications | Update a Live Activity via Push
*OneSignal::DefaultApi* | [**update_subscription**](docs/DefaultApi.md#update_subscription) | **PATCH** /apps/{app_id}/subscriptions/{subscription_id} |
*OneSignal::DefaultApi* | [**update_subscription_by_token**](docs/DefaultApi.md#update_subscription_by_token) | **PATCH** /apps/{app_id}/subscriptions_by_token/{token_type}/{token} | Update subscription by token
*OneSignal::DefaultApi* | [**update_template**](docs/DefaultApi.md#update_template) | **PATCH** /templates/{template_id} | Update template
*OneSignal::DefaultApi* | [**update_user**](docs/DefaultApi.md#update_user) | **PATCH** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
*OneSignal::DefaultApi* | [**view_api_keys**](docs/DefaultApi.md#view_api_keys) | **GET** /apps/{app_id}/auth/tokens | View API keys
*OneSignal::DefaultApi* | [**view_template**](docs/DefaultApi.md#view_template) | **GET** /templates/{template_id} | View template
*OneSignal::DefaultApi* | [**view_templates**](docs/DefaultApi.md#view_templates) | **GET** /templates | View templates


## Documentation for Models

- [OneSignal::ApiKeyToken](docs/ApiKeyToken.md)
- [OneSignal::ApiKeyTokensListResponse](docs/ApiKeyTokensListResponse.md)
- [OneSignal::App](docs/App.md)
- [OneSignal::BasicNotification](docs/BasicNotification.md)
- [OneSignal::BasicNotificationAllOf](docs/BasicNotificationAllOf.md)
- [OneSignal::BasicNotificationAllOfAndroidBackgroundLayout](docs/BasicNotificationAllOfAndroidBackgroundLayout.md)
- [OneSignal::Button](docs/Button.md)
- [OneSignal::CopyTemplateRequest](docs/CopyTemplateRequest.md)
- [OneSignal::CreateApiKeyRequest](docs/CreateApiKeyRequest.md)
- [OneSignal::CreateApiKeyResponse](docs/CreateApiKeyResponse.md)
- [OneSignal::CreateNotificationSuccessResponse](docs/CreateNotificationSuccessResponse.md)
- [OneSignal::CreateSegmentConflictResponse](docs/CreateSegmentConflictResponse.md)
- [OneSignal::CreateSegmentSuccessResponse](docs/CreateSegmentSuccessResponse.md)
- [OneSignal::CreateTemplateRequest](docs/CreateTemplateRequest.md)
- [OneSignal::CreateUserConflictResponse](docs/CreateUserConflictResponse.md)
- [OneSignal::CreateUserConflictResponseErrorsInner](docs/CreateUserConflictResponseErrorsInner.md)
- [OneSignal::CreateUserConflictResponseErrorsItemsMeta](docs/CreateUserConflictResponseErrorsItemsMeta.md)
- [OneSignal::CustomEvent](docs/CustomEvent.md)
- [OneSignal::CustomEventsRequest](docs/CustomEventsRequest.md)
- [OneSignal::DeliveryData](docs/DeliveryData.md)
- [OneSignal::ExportEventsSuccessResponse](docs/ExportEventsSuccessResponse.md)
- [OneSignal::ExportSubscriptionsRequestBody](docs/ExportSubscriptionsRequestBody.md)
- [OneSignal::ExportSubscriptionsSuccessResponse](docs/ExportSubscriptionsSuccessResponse.md)
- [OneSignal::Filter](docs/Filter.md)
- [OneSignal::FilterExpression](docs/FilterExpression.md)
- [OneSignal::GenericError](docs/GenericError.md)
- [OneSignal::GenericSuccessBoolResponse](docs/GenericSuccessBoolResponse.md)
- [OneSignal::GetNotificationHistoryRequestBody](docs/GetNotificationHistoryRequestBody.md)
- [OneSignal::GetSegmentsSuccessResponse](docs/GetSegmentsSuccessResponse.md)
- [OneSignal::LanguageStringMap](docs/LanguageStringMap.md)
- [OneSignal::Notification](docs/Notification.md)
- [OneSignal::NotificationAllOf](docs/NotificationAllOf.md)
- [OneSignal::NotificationHistorySuccessResponse](docs/NotificationHistorySuccessResponse.md)
- [OneSignal::NotificationSlice](docs/NotificationSlice.md)
- [OneSignal::NotificationTarget](docs/NotificationTarget.md)
- [OneSignal::NotificationWithMeta](docs/NotificationWithMeta.md)
- [OneSignal::NotificationWithMetaAllOf](docs/NotificationWithMetaAllOf.md)
- [OneSignal::Operator](docs/Operator.md)
- [OneSignal::OutcomeData](docs/OutcomeData.md)
- [OneSignal::OutcomesData](docs/OutcomesData.md)
- [OneSignal::PlatformDeliveryData](docs/PlatformDeliveryData.md)
- [OneSignal::PlatformDeliveryDataEmailAllOf](docs/PlatformDeliveryDataEmailAllOf.md)
- [OneSignal::PlatformDeliveryDataSmsAllOf](docs/PlatformDeliveryDataSmsAllOf.md)
- [OneSignal::PropertiesBody](docs/PropertiesBody.md)
- [OneSignal::PropertiesDeltas](docs/PropertiesDeltas.md)
- [OneSignal::PropertiesObject](docs/PropertiesObject.md)
- [OneSignal::Purchase](docs/Purchase.md)
- [OneSignal::RateLimitError](docs/RateLimitError.md)
- [OneSignal::Segment](docs/Segment.md)
- [OneSignal::SegmentData](docs/SegmentData.md)
- [OneSignal::SegmentNotificationTarget](docs/SegmentNotificationTarget.md)
- [OneSignal::StartLiveActivityRequest](docs/StartLiveActivityRequest.md)
- [OneSignal::StartLiveActivitySuccessResponse](docs/StartLiveActivitySuccessResponse.md)
- [OneSignal::Subscription](docs/Subscription.md)
- [OneSignal::SubscriptionBody](docs/SubscriptionBody.md)
- [OneSignal::SubscriptionNotificationTarget](docs/SubscriptionNotificationTarget.md)
- [OneSignal::TemplateResource](docs/TemplateResource.md)
- [OneSignal::TemplatesListResponse](docs/TemplatesListResponse.md)
- [OneSignal::TransferSubscriptionRequestBody](docs/TransferSubscriptionRequestBody.md)
- [OneSignal::UpdateApiKeyRequest](docs/UpdateApiKeyRequest.md)
- [OneSignal::UpdateLiveActivityRequest](docs/UpdateLiveActivityRequest.md)
- [OneSignal::UpdateLiveActivitySuccessResponse](docs/UpdateLiveActivitySuccessResponse.md)
- [OneSignal::UpdateTemplateRequest](docs/UpdateTemplateRequest.md)
- [OneSignal::UpdateUserRequest](docs/UpdateUserRequest.md)
- [OneSignal::User](docs/User.md)
- [OneSignal::UserIdentityBody](docs/UserIdentityBody.md)
- [OneSignal::WebButton](docs/WebButton.md)


## Documentation for Authorization


### organization_api_key

- **Type**: Bearer authentication

### rest_api_key

- **Type**: Bearer authentication
## Full API reference

The complete list of API endpoints and their parameters is available in the [DefaultApi documentation](https://github.com/OneSignal/onesignal-ruby-api/blob/master/docs/DefaultApi.md).

For the underlying REST API, see the [OneSignal API reference](https://documentation.onesignal.com/reference).
Loading
Loading