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
129 changes: 129 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,74 @@ paths:
- rest_api_key: []
summary: Delete Segment
x-accepts: application/json
get:
description: "Retrieve details for a single segment by its ID, including subscriber\
\ count and optionally segment metadata and filters."
operationId: get_segment
parameters:
- description: The OneSignal App ID for your app. Available in Keys & IDs.
explode: false
in: path
name: app_id
required: true
schema:
example: YOUR_APP_ID
type: string
style: simple
- description: 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.
explode: false
in: path
name: segment_id
required: true
schema:
example: d6c5a3e1-9f17-44a1-9d10-7c0e4a2b1c8e
type: string
style: simple
- description: Set to true to include segment metadata and filters in the response.
explode: true
in: query
name: include-segment-detail
required: false
schema:
example: true
type: boolean
style: form
responses:
default:
content:
application/json:
schema:
$ref: '#/components/schemas/GenericError'
description: Unexpected error
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/GetSegmentSuccessResponse'
description: OK
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/GenericError'
description: Bad Request
"404":
content:
application/json:
schema:
$ref: '#/components/schemas/GenericError'
description: Not Found
"429":
content:
application/json:
schema:
$ref: '#/components/schemas/RateLimitError'
description: Rate Limit Exceeded
security:
- rest_api_key: []
summary: View Segment
x-accepts: application/json
/apps/{app_id}/outcomes:
get:
description: "View the details of all the outcomes associated with your app\n\
Expand Down Expand Up @@ -3574,6 +3642,67 @@ components:
$ref: '#/components/schemas/SegmentData'
type: array
type: object
SegmentDetails:
description: Segment details. Only included when the include-segment-detail
query parameter is set to true.
example:
name: name
description: description
created_at: 6
id: id
source: default
filters:
- null
- null
properties:
id:
description: The unique identifier for the segment (UUID v4).
type: string
name:
description: The segment name.
type: string
description:
description: Human-readable description for the segment. `null` when unset.
Maximum 255 characters.
nullable: true
type: string
created_at:
description: Unix timestamp when the segment was created.
type: integer
source:
description: The source of the segment.
enum:
- default
- custom
- quickstart
type: string
filters:
description: "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."
items:
$ref: '#/components/schemas/FilterExpression'
type: array
type: object
GetSegmentSuccessResponse:
example:
payload:
name: name
description: description
created_at: 6
id: id
source: default
filters:
- null
- null
subscriber_count: 0
properties:
subscriber_count:
description: The number of subscribers matching this segment.
type: integer
payload:
$ref: '#/components/schemas/SegmentDetails'
type: object
UpdateLiveActivityRequest:
example:
event_updates: "{}"
Expand Down
79 changes: 79 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*
| [**getNotificationHistory**](DefaultApi.md#getNotificationHistory) | **POST** /notifications/{notification_id}/history | Notification History |
| [**getNotifications**](DefaultApi.md#getNotifications) | **GET** /notifications | View notifications |
| [**getOutcomes**](DefaultApi.md#getOutcomes) | **GET** /apps/{app_id}/outcomes | View Outcomes |
| [**getSegment**](DefaultApi.md#getSegment) | **GET** /apps/{app_id}/segments/{segment_id} | View Segment |
| [**getSegments**](DefaultApi.md#getSegments) | **GET** /apps/{app_id}/segments | Get Segments |
| [**getUser**](DefaultApi.md#getUser) | **GET** /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
| [**rotateApiKey**](DefaultApi.md#rotateApiKey) | **POST** /apps/{app_id}/auth/tokens/{token_id}/rotate | Rotate API key |
Expand Down Expand Up @@ -2330,6 +2331,84 @@ public class Example {
| **429** | Rate Limit Exceeded | - |
| **0** | Unexpected error | - |

<a name="getSegment"></a>
# **getSegment**
> GetSegmentSuccessResponse getSegment(appId, segmentId, includeSegmentDetail)

View Segment

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

### Example
```java
// Import classes:
import com.onesignal.client.ApiClient;
import com.onesignal.client.ApiException;
import com.onesignal.client.Configuration;
import com.onesignal.client.auth.*;
import com.onesignal.client.model.*;
import com.onesignal.client.api.DefaultApi;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.onesignal.com");

// Configure HTTP bearer authorization: rest_api_key
HttpBearerAuth rest_api_key = (HttpBearerAuth) defaultClient.getAuthentication("rest_api_key");
rest_api_key.setBearerToken("YOUR_REST_API_KEY");

DefaultApi apiInstance = new DefaultApi(defaultClient);
String appId = "YOUR_APP_ID"; // String | The OneSignal App ID for your app. Available in Keys & IDs.
String segmentId = "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.
Boolean includeSegmentDetail = true; // Boolean | Set to true to include segment metadata and filters in the response.
try {
GetSegmentSuccessResponse result = apiInstance.getSegment(appId, segmentId, includeSegmentDetail);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#getSegment");
System.err.println("Status code: " + e.getCode());
// getErrorMessages() flattens any error-envelope shape to a List<String>;
// the raw body remains on getResponseBody().
System.err.println("Error messages: " + e.getErrorMessages());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```

### Parameters

| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **appId** | **String**| The OneSignal App ID for your app. Available in Keys &amp; IDs. | |
| **segmentId** | **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. | |
| **includeSegmentDetail** | **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-java-api#configuration)

### HTTP request headers

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

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | OK | - |
| **400** | Bad Request | - |
| **404** | Not Found | - |
| **429** | Rate Limit Exceeded | - |
| **0** | Unexpected error | - |

<a name="getSegments"></a>
# **getSegments**
> GetSegmentsSuccessResponse getSegments(appId, offset, limit)
Expand Down
14 changes: 14 additions & 0 deletions docs/GetSegmentSuccessResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# GetSegmentSuccessResponse


## Properties

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



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


# SegmentDetails

Segment details. Only included when the include-segment-detail query parameter is set to true.

## 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] |
|**createdAt** | **Integer** | Unix timestamp when the segment was created. | [optional] |
|**source** | [**SourceEnum**](#SourceEnum) | The source of the segment. | [optional] |
|**filters** | [**List&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] |



## Enum: SourceEnum

| Name | Value |
|---- | -----|
| DEFAULT | &quot;default&quot; |
| CUSTOM | &quot;custom&quot; |
| QUICKSTART | &quot;quickstart&quot; |



2 changes: 2 additions & 0 deletions src/main/java/com/onesignal/client/JSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
.registerTypeAdapterFactory(new com.onesignal.client.model.GenericError.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.GenericSuccessBoolResponse.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.GetNotificationHistoryRequestBody.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.GetSegmentSuccessResponse.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.GetSegmentsSuccessResponse.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.LanguageStringMap.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.Notification.CustomTypeAdapterFactory())
Expand All @@ -143,6 +144,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
.registerTypeAdapterFactory(new com.onesignal.client.model.RateLimitError.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.Segment.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.SegmentData.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.SegmentDetails.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.SegmentNotificationTarget.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.StartLiveActivityRequest.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(new com.onesignal.client.model.StartLiveActivitySuccessResponse.CustomTypeAdapterFactory())
Expand Down
Loading