activitysmith 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,361 @@
1
+ =begin
2
+ #ActivitySmith API
3
+
4
+ #Send push notifications and Live Activities to your own devices via a single API key.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.7.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ # Returned after a managed stream request is reconciled.
18
+ class LiveActivityStreamPutResponse
19
+ attr_accessor :success
20
+
21
+ attr_accessor :operation
22
+
23
+ attr_accessor :stream_key
24
+
25
+ attr_accessor :activity_id
26
+
27
+ attr_accessor :previous_activity_id
28
+
29
+ attr_accessor :devices_notified
30
+
31
+ attr_accessor :devices_queued
32
+
33
+ attr_accessor :users_notified
34
+
35
+ attr_accessor :effective_channel_slugs
36
+
37
+ attr_accessor :timestamp
38
+
39
+ class EnumAttributeValidator
40
+ attr_reader :datatype
41
+ attr_reader :allowable_values
42
+
43
+ def initialize(datatype, allowable_values)
44
+ @allowable_values = allowable_values.map do |value|
45
+ case datatype.to_s
46
+ when /Integer/i
47
+ value.to_i
48
+ when /Float/i
49
+ value.to_f
50
+ else
51
+ value
52
+ end
53
+ end
54
+ end
55
+
56
+ def valid?(value)
57
+ !value || allowable_values.include?(value)
58
+ end
59
+ end
60
+
61
+ # Attribute mapping from ruby-style variable name to JSON key.
62
+ def self.attribute_map
63
+ {
64
+ :'success' => :'success',
65
+ :'operation' => :'operation',
66
+ :'stream_key' => :'stream_key',
67
+ :'activity_id' => :'activity_id',
68
+ :'previous_activity_id' => :'previous_activity_id',
69
+ :'devices_notified' => :'devices_notified',
70
+ :'devices_queued' => :'devices_queued',
71
+ :'users_notified' => :'users_notified',
72
+ :'effective_channel_slugs' => :'effective_channel_slugs',
73
+ :'timestamp' => :'timestamp'
74
+ }
75
+ end
76
+
77
+ # Returns all the JSON keys this model knows about
78
+ def self.acceptable_attributes
79
+ attribute_map.values
80
+ end
81
+
82
+ # Attribute type mapping.
83
+ def self.openapi_types
84
+ {
85
+ :'success' => :'Boolean',
86
+ :'operation' => :'String',
87
+ :'stream_key' => :'String',
88
+ :'activity_id' => :'String',
89
+ :'previous_activity_id' => :'String',
90
+ :'devices_notified' => :'Integer',
91
+ :'devices_queued' => :'Integer',
92
+ :'users_notified' => :'Integer',
93
+ :'effective_channel_slugs' => :'Array<String>',
94
+ :'timestamp' => :'Time'
95
+ }
96
+ end
97
+
98
+ # List of attributes with nullable: true
99
+ def self.openapi_nullable
100
+ Set.new([
101
+ :'activity_id',
102
+ ])
103
+ end
104
+
105
+ # Initializes the object
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ def initialize(attributes = {})
108
+ if (!attributes.is_a?(Hash))
109
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::LiveActivityStreamPutResponse` initialize method"
110
+ end
111
+
112
+ # check to see if the attribute exists and convert string to symbol for hash key
113
+ attributes = attributes.each_with_object({}) { |(k, v), h|
114
+ if (!self.class.attribute_map.key?(k.to_sym))
115
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::LiveActivityStreamPutResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
116
+ end
117
+ h[k.to_sym] = v
118
+ }
119
+
120
+ if attributes.key?(:'success')
121
+ self.success = attributes[:'success']
122
+ else
123
+ self.success = nil
124
+ end
125
+
126
+ if attributes.key?(:'operation')
127
+ self.operation = attributes[:'operation']
128
+ else
129
+ self.operation = nil
130
+ end
131
+
132
+ if attributes.key?(:'stream_key')
133
+ self.stream_key = attributes[:'stream_key']
134
+ else
135
+ self.stream_key = nil
136
+ end
137
+
138
+ if attributes.key?(:'activity_id')
139
+ self.activity_id = attributes[:'activity_id']
140
+ end
141
+
142
+ if attributes.key?(:'previous_activity_id')
143
+ self.previous_activity_id = attributes[:'previous_activity_id']
144
+ end
145
+
146
+ if attributes.key?(:'devices_notified')
147
+ self.devices_notified = attributes[:'devices_notified']
148
+ end
149
+
150
+ if attributes.key?(:'devices_queued')
151
+ self.devices_queued = attributes[:'devices_queued']
152
+ end
153
+
154
+ if attributes.key?(:'users_notified')
155
+ self.users_notified = attributes[:'users_notified']
156
+ end
157
+
158
+ if attributes.key?(:'effective_channel_slugs')
159
+ if (value = attributes[:'effective_channel_slugs']).is_a?(Array)
160
+ self.effective_channel_slugs = value
161
+ end
162
+ end
163
+
164
+ if attributes.key?(:'timestamp')
165
+ self.timestamp = attributes[:'timestamp']
166
+ else
167
+ self.timestamp = nil
168
+ end
169
+ end
170
+
171
+ # Show invalid properties with the reasons. Usually used together with valid?
172
+ # @return Array for valid properties with the reasons
173
+ def list_invalid_properties
174
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
175
+ invalid_properties = Array.new
176
+ if @success.nil?
177
+ invalid_properties.push('invalid value for "success", success cannot be nil.')
178
+ end
179
+
180
+ if @operation.nil?
181
+ invalid_properties.push('invalid value for "operation", operation cannot be nil.')
182
+ end
183
+
184
+ if @stream_key.nil?
185
+ invalid_properties.push('invalid value for "stream_key", stream_key cannot be nil.')
186
+ end
187
+
188
+ if @timestamp.nil?
189
+ invalid_properties.push('invalid value for "timestamp", timestamp cannot be nil.')
190
+ end
191
+
192
+ invalid_properties
193
+ end
194
+
195
+ # Check to see if the all the properties in the model are valid
196
+ # @return true if the model is valid
197
+ def valid?
198
+ warn '[DEPRECATED] the `valid?` method is obsolete'
199
+ return false if @success.nil?
200
+ return false if @operation.nil?
201
+ operation_validator = EnumAttributeValidator.new('String', ["started", "updated", "rotated", "noop", "paused"])
202
+ return false unless operation_validator.valid?(@operation)
203
+ return false if @stream_key.nil?
204
+ return false if @timestamp.nil?
205
+ true
206
+ end
207
+
208
+ # Custom attribute writer method checking allowed values (enum).
209
+ # @param [Object] operation Object to be assigned
210
+ def operation=(operation)
211
+ validator = EnumAttributeValidator.new('String', ["started", "updated", "rotated", "noop", "paused"])
212
+ unless validator.valid?(operation)
213
+ fail ArgumentError, "invalid value for \"operation\", must be one of #{validator.allowable_values}."
214
+ end
215
+ @operation = operation
216
+ end
217
+
218
+ # Checks equality by comparing each attribute.
219
+ # @param [Object] Object to be compared
220
+ def ==(o)
221
+ return true if self.equal?(o)
222
+ self.class == o.class &&
223
+ success == o.success &&
224
+ operation == o.operation &&
225
+ stream_key == o.stream_key &&
226
+ activity_id == o.activity_id &&
227
+ previous_activity_id == o.previous_activity_id &&
228
+ devices_notified == o.devices_notified &&
229
+ devices_queued == o.devices_queued &&
230
+ users_notified == o.users_notified &&
231
+ effective_channel_slugs == o.effective_channel_slugs &&
232
+ timestamp == o.timestamp
233
+ end
234
+
235
+ # @see the `==` method
236
+ # @param [Object] Object to be compared
237
+ def eql?(o)
238
+ self == o
239
+ end
240
+
241
+ # Calculates hash code according to all attributes.
242
+ # @return [Integer] Hash code
243
+ def hash
244
+ [success, operation, stream_key, activity_id, previous_activity_id, devices_notified, devices_queued, users_notified, effective_channel_slugs, timestamp].hash
245
+ end
246
+
247
+ # Builds the object from hash
248
+ # @param [Hash] attributes Model attributes in the form of hash
249
+ # @return [Object] Returns the model itself
250
+ def self.build_from_hash(attributes)
251
+ return nil unless attributes.is_a?(Hash)
252
+ attributes = attributes.transform_keys(&:to_sym)
253
+ transformed_hash = {}
254
+ openapi_types.each_pair do |key, type|
255
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
256
+ transformed_hash["#{key}"] = nil
257
+ elsif type =~ /\AArray<(.*)>/i
258
+ # check to ensure the input is an array given that the attribute
259
+ # is documented as an array but the input is not
260
+ if attributes[attribute_map[key]].is_a?(Array)
261
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
262
+ end
263
+ elsif !attributes[attribute_map[key]].nil?
264
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
265
+ end
266
+ end
267
+ new(transformed_hash)
268
+ end
269
+
270
+ # Deserializes the data based on type
271
+ # @param string type Data type
272
+ # @param string value Value to be deserialized
273
+ # @return [Object] Deserialized data
274
+ def self._deserialize(type, value)
275
+ case type.to_sym
276
+ when :Time
277
+ Time.parse(value)
278
+ when :Date
279
+ Date.parse(value)
280
+ when :String
281
+ value.to_s
282
+ when :Integer
283
+ value.to_i
284
+ when :Float
285
+ value.to_f
286
+ when :Boolean
287
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
288
+ true
289
+ else
290
+ false
291
+ end
292
+ when :Object
293
+ # generic object (usually a Hash), return directly
294
+ value
295
+ when /\AArray<(?<inner_type>.+)>\z/
296
+ inner_type = Regexp.last_match[:inner_type]
297
+ value.map { |v| _deserialize(inner_type, v) }
298
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
299
+ k_type = Regexp.last_match[:k_type]
300
+ v_type = Regexp.last_match[:v_type]
301
+ {}.tap do |hash|
302
+ value.each do |k, v|
303
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
304
+ end
305
+ end
306
+ else # model
307
+ # models (e.g. Pet) or oneOf
308
+ klass = OpenapiClient.const_get(type)
309
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
310
+ end
311
+ end
312
+
313
+ # Returns the string representation of the object
314
+ # @return [String] String presentation of the object
315
+ def to_s
316
+ to_hash.to_s
317
+ end
318
+
319
+ # to_body is an alias to to_hash (backward compatibility)
320
+ # @return [Hash] Returns the object in the form of hash
321
+ def to_body
322
+ to_hash
323
+ end
324
+
325
+ # Returns the object in the form of hash
326
+ # @return [Hash] Returns the object in the form of hash
327
+ def to_hash
328
+ hash = {}
329
+ self.class.attribute_map.each_pair do |attr, param|
330
+ value = self.send(attr)
331
+ if value.nil?
332
+ is_nullable = self.class.openapi_nullable.include?(attr)
333
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
334
+ end
335
+
336
+ hash[param] = _to_hash(value)
337
+ end
338
+ hash
339
+ end
340
+
341
+ # Outputs non-array value in the form of hash
342
+ # For object, use to_hash. Otherwise, just return the value
343
+ # @param [Object] value Any valid value
344
+ # @return [Hash] Returns the value in the form of hash
345
+ def _to_hash(value)
346
+ if value.is_a?(Array)
347
+ value.compact.map { |v| _to_hash(v) }
348
+ elsif value.is_a?(Hash)
349
+ {}.tap do |hash|
350
+ value.each { |k, v| hash[k] = _to_hash(v) }
351
+ end
352
+ elsif value.respond_to? :to_hash
353
+ value.to_hash
354
+ else
355
+ value
356
+ end
357
+ end
358
+
359
+ end
360
+
361
+ end
@@ -0,0 +1,280 @@
1
+ =begin
2
+ #ActivitySmith API
3
+
4
+ #Send push notifications and Live Activities to your own devices via a single API key.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.7.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ # Send the latest state for a managed Live Activity stream. channels is the streamlined form for stream targeting. target.channels is also accepted for compatibility. If both are provided, they must match.
18
+ class LiveActivityStreamRequest
19
+ attr_accessor :content_state
20
+
21
+ attr_accessor :action
22
+
23
+ attr_accessor :alert
24
+
25
+ # Channel slugs. When omitted, API key scope determines recipients.
26
+ attr_accessor :channels
27
+
28
+ attr_accessor :target
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'content_state' => :'content_state',
34
+ :'action' => :'action',
35
+ :'alert' => :'alert',
36
+ :'channels' => :'channels',
37
+ :'target' => :'target'
38
+ }
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'content_state' => :'StreamContentState',
50
+ :'action' => :'LiveActivityAction',
51
+ :'alert' => :'AlertPayload',
52
+ :'channels' => :'Array<String>',
53
+ :'target' => :'ChannelTarget'
54
+ }
55
+ end
56
+
57
+ # List of attributes with nullable: true
58
+ def self.openapi_nullable
59
+ Set.new([
60
+ ])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::LiveActivityStreamRequest` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!self.class.attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::LiveActivityStreamRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'content_state')
79
+ self.content_state = attributes[:'content_state']
80
+ else
81
+ self.content_state = nil
82
+ end
83
+
84
+ if attributes.key?(:'action')
85
+ self.action = attributes[:'action']
86
+ end
87
+
88
+ if attributes.key?(:'alert')
89
+ self.alert = attributes[:'alert']
90
+ end
91
+
92
+ if attributes.key?(:'channels')
93
+ if (value = attributes[:'channels']).is_a?(Array)
94
+ self.channels = value
95
+ end
96
+ end
97
+
98
+ if attributes.key?(:'target')
99
+ self.target = attributes[:'target']
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
107
+ invalid_properties = Array.new
108
+ if @content_state.nil?
109
+ invalid_properties.push('invalid value for "content_state", content_state cannot be nil.')
110
+ end
111
+
112
+ if !@channels.nil? && @channels.length < 1
113
+ invalid_properties.push('invalid value for "channels", number of items must be greater than or equal to 1.')
114
+ end
115
+
116
+ invalid_properties
117
+ end
118
+
119
+ # Check to see if the all the properties in the model are valid
120
+ # @return true if the model is valid
121
+ def valid?
122
+ warn '[DEPRECATED] the `valid?` method is obsolete'
123
+ return false if @content_state.nil?
124
+ return false if !@channels.nil? && @channels.length < 1
125
+ true
126
+ end
127
+
128
+ # Custom attribute writer method with validation
129
+ # @param [Object] channels Value to be assigned
130
+ def channels=(channels)
131
+ if channels.nil?
132
+ fail ArgumentError, 'channels cannot be nil'
133
+ end
134
+
135
+ if channels.length < 1
136
+ fail ArgumentError, 'invalid value for "channels", number of items must be greater than or equal to 1.'
137
+ end
138
+
139
+ @channels = channels
140
+ end
141
+
142
+ # Checks equality by comparing each attribute.
143
+ # @param [Object] Object to be compared
144
+ def ==(o)
145
+ return true if self.equal?(o)
146
+ self.class == o.class &&
147
+ content_state == o.content_state &&
148
+ action == o.action &&
149
+ alert == o.alert &&
150
+ channels == o.channels &&
151
+ target == o.target
152
+ end
153
+
154
+ # @see the `==` method
155
+ # @param [Object] Object to be compared
156
+ def eql?(o)
157
+ self == o
158
+ end
159
+
160
+ # Calculates hash code according to all attributes.
161
+ # @return [Integer] Hash code
162
+ def hash
163
+ [content_state, action, alert, channels, target].hash
164
+ end
165
+
166
+ # Builds the object from hash
167
+ # @param [Hash] attributes Model attributes in the form of hash
168
+ # @return [Object] Returns the model itself
169
+ def self.build_from_hash(attributes)
170
+ return nil unless attributes.is_a?(Hash)
171
+ attributes = attributes.transform_keys(&:to_sym)
172
+ transformed_hash = {}
173
+ openapi_types.each_pair do |key, type|
174
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
175
+ transformed_hash["#{key}"] = nil
176
+ elsif type =~ /\AArray<(.*)>/i
177
+ # check to ensure the input is an array given that the attribute
178
+ # is documented as an array but the input is not
179
+ if attributes[attribute_map[key]].is_a?(Array)
180
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
181
+ end
182
+ elsif !attributes[attribute_map[key]].nil?
183
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
184
+ end
185
+ end
186
+ new(transformed_hash)
187
+ end
188
+
189
+ # Deserializes the data based on type
190
+ # @param string type Data type
191
+ # @param string value Value to be deserialized
192
+ # @return [Object] Deserialized data
193
+ def self._deserialize(type, value)
194
+ case type.to_sym
195
+ when :Time
196
+ Time.parse(value)
197
+ when :Date
198
+ Date.parse(value)
199
+ when :String
200
+ value.to_s
201
+ when :Integer
202
+ value.to_i
203
+ when :Float
204
+ value.to_f
205
+ when :Boolean
206
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
207
+ true
208
+ else
209
+ false
210
+ end
211
+ when :Object
212
+ # generic object (usually a Hash), return directly
213
+ value
214
+ when /\AArray<(?<inner_type>.+)>\z/
215
+ inner_type = Regexp.last_match[:inner_type]
216
+ value.map { |v| _deserialize(inner_type, v) }
217
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
218
+ k_type = Regexp.last_match[:k_type]
219
+ v_type = Regexp.last_match[:v_type]
220
+ {}.tap do |hash|
221
+ value.each do |k, v|
222
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
223
+ end
224
+ end
225
+ else # model
226
+ # models (e.g. Pet) or oneOf
227
+ klass = OpenapiClient.const_get(type)
228
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
229
+ end
230
+ end
231
+
232
+ # Returns the string representation of the object
233
+ # @return [String] String presentation of the object
234
+ def to_s
235
+ to_hash.to_s
236
+ end
237
+
238
+ # to_body is an alias to to_hash (backward compatibility)
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_body
241
+ to_hash
242
+ end
243
+
244
+ # Returns the object in the form of hash
245
+ # @return [Hash] Returns the object in the form of hash
246
+ def to_hash
247
+ hash = {}
248
+ self.class.attribute_map.each_pair do |attr, param|
249
+ value = self.send(attr)
250
+ if value.nil?
251
+ is_nullable = self.class.openapi_nullable.include?(attr)
252
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
253
+ end
254
+
255
+ hash[param] = _to_hash(value)
256
+ end
257
+ hash
258
+ end
259
+
260
+ # Outputs non-array value in the form of hash
261
+ # For object, use to_hash. Otherwise, just return the value
262
+ # @param [Object] value Any valid value
263
+ # @return [Hash] Returns the value in the form of hash
264
+ def _to_hash(value)
265
+ if value.is_a?(Array)
266
+ value.compact.map { |v| _to_hash(v) }
267
+ elsif value.is_a?(Hash)
268
+ {}.tap do |hash|
269
+ value.each { |k, v| hash[k] = _to_hash(v) }
270
+ end
271
+ elsif value.respond_to? :to_hash
272
+ value.to_hash
273
+ else
274
+ value
275
+ end
276
+ end
277
+
278
+ end
279
+
280
+ end