activitysmith 0.1.1

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.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +116 -0
  4. data/generated/activitysmith_openapi/api/live_activities_api.rb +226 -0
  5. data/generated/activitysmith_openapi/api/push_notifications_api.rb +90 -0
  6. data/generated/activitysmith_openapi/api_client.rb +394 -0
  7. data/generated/activitysmith_openapi/api_error.rb +58 -0
  8. data/generated/activitysmith_openapi/configuration.rb +309 -0
  9. data/generated/activitysmith_openapi/models/content_state_end.rb +393 -0
  10. data/generated/activitysmith_openapi/models/content_state_start.rb +397 -0
  11. data/generated/activitysmith_openapi/models/content_state_update.rb +362 -0
  12. data/generated/activitysmith_openapi/models/live_activity_end_request.rb +237 -0
  13. data/generated/activitysmith_openapi/models/live_activity_end_response.rb +271 -0
  14. data/generated/activitysmith_openapi/models/live_activity_limit_error.rb +270 -0
  15. data/generated/activitysmith_openapi/models/live_activity_start_request.rb +221 -0
  16. data/generated/activitysmith_openapi/models/live_activity_start_response.rb +271 -0
  17. data/generated/activitysmith_openapi/models/live_activity_update_request.rb +237 -0
  18. data/generated/activitysmith_openapi/models/live_activity_update_response.rb +271 -0
  19. data/generated/activitysmith_openapi/models/push_notification_request.rb +239 -0
  20. data/generated/activitysmith_openapi/models/push_notification_response.rb +255 -0
  21. data/generated/activitysmith_openapi/models/rate_limit_error.rb +237 -0
  22. data/generated/activitysmith_openapi/models/send_push_notification429_response.rb +105 -0
  23. data/generated/activitysmith_openapi/version.rb +15 -0
  24. data/generated/activitysmith_openapi.rb +55 -0
  25. data/lib/activitysmith/client.rb +47 -0
  26. data/lib/activitysmith/live_activities.rb +44 -0
  27. data/lib/activitysmith/notifications.rb +28 -0
  28. data/lib/activitysmith/version.rb +5 -0
  29. data/lib/activitysmith.rb +6 -0
  30. metadata +129 -0
