diff --git a/docs/DefaultApi.md b/docs/DefaultApi.md index 41b9026..ca4a461 100644 --- a/docs/DefaultApi.md +++ b/docs/DefaultApi.md @@ -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 | @@ -2366,6 +2367,88 @@ end - **Accept**: application/json +## get_segment + +> 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; + # 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. + +> , 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 # => +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 & 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. | | +| **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 > get_segments(app_id, opts) diff --git a/docs/GetSegmentSuccessResponse.md b/docs/GetSegmentSuccessResponse.md new file mode 100644 index 0000000..b467430 --- /dev/null +++ b/docs/GetSegmentSuccessResponse.md @@ -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 +) +``` + diff --git a/docs/SegmentDetails.md b/docs/SegmentDetails.md new file mode 100644 index 0000000..c401656 --- /dev/null +++ b/docs/SegmentDetails.md @@ -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. `null` 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<FilterExpression>**](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 +) +``` + diff --git a/lib/onesignal.rb b/lib/onesignal.rb index 51864ef..b92e6d0 100644 --- a/lib/onesignal.rb +++ b/lib/onesignal.rb @@ -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' @@ -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' diff --git a/lib/onesignal/api/default_api.rb b/lib/onesignal/api/default_api.rb index e602e88..af2e1ba 100644 --- a/lib/onesignal/api/default_api.rb +++ b/lib/onesignal/api/default_api.rb @@ -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 & IDs. + # @param 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. + # @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 & IDs. + # @param 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. + # @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 & IDs. diff --git a/lib/onesignal/models/get_segment_success_response.rb b/lib/onesignal/models/get_segment_success_response.rb new file mode 100644 index 0000000..334b9b2 --- /dev/null +++ b/lib/onesignal/models/get_segment_success_response.rb @@ -0,0 +1,229 @@ +=begin +#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 +OpenAPI Generator version: 6.0.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module OneSignal + class GetSegmentSuccessResponse + # The number of subscribers matching this segment. + attr_accessor :subscriber_count + + attr_accessor :payload + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'subscriber_count' => :'subscriber_count', + :'payload' => :'payload' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'subscriber_count' => :'Integer', + :'payload' => :'SegmentDetails' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::GetSegmentSuccessResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::GetSegmentSuccessResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'subscriber_count') + self.subscriber_count = attributes[:'subscriber_count'] + end + + if attributes.key?(:'payload') + self.payload = attributes[:'payload'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + subscriber_count == o.subscriber_count && + payload == o.payload + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [subscriber_count, payload].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = OneSignal.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/onesignal/models/segment_details.rb b/lib/onesignal/models/segment_details.rb new file mode 100644 index 0000000..a1294b7 --- /dev/null +++ b/lib/onesignal/models/segment_details.rb @@ -0,0 +1,308 @@ +=begin +#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 +OpenAPI Generator version: 6.0.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module OneSignal + # Segment details. Only included when the include-segment-detail query parameter is set to true. + class SegmentDetails + # The unique identifier for the segment (UUID v4). + attr_accessor :id + + # The segment name. + attr_accessor :name + + # Human-readable description for the segment. `null` when unset. Maximum 255 characters. + attr_accessor :description + + # Unix timestamp when the segment was created. + attr_accessor :created_at + + # The source of the segment. + attr_accessor :source + + # 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. + attr_accessor :filters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'description' => :'description', + :'created_at' => :'created_at', + :'source' => :'source', + :'filters' => :'filters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'description' => :'String', + :'created_at' => :'Integer', + :'source' => :'String', + :'filters' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'description', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::SegmentDetails` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::SegmentDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'filters') + if (value = attributes[:'filters']).is_a?(Array) + self.filters = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + source_validator = EnumAttributeValidator.new('String', ["default", "custom", "quickstart"]) + return false unless source_validator.valid?(@source) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] source Object to be assigned + def source=(source) + validator = EnumAttributeValidator.new('String', ["default", "custom", "quickstart"]) + unless validator.valid?(source) + fail ArgumentError, "invalid value for \"source\", must be one of #{validator.allowable_values}." + end + @source = source + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + description == o.description && + created_at == o.created_at && + source == o.source && + filters == o.filters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, description, created_at, source, filters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = OneSignal.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/spec/api/default_api_spec.rb b/spec/api/default_api_spec.rb index e32794d..80b88aa 100644 --- a/spec/api/default_api_spec.rb +++ b/spec/api/default_api_spec.rb @@ -398,6 +398,20 @@ end end + # unit tests for get_segment + # View Segment + # Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters. + # @param app_id The OneSignal App ID for your app. Available in Keys & IDs. + # @param segment_id 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. + # @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] + describe 'get_segment test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + # unit tests for get_segments # Get Segments # Returns an array of segments from an app. diff --git a/spec/models/get_segment_success_response_spec.rb b/spec/models/get_segment_success_response_spec.rb new file mode 100644 index 0000000..53c4574 --- /dev/null +++ b/spec/models/get_segment_success_response_spec.rb @@ -0,0 +1,40 @@ +=begin +#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 +OpenAPI Generator version: 6.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for OneSignal::GetSegmentSuccessResponse +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe OneSignal::GetSegmentSuccessResponse do + let(:instance) { OneSignal::GetSegmentSuccessResponse.new } + + describe 'test an instance of GetSegmentSuccessResponse' do + it 'should create an instance of GetSegmentSuccessResponse' do + expect(instance).to be_instance_of(OneSignal::GetSegmentSuccessResponse) + end + end + describe 'test attribute "subscriber_count"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "payload"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/spec/models/segment_details_spec.rb b/spec/models/segment_details_spec.rb new file mode 100644 index 0000000..2353248 --- /dev/null +++ b/spec/models/segment_details_spec.rb @@ -0,0 +1,68 @@ +=begin +#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 +OpenAPI Generator version: 6.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for OneSignal::SegmentDetails +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe OneSignal::SegmentDetails do + let(:instance) { OneSignal::SegmentDetails.new } + + describe 'test an instance of SegmentDetails' do + it 'should create an instance of SegmentDetails' do + expect(instance).to be_instance_of(OneSignal::SegmentDetails) + end + end + describe 'test attribute "id"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "description"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "created_at"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "source"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["default", "custom", "quickstart"]) + # validator.allowable_values.each do |value| + # expect { instance.source = value }.not_to raise_error + # end + end + end + + describe 'test attribute "filters"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end