onesignal 0.2.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +14 -0
- data/Gemfile +6 -1
- data/LICENSE +6 -3
- data/README.md +144 -99
- data/RELEASE_INSTRUCTIONS.md +11 -0
- data/Rakefile +8 -8
- data/docs/App.md +76 -0
- data/docs/Button.md +22 -0
- data/docs/DefaultApi.md +1394 -0
- data/docs/DeliveryData.md +26 -0
- data/docs/ExportPlayersRequestBody.md +22 -0
- data/docs/Filter.md +24 -0
- data/docs/FilterExpressions.md +26 -0
- data/docs/FilterNotificationTarget.md +40 -0
- data/docs/GetNotificationRequestBody.md +22 -0
- data/docs/InlineResponse200.md +24 -0
- data/docs/InlineResponse2001.md +18 -0
- data/docs/InlineResponse2002.md +20 -0
- data/docs/InlineResponse2005.md +20 -0
- data/docs/InlineResponse2007.md +18 -0
- data/docs/InlineResponse2008.md +18 -0
- data/docs/InlineResponse201.md +20 -0
- data/docs/InlineResponse400.md +18 -0
- data/docs/InlineResponse4001.md +20 -0
- data/docs/InlineResponse4002.md +20 -0
- data/docs/InlineResponse4003.md +18 -0
- data/docs/InvalidIdentifierError.md +20 -0
- data/docs/Notification.md +240 -0
- data/docs/Notification200Errors.md +49 -0
- data/docs/NotificationAllOf.md +192 -0
- data/docs/NotificationAllOfAndroidBackgroundLayout.md +22 -0
- data/docs/NotificationSlice.md +24 -0
- data/docs/NotificationTarget.md +64 -0
- data/docs/NotificationWithMeta.md +260 -0
- data/docs/NotificationWithMetaAllOf.md +38 -0
- data/docs/Operator.md +18 -0
- data/docs/OutcomeData.md +22 -0
- data/docs/OutcomesData.md +18 -0
- data/docs/PlatformDeliveryData.md +28 -0
- data/docs/Player.md +70 -0
- data/docs/PlayerNotificationTarget.md +36 -0
- data/docs/PlayerSlice.md +24 -0
- data/docs/Purchase.md +22 -0
- data/docs/Segment.md +22 -0
- data/docs/SegmentNotificationTarget.md +20 -0
- data/docs/StringMap.md +102 -0
- data/docs/UpdatePlayerTagsRequestBody.md +18 -0
- data/lib/onesignal/api/default_api.rb +1365 -0
- data/lib/onesignal/api_client.rb +393 -0
- data/lib/onesignal/api_error.rb +57 -0
- data/lib/onesignal/configuration.rb +245 -0
- data/lib/onesignal/models/app.rb +519 -20
- data/lib/onesignal/models/button.rb +242 -0
- data/lib/onesignal/models/delivery_data.rb +260 -0
- data/lib/onesignal/models/export_players_request_body.rb +242 -0
- data/lib/onesignal/models/filter.rb +294 -0
- data/lib/onesignal/models/filter_expressions.rb +336 -0
- data/lib/onesignal/models/filter_notification_target.rb +330 -0
- data/lib/onesignal/models/get_notification_request_body.rb +273 -0
- data/lib/onesignal/models/inline_response200.rb +257 -0
- data/lib/onesignal/models/inline_response2001.rb +219 -0
- data/lib/onesignal/models/inline_response2002.rb +228 -0
- data/lib/onesignal/models/inline_response2005.rb +228 -0
- data/lib/onesignal/models/inline_response2007.rb +219 -0
- data/lib/onesignal/models/inline_response2008.rb +219 -0
- data/lib/onesignal/models/inline_response201.rb +229 -0
- data/lib/onesignal/models/inline_response400.rb +221 -0
- data/lib/onesignal/models/inline_response4001.rb +230 -0
- data/lib/onesignal/models/inline_response4002.rb +230 -0
- data/lib/onesignal/models/inline_response4003.rb +221 -0
- data/lib/onesignal/models/invalid_identifier_error.rb +234 -0
- data/lib/onesignal/models/notification.rb +1414 -9
- data/lib/onesignal/models/notification200_errors.rb +105 -0
- data/lib/onesignal/models/notification_all_of.rb +1144 -0
- data/lib/onesignal/models/notification_all_of_android_background_layout.rb +241 -0
- data/lib/onesignal/models/notification_slice.rb +248 -0
- data/lib/onesignal/models/notification_target.rb +495 -0
- data/lib/onesignal/models/notification_with_meta.rb +1526 -0
- data/lib/onesignal/models/notification_with_meta_all_of.rb +322 -0
- data/lib/onesignal/models/operator.rb +254 -0
- data/lib/onesignal/models/outcome_data.rb +286 -0
- data/lib/onesignal/models/outcomes_data.rb +221 -0
- data/lib/onesignal/models/platform_delivery_data.rb +265 -0
- data/lib/onesignal/models/player.rb +480 -13
- data/lib/onesignal/models/player_notification_target.rb +330 -0
- data/lib/onesignal/models/player_slice.rb +248 -0
- data/lib/onesignal/models/purchase.rb +255 -0
- data/lib/onesignal/models/segment.rb +252 -0
- data/lib/onesignal/models/segment_notification_target.rb +234 -0
- data/lib/onesignal/models/string_map.rb +640 -0
- data/lib/onesignal/models/update_player_tags_request_body.rb +220 -0
- data/lib/onesignal/version.rb +13 -1
- data/lib/onesignal.rb +73 -16
- data/onesignal.gemspec +37 -27
- data/spec/api/default_api_spec.rb +285 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/app_spec.rb +212 -0
- data/spec/models/button_spec.rb +46 -0
- data/spec/models/delivery_data_spec.rb +58 -0
- data/spec/models/export_players_request_body_spec.rb +46 -0
- data/spec/models/filter_expressions_spec.rb +66 -0
- data/spec/models/filter_notification_target_spec.rb +100 -0
- data/spec/models/filter_spec.rb +56 -0
- data/spec/models/get_notification_request_body_spec.rb +50 -0
- data/spec/models/inline_response2001_spec.rb +34 -0
- data/spec/models/inline_response2002_spec.rb +40 -0
- data/spec/models/inline_response2005_spec.rb +40 -0
- data/spec/models/inline_response2007_spec.rb +34 -0
- data/spec/models/inline_response2008_spec.rb +34 -0
- data/spec/models/inline_response200_spec.rb +52 -0
- data/spec/models/inline_response201_spec.rb +40 -0
- data/spec/models/inline_response4001_spec.rb +40 -0
- data/spec/models/inline_response4002_spec.rb +40 -0
- data/spec/models/inline_response4003_spec.rb +34 -0
- data/spec/models/inline_response400_spec.rb +34 -0
- data/spec/models/invalid_identifier_error_spec.rb +40 -0
- data/spec/models/notification200_errors_spec.rb +31 -0
- data/spec/models/notification_all_of_android_background_layout_spec.rb +46 -0
- data/spec/models/notification_all_of_spec.rb +560 -0
- data/spec/models/notification_slice_spec.rb +52 -0
- data/spec/models/notification_spec.rb +704 -0
- data/spec/models/notification_target_spec.rb +172 -0
- data/spec/models/notification_with_meta_all_of_spec.rb +94 -0
- data/spec/models/notification_with_meta_spec.rb +764 -0
- data/spec/models/operator_spec.rb +38 -0
- data/spec/models/outcome_data_spec.rb +50 -0
- data/spec/models/outcomes_data_spec.rb +34 -0
- data/spec/models/platform_delivery_data_spec.rb +64 -0
- data/spec/models/player_notification_target_spec.rb +88 -0
- data/spec/models/player_slice_spec.rb +52 -0
- data/spec/models/player_spec.rb +190 -0
- data/spec/models/purchase_spec.rb +46 -0
- data/spec/models/segment_notification_target_spec.rb +40 -0
- data/spec/models/segment_spec.rb +46 -0
- data/spec/models/string_map_spec.rb +286 -0
- data/spec/models/update_player_tags_request_body_spec.rb +34 -0
- data/spec/spec_helper.rb +111 -0
- metadata +203 -64
- data/.gitignore +0 -10
- data/.rubocop.yml +0 -17
- data/.travis.yml +0 -16
- data/CODE_OF_CONDUCT.md +0 -49
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/onesignal/app_id_missing_error.rb +0 -7
- data/lib/onesignal/client.rb +0 -44
- data/lib/onesignal/models/base_model.rb +0 -19
- data/lib/onesignal/request.rb +0 -94
- data/lib/onesignal/request_error.rb +0 -21
- data/lib/onesignal/resources/app_resource.rb +0 -27
- data/lib/onesignal/resources/base_resource.rb +0 -35
- data/lib/onesignal/resources/notification_resource.rb +0 -33
- data/lib/onesignal/resources/player_resource.rb +0 -53
@@ -0,0 +1,336 @@
|
|
1
|
+
=begin
|
2
|
+
#OneSignal
|
3
|
+
|
4
|
+
#A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.1
|
7
|
+
Contact: devrel@onesignal.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module OneSignal
|
17
|
+
class FilterExpressions
|
18
|
+
# Name of the field to use as the first operand in the filter expression.
|
19
|
+
attr_accessor :field
|
20
|
+
|
21
|
+
# If `field` is `tag`, this field is *required* to specify `key` inside the tags.
|
22
|
+
attr_accessor :key
|
23
|
+
|
24
|
+
# Constant value to use as the second operand in the filter expression. This value is *required* when the relation operator is a binary operator.
|
25
|
+
attr_accessor :value
|
26
|
+
|
27
|
+
# Operator of a filter expression.
|
28
|
+
attr_accessor :relation
|
29
|
+
|
30
|
+
# Strictly, this must be either `\"OR\"`, or `\"AND\"`. It can be used to compose Filters as part of a Filters object.
|
31
|
+
attr_accessor :operator
|
32
|
+
|
33
|
+
class EnumAttributeValidator
|
34
|
+
attr_reader :datatype
|
35
|
+
attr_reader :allowable_values
|
36
|
+
|
37
|
+
def initialize(datatype, allowable_values)
|
38
|
+
@allowable_values = allowable_values.map do |value|
|
39
|
+
case datatype.to_s
|
40
|
+
when /Integer/i
|
41
|
+
value.to_i
|
42
|
+
when /Float/i
|
43
|
+
value.to_f
|
44
|
+
else
|
45
|
+
value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def valid?(value)
|
51
|
+
!value || allowable_values.include?(value)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
56
|
+
def self.attribute_map
|
57
|
+
{
|
58
|
+
:'field' => :'field',
|
59
|
+
:'key' => :'key',
|
60
|
+
:'value' => :'value',
|
61
|
+
:'relation' => :'relation',
|
62
|
+
:'operator' => :'operator'
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns all the JSON keys this model knows about
|
67
|
+
def self.acceptable_attributes
|
68
|
+
attribute_map.values
|
69
|
+
end
|
70
|
+
|
71
|
+
# Attribute type mapping.
|
72
|
+
def self.openapi_types
|
73
|
+
{
|
74
|
+
:'field' => :'String',
|
75
|
+
:'key' => :'String',
|
76
|
+
:'value' => :'String',
|
77
|
+
:'relation' => :'String',
|
78
|
+
:'operator' => :'String'
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
# List of attributes with nullable: true
|
83
|
+
def self.openapi_nullable
|
84
|
+
Set.new([
|
85
|
+
])
|
86
|
+
end
|
87
|
+
|
88
|
+
# List of class defined in anyOf (OpenAPI v3)
|
89
|
+
def self.openapi_any_of
|
90
|
+
[
|
91
|
+
:'Filter',
|
92
|
+
:'Operator'
|
93
|
+
]
|
94
|
+
end
|
95
|
+
|
96
|
+
# Initializes the object
|
97
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
98
|
+
def initialize(attributes = {})
|
99
|
+
if (!attributes.is_a?(Hash))
|
100
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::FilterExpressions` initialize method"
|
101
|
+
end
|
102
|
+
|
103
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
104
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
105
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
106
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::FilterExpressions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
107
|
+
end
|
108
|
+
h[k.to_sym] = v
|
109
|
+
}
|
110
|
+
|
111
|
+
if attributes.key?(:'field')
|
112
|
+
self.field = attributes[:'field']
|
113
|
+
end
|
114
|
+
|
115
|
+
if attributes.key?(:'key')
|
116
|
+
self.key = attributes[:'key']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:'value')
|
120
|
+
self.value = attributes[:'value']
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'relation')
|
124
|
+
self.relation = attributes[:'relation']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'operator')
|
128
|
+
self.operator = attributes[:'operator']
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
133
|
+
# @return Array for valid properties with the reasons
|
134
|
+
def list_invalid_properties
|
135
|
+
invalid_properties = Array.new
|
136
|
+
if @field.nil?
|
137
|
+
invalid_properties.push('invalid value for "field", field cannot be nil.')
|
138
|
+
end
|
139
|
+
|
140
|
+
if @relation.nil?
|
141
|
+
invalid_properties.push('invalid value for "relation", relation cannot be nil.')
|
142
|
+
end
|
143
|
+
|
144
|
+
invalid_properties
|
145
|
+
end
|
146
|
+
|
147
|
+
# Check to see if the all the properties in the model are valid
|
148
|
+
# @return true if the model is valid
|
149
|
+
def valid?
|
150
|
+
return false if @field.nil?
|
151
|
+
return false if @relation.nil?
|
152
|
+
relation_validator = EnumAttributeValidator.new('String', [">", "<", "=", "!=", "exists", "not_exists", "time_elapsed_gt", "time_elapsed_lt"])
|
153
|
+
return false unless relation_validator.valid?(@relation)
|
154
|
+
operator_validator = EnumAttributeValidator.new('String', ["OR", "AND"])
|
155
|
+
return false unless operator_validator.valid?(@operator)
|
156
|
+
_any_of_found = false
|
157
|
+
self.class.openapi_any_of.each do |_class|
|
158
|
+
_any_of = OneSignal.const_get(_class).build_from_hash(self.to_hash)
|
159
|
+
if _any_of.valid?
|
160
|
+
_any_of_found = true
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
if !_any_of_found
|
165
|
+
return false
|
166
|
+
end
|
167
|
+
|
168
|
+
true
|
169
|
+
end
|
170
|
+
|
171
|
+
# Custom attribute writer method checking allowed values (enum).
|
172
|
+
# @param [Object] relation Object to be assigned
|
173
|
+
def relation=(relation)
|
174
|
+
validator = EnumAttributeValidator.new('String', [">", "<", "=", "!=", "exists", "not_exists", "time_elapsed_gt", "time_elapsed_lt"])
|
175
|
+
unless validator.valid?(relation)
|
176
|
+
fail ArgumentError, "invalid value for \"relation\", must be one of #{validator.allowable_values}."
|
177
|
+
end
|
178
|
+
@relation = relation
|
179
|
+
end
|
180
|
+
|
181
|
+
# Custom attribute writer method checking allowed values (enum).
|
182
|
+
# @param [Object] operator Object to be assigned
|
183
|
+
def operator=(operator)
|
184
|
+
validator = EnumAttributeValidator.new('String', ["OR", "AND"])
|
185
|
+
unless validator.valid?(operator)
|
186
|
+
fail ArgumentError, "invalid value for \"operator\", must be one of #{validator.allowable_values}."
|
187
|
+
end
|
188
|
+
@operator = operator
|
189
|
+
end
|
190
|
+
|
191
|
+
# Checks equality by comparing each attribute.
|
192
|
+
# @param [Object] Object to be compared
|
193
|
+
def ==(o)
|
194
|
+
return true if self.equal?(o)
|
195
|
+
self.class == o.class &&
|
196
|
+
field == o.field &&
|
197
|
+
key == o.key &&
|
198
|
+
value == o.value &&
|
199
|
+
relation == o.relation &&
|
200
|
+
operator == o.operator
|
201
|
+
end
|
202
|
+
|
203
|
+
# @see the `==` method
|
204
|
+
# @param [Object] Object to be compared
|
205
|
+
def eql?(o)
|
206
|
+
self == o
|
207
|
+
end
|
208
|
+
|
209
|
+
# Calculates hash code according to all attributes.
|
210
|
+
# @return [Integer] Hash code
|
211
|
+
def hash
|
212
|
+
[field, key, value, relation, operator].hash
|
213
|
+
end
|
214
|
+
|
215
|
+
# Builds the object from hash
|
216
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
217
|
+
# @return [Object] Returns the model itself
|
218
|
+
def self.build_from_hash(attributes)
|
219
|
+
new.build_from_hash(attributes)
|
220
|
+
end
|
221
|
+
|
222
|
+
# Builds the object from hash
|
223
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
224
|
+
# @return [Object] Returns the model itself
|
225
|
+
def build_from_hash(attributes)
|
226
|
+
return nil unless attributes.is_a?(Hash)
|
227
|
+
attributes = attributes.transform_keys(&:to_sym)
|
228
|
+
self.class.openapi_types.each_pair do |key, type|
|
229
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
230
|
+
self.send("#{key}=", nil)
|
231
|
+
elsif type =~ /\AArray<(.*)>/i
|
232
|
+
# check to ensure the input is an array given that the attribute
|
233
|
+
# is documented as an array but the input is not
|
234
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
235
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
236
|
+
end
|
237
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
238
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
self
|
243
|
+
end
|
244
|
+
|
245
|
+
# Deserializes the data based on type
|
246
|
+
# @param string type Data type
|
247
|
+
# @param string value Value to be deserialized
|
248
|
+
# @return [Object] Deserialized data
|
249
|
+
def _deserialize(type, value)
|
250
|
+
case type.to_sym
|
251
|
+
when :Time
|
252
|
+
Time.parse(value)
|
253
|
+
when :Date
|
254
|
+
Date.parse(value)
|
255
|
+
when :String
|
256
|
+
value.to_s
|
257
|
+
when :Integer
|
258
|
+
value.to_i
|
259
|
+
when :Float
|
260
|
+
value.to_f
|
261
|
+
when :Boolean
|
262
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
263
|
+
true
|
264
|
+
else
|
265
|
+
false
|
266
|
+
end
|
267
|
+
when :Object
|
268
|
+
# generic object (usually a Hash), return directly
|
269
|
+
value
|
270
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
271
|
+
inner_type = Regexp.last_match[:inner_type]
|
272
|
+
value.map { |v| _deserialize(inner_type, v) }
|
273
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
274
|
+
k_type = Regexp.last_match[:k_type]
|
275
|
+
v_type = Regexp.last_match[:v_type]
|
276
|
+
{}.tap do |hash|
|
277
|
+
value.each do |k, v|
|
278
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
else # model
|
282
|
+
# models (e.g. Pet) or oneOf
|
283
|
+
klass = OneSignal.const_get(type)
|
284
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
# Returns the string representation of the object
|
289
|
+
# @return [String] String presentation of the object
|
290
|
+
def to_s
|
291
|
+
to_hash.to_s
|
292
|
+
end
|
293
|
+
|
294
|
+
# to_body is an alias to to_hash (backward compatibility)
|
295
|
+
# @return [Hash] Returns the object in the form of hash
|
296
|
+
def to_body
|
297
|
+
to_hash
|
298
|
+
end
|
299
|
+
|
300
|
+
# Returns the object in the form of hash
|
301
|
+
# @return [Hash] Returns the object in the form of hash
|
302
|
+
def to_hash
|
303
|
+
hash = {}
|
304
|
+
self.class.attribute_map.each_pair do |attr, param|
|
305
|
+
value = self.send(attr)
|
306
|
+
if value.nil?
|
307
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
308
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
309
|
+
end
|
310
|
+
|
311
|
+
hash[param] = _to_hash(value)
|
312
|
+
end
|
313
|
+
hash
|
314
|
+
end
|
315
|
+
|
316
|
+
# Outputs non-array value in the form of hash
|
317
|
+
# For object, use to_hash. Otherwise, just return the value
|
318
|
+
# @param [Object] value Any valid value
|
319
|
+
# @return [Hash] Returns the value in the form of hash
|
320
|
+
def _to_hash(value)
|
321
|
+
if value.is_a?(Array)
|
322
|
+
value.compact.map { |v| _to_hash(v) }
|
323
|
+
elsif value.is_a?(Hash)
|
324
|
+
{}.tap do |hash|
|
325
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
326
|
+
end
|
327
|
+
elsif value.respond_to? :to_hash
|
328
|
+
value.to_hash
|
329
|
+
else
|
330
|
+
value
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
end
|
335
|
+
|
336
|
+
end
|
@@ -0,0 +1,330 @@
|
|
1
|
+
=begin
|
2
|
+
#OneSignal
|
3
|
+
|
4
|
+
#A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.1
|
7
|
+
Contact: devrel@onesignal.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module OneSignal
|
17
|
+
class FilterNotificationTarget
|
18
|
+
# relation = \">\" or \"<\" hours_ago = number of hours before or after the users last session. Example: \"1.1\"
|
19
|
+
attr_accessor :last_session
|
20
|
+
|
21
|
+
# relation = \">\" or \"<\" hours_ago = number of hours before or after the users first session. Example: \"1.1\"
|
22
|
+
attr_accessor :first_session
|
23
|
+
|
24
|
+
# relation = \">\", \"<\", \"=\" or \"!=\" value = number sessions. Example: \"1\"
|
25
|
+
attr_accessor :session_count
|
26
|
+
|
27
|
+
# relation = \">\", \"<\", \"=\" or \"!=\" value = Time in seconds the user has been in your app. Example: \"3600\"
|
28
|
+
attr_accessor :session_time
|
29
|
+
|
30
|
+
# relation = \">\", \"<\", or \"=\" value = Amount in USD a user has spent on IAP (In App Purchases). Example: \"0.99\"
|
31
|
+
attr_accessor :amount_spent
|
32
|
+
|
33
|
+
# relation = \">\", \"<\" or \"=\" key = SKU purchased in your app as an IAP (In App Purchases). Example: \"com.domain.100coinpack\" value = value of SKU to compare to. Example: \"0.99\"
|
34
|
+
attr_accessor :bought_sku
|
35
|
+
|
36
|
+
# relation = \">\", \"<\", \"=\", \"!=\", \"exists\", \"not_exists\", \"time_elapsed_gt\" (paid plan only) or \"time_elapsed_lt\" (paid plan only) See Time Operators key = Tag key to compare. value = Tag value to compare. Not required for \"exists\" or \"not_exists\". Example: See Formatting Filters
|
37
|
+
attr_accessor :tag
|
38
|
+
|
39
|
+
# relation = \"=\" or \"!=\" value = 2 character language code. Example: \"en\". For a list of all language codes see Language & Localization.
|
40
|
+
attr_accessor :language
|
41
|
+
|
42
|
+
# relation = \">\", \"<\", \"=\" or \"!=\" value = app version. Example: \"1.0.0\"
|
43
|
+
attr_accessor :app_version
|
44
|
+
|
45
|
+
# radius = in meters lat = latitude long = longitude
|
46
|
+
attr_accessor :location
|
47
|
+
|
48
|
+
# value = email address Only for sending Push Notifications Use this for targeting push subscribers associated with an email set with all SDK setEmail methods To send emails to specific email addresses use include_email_tokens parameter
|
49
|
+
attr_accessor :email
|
50
|
+
|
51
|
+
# relation = \"=\" value = 2-digit Country code Example: \"field\": \"country\", \"relation\": \"=\", \"value\", \"US\"
|
52
|
+
attr_accessor :country
|
53
|
+
|
54
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
55
|
+
def self.attribute_map
|
56
|
+
{
|
57
|
+
:'last_session' => :'last_session',
|
58
|
+
:'first_session' => :'first_session',
|
59
|
+
:'session_count' => :'session_count',
|
60
|
+
:'session_time' => :'session_time',
|
61
|
+
:'amount_spent' => :'amount_spent',
|
62
|
+
:'bought_sku' => :'bought_sku',
|
63
|
+
:'tag' => :'tag',
|
64
|
+
:'language' => :'language',
|
65
|
+
:'app_version' => :'app_version',
|
66
|
+
:'location' => :'location',
|
67
|
+
:'email' => :'email',
|
68
|
+
:'country' => :'country'
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns all the JSON keys this model knows about
|
73
|
+
def self.acceptable_attributes
|
74
|
+
attribute_map.values
|
75
|
+
end
|
76
|
+
|
77
|
+
# Attribute type mapping.
|
78
|
+
def self.openapi_types
|
79
|
+
{
|
80
|
+
:'last_session' => :'String',
|
81
|
+
:'first_session' => :'String',
|
82
|
+
:'session_count' => :'String',
|
83
|
+
:'session_time' => :'String',
|
84
|
+
:'amount_spent' => :'String',
|
85
|
+
:'bought_sku' => :'String',
|
86
|
+
:'tag' => :'String',
|
87
|
+
:'language' => :'String',
|
88
|
+
:'app_version' => :'String',
|
89
|
+
:'location' => :'String',
|
90
|
+
:'email' => :'String',
|
91
|
+
:'country' => :'String'
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
# List of attributes with nullable: true
|
96
|
+
def self.openapi_nullable
|
97
|
+
Set.new([
|
98
|
+
])
|
99
|
+
end
|
100
|
+
|
101
|
+
# Initializes the object
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
103
|
+
def initialize(attributes = {})
|
104
|
+
if (!attributes.is_a?(Hash))
|
105
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::FilterNotificationTarget` initialize method"
|
106
|
+
end
|
107
|
+
|
108
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
109
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
110
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
111
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::FilterNotificationTarget`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
112
|
+
end
|
113
|
+
h[k.to_sym] = v
|
114
|
+
}
|
115
|
+
|
116
|
+
if attributes.key?(:'last_session')
|
117
|
+
self.last_session = attributes[:'last_session']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.key?(:'first_session')
|
121
|
+
self.first_session = attributes[:'first_session']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'session_count')
|
125
|
+
self.session_count = attributes[:'session_count']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'session_time')
|
129
|
+
self.session_time = attributes[:'session_time']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.key?(:'amount_spent')
|
133
|
+
self.amount_spent = attributes[:'amount_spent']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.key?(:'bought_sku')
|
137
|
+
self.bought_sku = attributes[:'bought_sku']
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.key?(:'tag')
|
141
|
+
self.tag = attributes[:'tag']
|
142
|
+
end
|
143
|
+
|
144
|
+
if attributes.key?(:'language')
|
145
|
+
self.language = attributes[:'language']
|
146
|
+
end
|
147
|
+
|
148
|
+
if attributes.key?(:'app_version')
|
149
|
+
self.app_version = attributes[:'app_version']
|
150
|
+
end
|
151
|
+
|
152
|
+
if attributes.key?(:'location')
|
153
|
+
self.location = attributes[:'location']
|
154
|
+
end
|
155
|
+
|
156
|
+
if attributes.key?(:'email')
|
157
|
+
self.email = attributes[:'email']
|
158
|
+
end
|
159
|
+
|
160
|
+
if attributes.key?(:'country')
|
161
|
+
self.country = attributes[:'country']
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
166
|
+
# @return Array for valid properties with the reasons
|
167
|
+
def list_invalid_properties
|
168
|
+
invalid_properties = Array.new
|
169
|
+
invalid_properties
|
170
|
+
end
|
171
|
+
|
172
|
+
# Check to see if the all the properties in the model are valid
|
173
|
+
# @return true if the model is valid
|
174
|
+
def valid?
|
175
|
+
true
|
176
|
+
end
|
177
|
+
|
178
|
+
# Checks equality by comparing each attribute.
|
179
|
+
# @param [Object] Object to be compared
|
180
|
+
def ==(o)
|
181
|
+
return true if self.equal?(o)
|
182
|
+
self.class == o.class &&
|
183
|
+
last_session == o.last_session &&
|
184
|
+
first_session == o.first_session &&
|
185
|
+
session_count == o.session_count &&
|
186
|
+
session_time == o.session_time &&
|
187
|
+
amount_spent == o.amount_spent &&
|
188
|
+
bought_sku == o.bought_sku &&
|
189
|
+
tag == o.tag &&
|
190
|
+
language == o.language &&
|
191
|
+
app_version == o.app_version &&
|
192
|
+
location == o.location &&
|
193
|
+
email == o.email &&
|
194
|
+
country == o.country
|
195
|
+
end
|
196
|
+
|
197
|
+
# @see the `==` method
|
198
|
+
# @param [Object] Object to be compared
|
199
|
+
def eql?(o)
|
200
|
+
self == o
|
201
|
+
end
|
202
|
+
|
203
|
+
# Calculates hash code according to all attributes.
|
204
|
+
# @return [Integer] Hash code
|
205
|
+
def hash
|
206
|
+
[last_session, first_session, session_count, session_time, amount_spent, bought_sku, tag, language, app_version, location, email, country].hash
|
207
|
+
end
|
208
|
+
|
209
|
+
# Builds the object from hash
|
210
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
211
|
+
# @return [Object] Returns the model itself
|
212
|
+
def self.build_from_hash(attributes)
|
213
|
+
new.build_from_hash(attributes)
|
214
|
+
end
|
215
|
+
|
216
|
+
# Builds the object from hash
|
217
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
218
|
+
# @return [Object] Returns the model itself
|
219
|
+
def build_from_hash(attributes)
|
220
|
+
return nil unless attributes.is_a?(Hash)
|
221
|
+
attributes = attributes.transform_keys(&:to_sym)
|
222
|
+
self.class.openapi_types.each_pair do |key, type|
|
223
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
224
|
+
self.send("#{key}=", nil)
|
225
|
+
elsif type =~ /\AArray<(.*)>/i
|
226
|
+
# check to ensure the input is an array given that the attribute
|
227
|
+
# is documented as an array but the input is not
|
228
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
229
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
230
|
+
end
|
231
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
232
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
self
|
237
|
+
end
|
238
|
+
|
239
|
+
# Deserializes the data based on type
|
240
|
+
# @param string type Data type
|
241
|
+
# @param string value Value to be deserialized
|
242
|
+
# @return [Object] Deserialized data
|
243
|
+
def _deserialize(type, value)
|
244
|
+
case type.to_sym
|
245
|
+
when :Time
|
246
|
+
Time.parse(value)
|
247
|
+
when :Date
|
248
|
+
Date.parse(value)
|
249
|
+
when :String
|
250
|
+
value.to_s
|
251
|
+
when :Integer
|
252
|
+
value.to_i
|
253
|
+
when :Float
|
254
|
+
value.to_f
|
255
|
+
when :Boolean
|
256
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
257
|
+
true
|
258
|
+
else
|
259
|
+
false
|
260
|
+
end
|
261
|
+
when :Object
|
262
|
+
# generic object (usually a Hash), return directly
|
263
|
+
value
|
264
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
265
|
+
inner_type = Regexp.last_match[:inner_type]
|
266
|
+
value.map { |v| _deserialize(inner_type, v) }
|
267
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
268
|
+
k_type = Regexp.last_match[:k_type]
|
269
|
+
v_type = Regexp.last_match[:v_type]
|
270
|
+
{}.tap do |hash|
|
271
|
+
value.each do |k, v|
|
272
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
else # model
|
276
|
+
# models (e.g. Pet) or oneOf
|
277
|
+
klass = OneSignal.const_get(type)
|
278
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
# Returns the string representation of the object
|
283
|
+
# @return [String] String presentation of the object
|
284
|
+
def to_s
|
285
|
+
to_hash.to_s
|
286
|
+
end
|
287
|
+
|
288
|
+
# to_body is an alias to to_hash (backward compatibility)
|
289
|
+
# @return [Hash] Returns the object in the form of hash
|
290
|
+
def to_body
|
291
|
+
to_hash
|
292
|
+
end
|
293
|
+
|
294
|
+
# Returns the object in the form of hash
|
295
|
+
# @return [Hash] Returns the object in the form of hash
|
296
|
+
def to_hash
|
297
|
+
hash = {}
|
298
|
+
self.class.attribute_map.each_pair do |attr, param|
|
299
|
+
value = self.send(attr)
|
300
|
+
if value.nil?
|
301
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
302
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
303
|
+
end
|
304
|
+
|
305
|
+
hash[param] = _to_hash(value)
|
306
|
+
end
|
307
|
+
hash
|
308
|
+
end
|
309
|
+
|
310
|
+
# Outputs non-array value in the form of hash
|
311
|
+
# For object, use to_hash. Otherwise, just return the value
|
312
|
+
# @param [Object] value Any valid value
|
313
|
+
# @return [Hash] Returns the value in the form of hash
|
314
|
+
def _to_hash(value)
|
315
|
+
if value.is_a?(Array)
|
316
|
+
value.compact.map { |v| _to_hash(v) }
|
317
|
+
elsif value.is_a?(Hash)
|
318
|
+
{}.tap do |hash|
|
319
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
320
|
+
end
|
321
|
+
elsif value.respond_to? :to_hash
|
322
|
+
value.to_hash
|
323
|
+
else
|
324
|
+
value
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|