Class: OneSignal::EstimateNotificationRecipientsRequest
- Inherits:
-
Object
- Object
- OneSignal::EstimateNotificationRecipientsRequest
- Defined in:
- lib/onesignal/models/estimate_notification_recipients_request.rb
Overview
The targeting subset of notification fields this endpoint honors. included_segments (or its \"All\" shorthand) is required. excluded_segments, filters, include_aliases, and target_channel narrow that segment-based audience further when present. Use target_channel to select which platforms to count. Other notification targeting fields (include_subscription_ids and the other raw subscription id/token fields, and the individual isIos / isAndroid / etc. platform flags) are not read by this endpoint. All non-targeting notification fields (content, delivery options, and so on) are accepted, but ignored.
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#app_id ⇒ Object
The OneSignal App ID for your app, which can be found in Keys & IDs.
-
#excluded_segments ⇒ Object
Segment that will be excluded when sending.
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#include_aliases ⇒ Object
Target specific users by aliases assigned via API.
-
#included_segments ⇒ Object
The segment names you want to target.
-
#target_channel ⇒ Object
Which platforms to count recipients for.
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_all_of ⇒ Object
List of class defined in allOf (OpenAPI v3).
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ EstimateNotificationRecipientsRequest
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ EstimateNotificationRecipientsRequest
Initializes the object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 104 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::EstimateNotificationRecipientsRequest` 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::EstimateNotificationRecipientsRequest`. 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?(:'included_segments') if (value = attributes[:'included_segments']).is_a?(Array) self.included_segments = value end end if attributes.key?(:'excluded_segments') if (value = attributes[:'excluded_segments']).is_a?(Array) self.excluded_segments = value end end if attributes.key?(:'app_id') self.app_id = attributes[:'app_id'] end if attributes.key?(:'filters') if (value = attributes[:'filters']).is_a?(Array) self.filters = value end end if attributes.key?(:'include_aliases') if (value = attributes[:'include_aliases']).is_a?(Hash) self.include_aliases = value end end if attributes.key?(:'target_channel') self.target_channel = attributes[:'target_channel'] end end |
Instance Attribute Details
#app_id ⇒ Object
The OneSignal App ID for your app, which can be found in Keys & IDs.
25 26 27 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 25 def app_id @app_id end |
#excluded_segments ⇒ Object
Segment that will be excluded when sending. Users in these segments will not receive a notification, even if they were included in included_segments. This targeting parameter is only compatible with included_segments. Example: ["Active Users", "Inactive Users"]
22 23 24 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 22 def excluded_segments @excluded_segments end |
#filters ⇒ Object
Returns the value of attribute filters.
27 28 29 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 27 def filters @filters end |
#include_aliases ⇒ Object
Target specific users by aliases assigned via API. An alias can be an external_id, onesignal_id, or a custom alias. Accepts an object where keys are alias labels and values are arrays of alias IDs to include Example usage: { "external_id": ["exId1", "extId2"], "internal_label": ["id1", "id2"] } Keys must match API spellings exactly (for example the label for External ID is the string external_id; arbitrary keys such as camelCase variants are not aliases and may yield no recipients). Not compatible with any other targeting parameters. REQUIRED: REST API Key Authentication Limit of 2,000 entries per REST API call Note: If targeting push, email, or sms subscribers with same ids, use with target_channel to indicate you are sending a push or email or sms.
30 31 32 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 30 def include_aliases @include_aliases end |
#included_segments ⇒ Object
The segment names you want to target. Users in these segments will receive a notification. This targeting parameter is only compatible with excluded_segments. Example: ["Active Users", "Inactive Users"] \"All\" is a shorthand for every subscribed user: if the array includes the string \"All\" and the app has no segment actually named All, it targets all subscribers instead of a literal segment lookup.
19 20 21 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 19 def included_segments @included_segments end |
#target_channel ⇒ Object
Which platforms to count recipients for. Selects the same default platforms Create notification would use for the channel. Individual platform flags (isIos, isAndroid, etc.) are not supported by this endpoint.
33 34 35 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 33 def target_channel @target_channel end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
70 71 72 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 70 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 58 def self.attribute_map { :'included_segments' => :'included_segments', :'excluded_segments' => :'excluded_segments', :'app_id' => :'app_id', :'filters' => :'filters', :'include_aliases' => :'include_aliases', :'target_channel' => :'target_channel' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
208 209 210 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 208 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_all_of ⇒ Object
List of class defined in allOf (OpenAPI v3)
95 96 97 98 99 100 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 95 def self.openapi_all_of [ :'EstimateNotificationRecipientsRequestAllOf', :'SegmentNotificationTarget' ] end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
87 88 89 90 91 92 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 87 def self.openapi_nullable Set.new([ :'filters', :'include_aliases', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 75 def self.openapi_types { :'included_segments' => :'Array<String>', :'excluded_segments' => :'Array<String>', :'app_id' => :'String', :'filters' => :'Array<FilterExpression>', :'include_aliases' => :'Hash<String, Array<String>>', :'target_channel' => :'String' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
182 183 184 185 186 187 188 189 190 191 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 182 def ==(o) return true if self.equal?(o) self.class == o.class && included_segments == o.included_segments && excluded_segments == o.excluded_segments && app_id == o.app_id && filters == o.filters && include_aliases == o.include_aliases && target_channel == o.target_channel end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 239 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<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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 |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 310 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 |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 215 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 |
#eql?(o) ⇒ Boolean
195 196 197 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 195 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
201 202 203 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 201 def hash [included_segments, excluded_segments, app_id, filters, include_aliases, target_channel].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
152 153 154 155 156 157 158 159 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 152 def list_invalid_properties invalid_properties = Array.new if @app_id.nil? invalid_properties.push('invalid value for "app_id", app_id cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
286 287 288 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 286 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 292 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 |
#to_s ⇒ String
Returns the string representation of the object
280 281 282 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 280 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
163 164 165 166 167 168 |
# File 'lib/onesignal/models/estimate_notification_recipients_request.rb', line 163 def valid? return false if @app_id.nil? target_channel_validator = EnumAttributeValidator.new('String', ["push", "email", "sms"]) return false unless target_channel_validator.valid?(@target_channel) true end |