@@ -0,0 +1,397 @@
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
+ # Start payload requires title, number_of_steps, current_step, and type.
18
+ class ContentStateStart
19
+ attr_accessor :title
20
+
21
+ attr_accessor :subtitle
22
+
23
+ attr_accessor :number_of_steps
24
+
25
+ attr_accessor :current_step
26
+
27
+ attr_accessor :type
28
+
29
+ # Optional. Accent color for the Live Activity. Defaults to blue.
30
+ attr_accessor :color
31
+
32
+ # Optional. Overrides color for the current step.
33
+ attr_accessor :step_color
34
+
35
+ class EnumAttributeValidator
36
+ attr_reader :datatype
37
+ attr_reader :allowable_values
38
+
39
+ def initialize(datatype, allowable_values)
40
+ @allowable_values = allowable_values.map do |value|
41
+ case datatype.to_s
42
+ when /Integer/i
43
+ value.to_i
44
+ when /Float/i
45
+ value.to_f
46
+ else
47
+ value
48
+ end
49
+ end
50
+ end
51
+
52
+ def valid?(value)
53
+ !value || allowable_values.include?(value)
54
+ end
55
+ end
56
+
57
+ # Attribute mapping from ruby-style variable name to JSON key.
58
+ def self.attribute_map
59
+ {
60
+ :'title' => :'title',
61
+ :'subtitle' => :'subtitle',
62
+ :'number_of_steps' => :'number_of_steps',
63
+ :'current_step' => :'current_step',
64
+ :'type' => :'type',
65
+ :'color' => :'color',
66
+ :'step_color' => :'step_color'
67
+ }
68
+ end
69
+
70
+ # Returns all the JSON keys this model knows about
71
+ def self.acceptable_attributes
72
+ attribute_map.values
73
+ end
74
+
75
+ # Attribute type mapping.
76
+ def self.openapi_types
77
+ {
78
+ :'title' => :'String',
79
+ :'subtitle' => :'String',
80
+ :'number_of_steps' => :'Integer',
81
+ :'current_step' => :'Integer',
82
+ :'type' => :'String',
83
+ :'color' => :'String',
84
+ :'step_color' => :'String'
85
+ }
86
+ end
87
+
88
+ # List of attributes with nullable: true
89
+ def self.openapi_nullable
90
+ Set.new([
91
+ ])
92
+ end
93
+
94
+ # Initializes the object
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ def initialize(attributes = {})
97
+ if (!attributes.is_a?(Hash))
98
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::ContentStateStart` initialize method"
99
+ end
100
+
101
+ # check to see if the attribute exists and convert string to symbol for hash key
102
+ attributes = attributes.each_with_object({}) { |(k, v), h|
103
+ if (!self.class.attribute_map.key?(k.to_sym))
104
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::ContentStateStart`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
105
+ end
106
+ h[k.to_sym] = v
107
+ }
108
+
109
+ if attributes.key?(:'title')
110
+ self.title = attributes[:'title']
111
+ else
112
+ self.title = nil
113
+ end
114
+
115
+ if attributes.key?(:'subtitle')
116
+ self.subtitle = attributes[:'subtitle']
117
+ end
118
+
119
+ if attributes.key?(:'number_of_steps')
120
+ self.number_of_steps = attributes[:'number_of_steps']
121
+ else
122
+ self.number_of_steps = nil
123
+ end
124
+
125
+ if attributes.key?(:'current_step')
126
+ self.current_step = attributes[:'current_step']
127
+ else
128
+ self.current_step = nil
129
+ end
130
+
131
+ if attributes.key?(:'type')
132
+ self.type = attributes[:'type']
133
+ else
134
+ self.type = nil
135
+ end
136
+
137
+ if attributes.key?(:'color')
138
+ self.color = attributes[:'color']
139
+ else
140
+ self.color = 'blue'
141
+ end
142
+
143
+ if attributes.key?(:'step_color')
144
+ self.step_color = attributes[:'step_color']
145
+ end
146
+ end
147
+
148
+ # Show invalid properties with the reasons. Usually used together with valid?
149
+ # @return Array for valid properties with the reasons
150
+ def list_invalid_properties
151
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
152
+ invalid_properties = Array.new
153
+ if @title.nil?
154
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
155
+ end
156
+
157
+ if @number_of_steps.nil?
158
+ invalid_properties.push('invalid value for "number_of_steps", number_of_steps cannot be nil.')
159
+ end
160
+
161
+ if @number_of_steps < 1
162
+ invalid_properties.push('invalid value for "number_of_steps", must be greater than or equal to 1.')
163
+ end
164
+
165
+ if @current_step.nil?
166
+ invalid_properties.push('invalid value for "current_step", current_step cannot be nil.')
167
+ end
168
+
169
+ if @current_step < 1
170
+ invalid_properties.push('invalid value for "current_step", must be greater than or equal to 1.')
171
+ end
172
+
173
+ if @type.nil?
174
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
175
+ end
176
+
177
+ invalid_properties
178
+ end
179
+
180
+ # Check to see if the all the properties in the model are valid
181
+ # @return true if the model is valid
182
+ def valid?
183
+ warn '[DEPRECATED] the `valid?` method is obsolete'
184
+ return false if @title.nil?
185
+ return false if @number_of_steps.nil?
186
+ return false if @number_of_steps < 1
187
+ return false if @current_step.nil?
188
+ return false if @current_step < 1
189
+ return false if @type.nil?
190
+ type_validator = EnumAttributeValidator.new('String', ["segmented_progress"])
191
+ return false unless type_validator.valid?(@type)
192
+ color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
193
+ return false unless color_validator.valid?(@color)
194
+ step_color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
195
+ return false unless step_color_validator.valid?(@step_color)
196
+ true
197
+ end
198
+
199
+ # Custom attribute writer method with validation
200
+ # @param [Object] number_of_steps Value to be assigned
201
+ def number_of_steps=(number_of_steps)
202
+ if number_of_steps.nil?
203
+ fail ArgumentError, 'number_of_steps cannot be nil'
204
+ end
205
+
206
+ if number_of_steps < 1
207
+ fail ArgumentError, 'invalid value for "number_of_steps", must be greater than or equal to 1.'
208
+ end
209
+
210
+ @number_of_steps = number_of_steps
211
+ end
212
+
213
+ # Custom attribute writer method with validation
214
+ # @param [Object] current_step Value to be assigned
215
+ def current_step=(current_step)
216
+ if current_step.nil?
217
+ fail ArgumentError, 'current_step cannot be nil'
218
+ end
219
+
220
+ if current_step < 1
221
+ fail ArgumentError, 'invalid value for "current_step", must be greater than or equal to 1.'
222
+ end
223
+
224
+ @current_step = current_step
225
+ end
226
+
227
+ # Custom attribute writer method checking allowed values (enum).
228
+ # @param [Object] type Object to be assigned
229
+ def type=(type)
230
+ validator = EnumAttributeValidator.new('String', ["segmented_progress"])
231
+ unless validator.valid?(type)
232
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
233
+ end
234
+ @type = type
235
+ end
236
+
237
+ # Custom attribute writer method checking allowed values (enum).
238
+ # @param [Object] color Object to be assigned
239
+ def color=(color)
240
+ validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
241
+ unless validator.valid?(color)
242
+ fail ArgumentError, "invalid value for \"color\", must be one of #{validator.allowable_values}."
243
+ end
244
+ @color = color
245
+ end
246
+
247
+ # Custom attribute writer method checking allowed values (enum).
248
+ # @param [Object] step_color Object to be assigned
249
+ def step_color=(step_color)
250
+ validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
251
+ unless validator.valid?(step_color)
252
+ fail ArgumentError, "invalid value for \"step_color\", must be one of #{validator.allowable_values}."
253
+ end
254
+ @step_color = step_color
255
+ end
256
+
257
+ # Checks equality by comparing each attribute.
258
+ # @param [Object] Object to be compared
259
+ def ==(o)
260
+ return true if self.equal?(o)
261
+ self.class == o.class &&
262
+ title == o.title &&
263
+ subtitle == o.subtitle &&
264
+ number_of_steps == o.number_of_steps &&
265
+ current_step == o.current_step &&
266
+ type == o.type &&
267
+ color == o.color &&
268
+ step_color == o.step_color
269
+ end
270
+
271
+ # @see the `==` method
272
+ # @param [Object] Object to be compared
273
+ def eql?(o)
274
+ self == o
275
+ end
276
+
277
+ # Calculates hash code according to all attributes.
278
+ # @return [Integer] Hash code
279
+ def hash
280
+ [title, subtitle, number_of_steps, current_step, type, color, step_color].hash
281
+ end
282
+
283
+ # Builds the object from hash
284
+ # @param [Hash] attributes Model attributes in the form of hash
285
+ # @return [Object] Returns the model itself
286
+ def self.build_from_hash(attributes)
287
+ return nil unless attributes.is_a?(Hash)
288
+ attributes = attributes.transform_keys(&:to_sym)
289
+ transformed_hash = {}
290
+ openapi_types.each_pair do |key, type|
291
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
292
+ transformed_hash["#{key}"] = nil
293
+ elsif type =~ /\AArray<(.*)>/i
294
+ # check to ensure the input is an array given that the attribute
295
+ # is documented as an array but the input is not
296
+ if attributes[attribute_map[key]].is_a?(Array)
297
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
298
+ end
299
+ elsif !attributes[attribute_map[key]].nil?
300
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
301
+ end
302
+ end
303
+ new(transformed_hash)
304
+ end
305
+
306
+ # Deserializes the data based on type
307
+ # @param string type Data type
308
+ # @param string value Value to be deserialized
309
+ # @return [Object] Deserialized data
310
+ def self._deserialize(type, value)
311
+ case type.to_sym
312
+ when :Time
313
+ Time.parse(value)
314
+ when :Date
315
+ Date.parse(value)
316
+ when :String
317
+ value.to_s
318
+ when :Integer
319
+ value.to_i
320
+ when :Float
321
+ value.to_f
322
+ when :Boolean
323
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
324
+ true
325
+ else
326
+ false
327
+ end
328
+ when :Object
329
+ # generic object (usually a Hash), return directly
330
+ value
331
+ when /\AArray<(?<inner_type>.+)>\z/
332
+ inner_type = Regexp.last_match[:inner_type]
333
+ value.map { |v| _deserialize(inner_type, v) }
334
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
335
+ k_type = Regexp.last_match[:k_type]
336
+ v_type = Regexp.last_match[:v_type]
337
+ {}.tap do |hash|
338
+ value.each do |k, v|
339
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
340
+ end
341
+ end
342
+ else # model
343
+ # models (e.g. Pet) or oneOf
344
+ klass = OpenapiClient.const_get(type)
345
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
346
+ end
347
+ end
348
+
349
+ # Returns the string representation of the object
350
+ # @return [String] String presentation of the object
351
+ def to_s
352
+ to_hash.to_s
353
+ end
354
+
355
+ # to_body is an alias to to_hash (backward compatibility)
356
+ # @return [Hash] Returns the object in the form of hash
357
+ def to_body
358
+ to_hash
359
+ end
360
+
361
+ # Returns the object in the form of hash
362
+ # @return [Hash] Returns the object in the form of hash
363
+ def to_hash
364
+ hash = {}
365
+ self.class.attribute_map.each_pair do |attr, param|
366
+ value = self.send(attr)
367
+ if value.nil?
368
+ is_nullable = self.class.openapi_nullable.include?(attr)
369
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
370
+ end
371
+
372
+ hash[param] = _to_hash(value)
373
+ end
374
+ hash
375
+ end
376
+
377
+ # Outputs non-array value in the form of hash
378
+ # For object, use to_hash. Otherwise, just return the value
379
+ # @param [Object] value Any valid value
380
+ # @return [Hash] Returns the value in the form of hash
381
+ def _to_hash(value)
382
+ if value.is_a?(Array)
383
+ value.compact.map { |v| _to_hash(v) }
384
+ elsif value.is_a?(Hash)
385
+ {}.tap do |hash|
386
+ value.each { |k, v| hash[k] = _to_hash(v) }
387
+ end
388
+ elsif value.respond_to? :to_hash
389
+ value.to_hash
390
+ else
391
+ value
392
+ end
393
+ end
394
+
395
+ end
396
+
397
+ end