From 5a357f6236b014a7ab2e83b9aa58e22cb2f0069c Mon Sep 17 00:00:00 2001 From: OneSignal Date: Fri, 24 Jul 2026 20:44:32 +0000 Subject: [PATCH] feat: add v5.10.0 package updates --- docs/DefaultApi.md | 63 ++++++++++++++++++++ docs/GetSegmentSuccessResponse.md | 12 ++++ docs/SegmentDetails.md | 16 ++++++ src/apis/default_api.rs | 49 ++++++++++++++++ src/models/get_segment_success_response.rs | 32 +++++++++++ src/models/mod.rs | 4 ++ src/models/segment_details.rs | 67 ++++++++++++++++++++++ 7 files changed, 243 insertions(+) create mode 100644 docs/GetSegmentSuccessResponse.md create mode 100644 docs/SegmentDetails.md create mode 100644 src/models/get_segment_success_response.rs create mode 100644 src/models/segment_details.rs diff --git a/docs/DefaultApi.md b/docs/DefaultApi.md index 3507eeb..b98989c 100644 --- a/docs/DefaultApi.md +++ b/docs/DefaultApi.md @@ -32,6 +32,7 @@ Method | HTTP request | Description [**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 @@ -1908,6 +1909,68 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](https://github.com/OneSignal/onesignal-rust-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-rust-api) +## get_segment + +> crate::models::GetSegmentSuccessResponse get_segment(app_id, segment_id, include_segment_detail) +View Segment + +Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters. + +### Example + +```rust +use onesignal_rust_api::apis::configuration::Configuration; +use onesignal_rust_api::apis::default_api; + + +#[tokio::main] +async fn main() { + let mut configuration = Configuration::new(); + configuration.rest_api_key_token = Some("YOUR_REST_API_KEY".to_string()); + + + // Realistic values are pulled from the spec's `example:` fields where present. + let app_id: &str = "YOUR_APP_ID"; + let segment_id: &str = "d6c5a3e1-9f17-44a1-9d10-7c0e4a2b1c8e"; + let include_segment_detail: Option = None; + + match default_api::get_segment(&configuration, app_id, segment_id, include_segment_detail).await { + Ok(resp) => println!("{:?}", resp), + Err(e @ onesignal_rust_api::apis::Error::ResponseError(_)) => { + // `e.error_messages()` flattens any error-envelope shape to a Vec; + // the raw response remains on the ResponseError variant. + eprintln!("get_segment failed: {:?}", e.error_messages()); + } + Err(e) => eprintln!("get_segment failed: {:?}", e), + } +} +``` + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**app_id** | **String** | The OneSignal App ID for your app. Available in Keys & IDs. | [required] | +**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. | [required] | +**include_segment_detail** | Option<**bool**> | Set to true to include segment metadata and filters in the response. | | + +### Return type + +[**crate::models::GetSegmentSuccessResponse**](GetSegmentSuccessResponse.md) + +### Authorization + +[rest_api_key](https://github.com/OneSignal/onesignal-rust-api#configuration) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](https://github.com/OneSignal/onesignal-rust-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-rust-api) + + ## get_segments > crate::models::GetSegmentsSuccessResponse get_segments(app_id, offset, limit) diff --git a/docs/GetSegmentSuccessResponse.md b/docs/GetSegmentSuccessResponse.md new file mode 100644 index 0000000..28492f9 --- /dev/null +++ b/docs/GetSegmentSuccessResponse.md @@ -0,0 +1,12 @@ +# GetSegmentSuccessResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**subscriber_count** | Option<**i32**> | The number of subscribers matching this segment. | [optional] +**payload** | Option<[**crate::models::SegmentDetails**](SegmentDetails.md)> | | [optional] + +[[Back to API list]](https://github.com/OneSignal/onesignal-rust-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-rust-api) + + diff --git a/docs/SegmentDetails.md b/docs/SegmentDetails.md new file mode 100644 index 0000000..7694fbf --- /dev/null +++ b/docs/SegmentDetails.md @@ -0,0 +1,16 @@ +# SegmentDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**String**> | The unique identifier for the segment (UUID v4). | [optional] +**name** | Option<**String**> | The segment name. | [optional] +**description** | Option<**String**> | Human-readable description for the segment. `null` when unset. Maximum 255 characters. | [optional] +**created_at** | Option<**i32**> | Unix timestamp when the segment was created. | [optional] +**source** | Option<**String**> | The source of the segment. | [optional] +**filters** | Option<[**Vec**](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] + +[[Back to API list]](https://github.com/OneSignal/onesignal-rust-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-rust-api) + + diff --git a/src/apis/default_api.rs b/src/apis/default_api.rs index 48e01ce..515a8c7 100644 --- a/src/apis/default_api.rs +++ b/src/apis/default_api.rs @@ -312,6 +312,17 @@ pub enum GetOutcomesError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`get_segment`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSegmentError { + Status400(crate::models::GenericError), + Status404(crate::models::GenericError), + Status429(crate::models::RateLimitError), + DefaultResponse(crate::models::GenericError), + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`get_segments`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1499,6 +1510,44 @@ pub async fn get_outcomes(configuration: &configuration::Configuration, app_id: } } +/// Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters. +pub async fn get_segment(configuration: &configuration::Configuration, app_id: &str, segment_id: &str, include_segment_detail: Option) -> Result> { + let configuration = configuration; + + let client = &configuration.client; + + let uri_str = format!("{}/apps/{app_id}/segments/{segment_id}", configuration.base_path, app_id=crate::apis::urlencode(app_id), segment_id=crate::apis::urlencode(segment_id)); + let mut req_builder = client.request(reqwest::Method::GET, uri_str.as_str()); + + if let Some(ref str) = include_segment_detail { + req_builder = req_builder.query(&[("include-segment-detail", &str.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + // Adds a telemetry header + req_builder = req_builder.header("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-rust, version=5.10.0"); + + if let Some(ref token) = configuration.rest_api_key_token { + req_builder = req_builder.header("Authorization", format!("Key {}", token.to_owned())); + } + + let req = req_builder.build()?; + let resp = client.execute(req).await?; + + let status = resp.status(); + let content = resp.text().await?; + + if !status.is_client_error() && !status.is_server_error() { + serde_json::from_str(&content).map_err(Error::from) + } else { + let entity: Option = serde_json::from_str(&content).ok(); + let error = ResponseContent { status: status, content: content, entity: entity }; + Err(Error::ResponseError(error)) + } +} + /// Returns an array of segments from an app. pub async fn get_segments(configuration: &configuration::Configuration, app_id: &str, offset: Option, limit: Option) -> Result> { let configuration = configuration; diff --git a/src/models/get_segment_success_response.rs b/src/models/get_segment_success_response.rs new file mode 100644 index 0000000..da24e8a --- /dev/null +++ b/src/models/get_segment_success_response.rs @@ -0,0 +1,32 @@ +/* + * OneSignal + * + * A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com + * + * The version of the OpenAPI document: 5.10.0 + * Contact: devrel@onesignal.com + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct GetSegmentSuccessResponse { + /// The number of subscribers matching this segment. + #[serde(rename = "subscriber_count", skip_serializing_if = "Option::is_none")] + pub subscriber_count: Option, + #[serde(rename = "payload", skip_serializing_if = "Option::is_none")] + pub payload: Option>, +} + +impl GetSegmentSuccessResponse { + pub fn new() -> GetSegmentSuccessResponse { + GetSegmentSuccessResponse { + subscriber_count: None, + payload: None, + } + } +} + + diff --git a/src/models/mod.rs b/src/models/mod.rs index ebde249..78cbc2f 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -54,6 +54,8 @@ pub mod generic_success_bool_response; pub use self::generic_success_bool_response::GenericSuccessBoolResponse; pub mod get_notification_history_request_body; pub use self::get_notification_history_request_body::GetNotificationHistoryRequestBody; +pub mod get_segment_success_response; +pub use self::get_segment_success_response::GetSegmentSuccessResponse; pub mod get_segments_success_response; pub use self::get_segments_success_response::GetSegmentsSuccessResponse; pub mod language_string_map; @@ -98,6 +100,8 @@ pub mod segment; pub use self::segment::Segment; pub mod segment_data; pub use self::segment_data::SegmentData; +pub mod segment_details; +pub use self::segment_details::SegmentDetails; pub mod segment_notification_target; pub use self::segment_notification_target::SegmentNotificationTarget; pub mod start_live_activity_request; diff --git a/src/models/segment_details.rs b/src/models/segment_details.rs new file mode 100644 index 0000000..39bc9f6 --- /dev/null +++ b/src/models/segment_details.rs @@ -0,0 +1,67 @@ +/* + * OneSignal + * + * A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com + * + * The version of the OpenAPI document: 5.10.0 + * Contact: devrel@onesignal.com + * Generated by: https://openapi-generator.tech + */ + +/// SegmentDetails : Segment details. Only included when the include-segment-detail query parameter is set to true. + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct SegmentDetails { + /// The unique identifier for the segment (UUID v4). + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// The segment name. + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + /// Human-readable description for the segment. `null` when unset. Maximum 255 characters. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + /// Unix timestamp when the segment was created. + #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")] + pub created_at: Option, + /// The source of the segment. + #[serde(rename = "source", skip_serializing_if = "Option::is_none")] + pub source: Option, + /// 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. + #[serde(rename = "filters", skip_serializing_if = "Option::is_none")] + pub filters: Option>, +} + +impl SegmentDetails { + /// Segment details. Only included when the include-segment-detail query parameter is set to true. + pub fn new() -> SegmentDetails { + SegmentDetails { + id: None, + name: None, + description: None, + created_at: None, + source: None, + filters: None, + } + } +} + +/// The source of the segment. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum SourceType { + #[serde(rename = "default")] + Default, + #[serde(rename = "custom")] + Custom, + #[serde(rename = "quickstart")] + Quickstart, +} + +impl Default for SourceType { + fn default() -> SourceType { + Self::Default + } +} +