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
83 changes: 83 additions & 0 deletions docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ All URIs are relative to *https://api.onesignal.com*
| [**get_notification_history**](DefaultApi.md#get_notification_history) | **POST** /notifications/{notification_id}/history | Notification History |
| [**get_notifications**](DefaultApi.md#get_notifications) | **GET** /notifications | View notifications |
| [**get_outcomes**](DefaultApi.md#get_outcomes) | **GET** /apps/{app_id}/outcomes | View Outcomes |
| [**get_segment**](DefaultApi.md#get_segment) | **GET** /apps/{app_id}/segments/{segment_id} | View Segment |
| [**get_segments**](DefaultApi.md#get_segments) | **GET** /apps/{app_id}/segments | Get Segments |
| [**get_user**](DefaultApi.md#get_user) | **GET** /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
| [**rotate_api_key**](DefaultApi.md#rotate_api_key) | **POST** /apps/{app_id}/auth/tokens/{token_id}/rotate | Rotate API key |
Expand Down Expand Up @@ -2366,6 +2367,88 @@ end
- **Accept**: application/json


## get_segment

> <GetSegmentSuccessResponse> get_segment(app_id, segment_id, opts)

View Segment

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

### Examples

```ruby
require 'onesignal'
# setup authorization
OneSignal.configure do |config|
# Configure Bearer authorization: rest_api_key
config.rest_api_key = 'YOUR_REST_API_KEY'

end

api_instance = OneSignal::DefaultApi.new
app_id = 'YOUR_APP_ID' # String | The OneSignal App ID for your app. Available in Keys & IDs.
segment_id = 'd6c5a3e1-9f17-44a1-9d10-7c0e4a2b1c8e' # 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 = {
include_segment_detail: true # Boolean | Set to true to include segment metadata and filters in the response.
}

begin
# View Segment
result = api_instance.get_segment(app_id, segment_id, opts)
p result
rescue OneSignal::ApiError => e
puts "Error when calling DefaultApi->get_segment: #{e}"
puts "Status Code: #{e.code}"
# `e.error_messages` flattens any error-envelope shape to an Array<String>;
# the raw body remains on `e.response_body`.
puts "Error Messages: #{e.error_messages}"
puts "Response Body: #{e.response_body}"
end
```

#### Using the get_segment_with_http_info variant

This returns an Array which contains the response data, status code and headers.

> <Array(<GetSegmentSuccessResponse>, Integer, Hash)> get_segment_with_http_info(app_id, segment_id, opts)

```ruby
begin
# View Segment
data, status_code, headers = api_instance.get_segment_with_http_info(app_id, segment_id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => <GetSegmentSuccessResponse>
rescue OneSignal::ApiError => e
puts "Error when calling DefaultApi->get_segment_with_http_info: #{e}"
puts "Status Code: #{e.code}"
puts "Response Body: #{e.response_body}"
end
```

### Parameters

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **app_id** | **String** | The OneSignal App ID for your app. Available in Keys &amp; IDs. | |
| **segment_id** | **String** | The segment&#39;s unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard. | |
| **include_segment_detail** | **Boolean** | Set to true to include segment metadata and filters in the response. | [optional] |

### Return type

[**GetSegmentSuccessResponse**](GetSegmentSuccessResponse.md)

### Authorization

[rest_api_key](https://github.com/OneSignal/onesignal-ruby-api#configuration)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json


## get_segments

> <GetSegmentsSuccessResponse> get_segments(app_id, opts)
Expand Down
20 changes: 20 additions & 0 deletions docs/GetSegmentSuccessResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# OneSignal::GetSegmentSuccessResponse

## Properties

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **subscriber_count** | **Integer** | The number of subscribers matching this segment. | [optional] |
| **payload** | [**SegmentDetails**](SegmentDetails.md) | | [optional] |

## Example

```ruby
require 'onesignal'

instance = OneSignal::GetSegmentSuccessResponse.new(
subscriber_count: nil,
payload: nil
)
```

28 changes: 28 additions & 0 deletions docs/SegmentDetails.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# OneSignal::SegmentDetails

## Properties

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The unique identifier for the segment (UUID v4). | [optional] |
| **name** | **String** | The segment name. | [optional] |
| **description** | **String** | Human-readable description for the segment. &#x60;null&#x60; when unset. Maximum 255 characters. | [optional] |
| **created_at** | **Integer** | Unix timestamp when the segment was created. | [optional] |
| **source** | **String** | The source of the segment. | [optional] |
| **filters** | [**Array&lt;FilterExpression&gt;**](FilterExpression.md) | Array of filter and operator objects defining the segment criteria. Uses the same format as the Create Segment API, so filters can be directly used to recreate or update the segment. | [optional] |

## Example

```ruby
require 'onesignal'

instance = OneSignal::SegmentDetails.new(
id: nil,
name: nil,
description: nil,
created_at: nil,
source: nil,
filters: nil
)
```

2 changes: 2 additions & 0 deletions lib/onesignal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
require 'onesignal/models/generic_error'
require 'onesignal/models/generic_success_bool_response'
require 'onesignal/models/get_notification_history_request_body'
require 'onesignal/models/get_segment_success_response'
require 'onesignal/models/get_segments_success_response'
require 'onesignal/models/language_string_map'
require 'onesignal/models/notification'
Expand All @@ -68,6 +69,7 @@
require 'onesignal/models/rate_limit_error'
require 'onesignal/models/segment'
require 'onesignal/models/segment_data'
require 'onesignal/models/segment_details'
require 'onesignal/models/segment_notification_target'
require 'onesignal/models/start_live_activity_request'
require 'onesignal/models/start_live_activity_success_response'
Expand Down
72 changes: 72 additions & 0 deletions lib/onesignal/api/default_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,78 @@ def get_outcomes_with_http_info(app_id, outcome_names, opts = {})
return data, status_code, headers
end

# View Segment
# Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters.
# @param app_id [String] The OneSignal App ID for your app. Available in Keys &amp; IDs.
# @param segment_id [String] The segment&#39;s unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :include_segment_detail Set to true to include segment metadata and filters in the response.
# @return [GetSegmentSuccessResponse]
def get_segment(app_id, segment_id, opts = {})
data, _status_code, _headers = get_segment_with_http_info(app_id, segment_id, opts)
data
end

# View Segment
# Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters.
# @param app_id [String] The OneSignal App ID for your app. Available in Keys &amp; IDs.
# @param segment_id [String] The segment&#39;s unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :include_segment_detail Set to true to include segment metadata and filters in the response.
# @return [Array<(GetSegmentSuccessResponse, Integer, Hash)>] GetSegmentSuccessResponse data, response status code and response headers
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
# Returns an array of segments from an app.
# @param app_id [String] The OneSignal App ID for your app. Available in Keys &amp; IDs.
Expand Down
Loading