activitysmith 1.3.1 → 1.6.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.
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module OpenapiClient
17
- # Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates.
17
+ # Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. For alert include message. Optional icon is supported by all Live Activity types. Optional badge is supported by alert, progress, and segmented_progress. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates.
18
18
  class ContentStateUpdate
19
19
  attr_accessor :title
20
20
 
@@ -23,7 +23,7 @@ module OpenapiClient
23
23
  # Total number of steps. Use for type=segmented_progress. Optional on update, and safe to change if the workflow gains or loses steps.
24
24
  attr_accessor :number_of_steps
25
25
 
26
- # Current step. Use for type=segmented_progress.
26
+ # Current completed step count. Use for type=segmented_progress. Set 0 when no segment is complete yet. Must be less than or equal to number_of_steps when number_of_steps is provided.
27
27
  attr_accessor :current_step
28
28
 
29
29
  # Progress percentage (0–100). Use for type=progress. Takes precedence over value/upper_limit if both are provided.
@@ -38,10 +38,19 @@ module OpenapiClient
38
38
  # Use for type=metrics or type=stats.
39
39
  attr_accessor :metrics
40
40
 
41
+ # Alert message. Use for type=alert.
42
+ attr_accessor :message
43
+
44
+ # Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, and stats.
45
+ attr_accessor :icon
46
+
47
+ # Optional badge. Supported by alert, progress, and segmented_progress.
48
+ attr_accessor :badge
49
+
41
50
  # Optional. When omitted, the API uses the existing Live Activity type.
42
51
  attr_accessor :type
43
52
 
44
- # Optional. Accent color for the Live Activity. Defaults to blue.
53
+ # Optional. Accent color for progress, segmented_progress, and metrics Live Activities. For Alert Live Activities, this tints the action button when action is included.
45
54
  attr_accessor :color
46
55
 
47
56
  # Optional. Overrides color for the current step. Only applies to type=segmented_progress.
@@ -83,6 +92,9 @@ module OpenapiClient
83
92
  :'value' => :'value',
84
93
  :'upper_limit' => :'upper_limit',
85
94
  :'metrics' => :'metrics',
95
+ :'message' => :'message',
96
+ :'icon' => :'icon',
97
+ :'badge' => :'badge',
86
98
  :'type' => :'type',
87
99
  :'color' => :'color',
88
100
  :'step_color' => :'step_color',
@@ -106,6 +118,9 @@ module OpenapiClient
106
118
  :'value' => :'Float',
107
119
  :'upper_limit' => :'Float',
108
120
  :'metrics' => :'Array<ActivityMetric>',
121
+ :'message' => :'String',
122
+ :'icon' => :'LiveActivityAlertIcon',
123
+ :'badge' => :'LiveActivityAlertBadge',
109
124
  :'type' => :'String',
110
125
  :'color' => :'String',
111
126
  :'step_color' => :'String',
@@ -170,14 +185,24 @@ module OpenapiClient
170
185
  end
171
186
  end
172
187
 
188
+ if attributes.key?(:'message')
189
+ self.message = attributes[:'message']
190
+ end
191
+
192
+ if attributes.key?(:'icon')
193
+ self.icon = attributes[:'icon']
194
+ end
195
+
196
+ if attributes.key?(:'badge')
197
+ self.badge = attributes[:'badge']
198
+ end
199
+
173
200
  if attributes.key?(:'type')
174
201
  self.type = attributes[:'type']
175
202
  end
176
203
 
177
204
  if attributes.key?(:'color')
178
205
  self.color = attributes[:'color']
179
- else
180
- self.color = 'blue'
181
206
  end
182
207
 
183
208
  if attributes.key?(:'step_color')
@@ -204,8 +229,8 @@ module OpenapiClient
204
229
  invalid_properties.push('invalid value for "number_of_steps", must be greater than or equal to 1.')
205
230
  end
206
231
 
207
- if !@current_step.nil? && @current_step < 1
208
- invalid_properties.push('invalid value for "current_step", must be greater than or equal to 1.')
232
+ if !@current_step.nil? && @current_step < 0
233
+ invalid_properties.push('invalid value for "current_step", must be greater than or equal to 0.')
209
234
  end
210
235
 
211
236
  if !@percentage.nil? && @percentage > 100
@@ -224,6 +249,10 @@ module OpenapiClient
224
249
  invalid_properties.push('invalid value for "metrics", number of items must be greater than or equal to 1.')
225
250
  end
226
251
 
252
+ if !@message.nil? && @message.to_s.length < 1
253
+ invalid_properties.push('invalid value for "message", the character length must be great than or equal to 1.')
254
+ end
255
+
227
256
  invalid_properties
228
257
  end
229
258
 
@@ -233,16 +262,17 @@ module OpenapiClient
233
262
  warn '[DEPRECATED] the `valid?` method is obsolete'
234
263
  return false if @title.nil?
235
264
  return false if !@number_of_steps.nil? && @number_of_steps < 1
236
- return false if !@current_step.nil? && @current_step < 1
265
+ return false if !@current_step.nil? && @current_step < 0
237
266
  return false if !@percentage.nil? && @percentage > 100
238
267
  return false if !@percentage.nil? && @percentage < 0
239
268
  return false if !@metrics.nil? && @metrics.length > 8
240
269
  return false if !@metrics.nil? && @metrics.length < 1
241
- type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
270
+ return false if !@message.nil? && @message.to_s.length < 1
271
+ type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert"])
242
272
  return false unless type_validator.valid?(@type)
243
- color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
273
+ color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "gray"])
244
274
  return false unless color_validator.valid?(@color)
245
- step_color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
275
+ step_color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "gray"])
246
276
  return false unless step_color_validator.valid?(@step_color)
247
277
  true
248
278
  end
@@ -268,8 +298,8 @@ module OpenapiClient
268
298
  fail ArgumentError, 'current_step cannot be nil'
269
299
  end
270
300
 
271
- if current_step < 1
272
- fail ArgumentError, 'invalid value for "current_step", must be greater than or equal to 1.'
301
+ if current_step < 0
302
+ fail ArgumentError, 'invalid value for "current_step", must be greater than or equal to 0.'
273
303
  end
274
304
 
275
305
  @current_step = current_step
@@ -311,10 +341,24 @@ module OpenapiClient
311
341
  @metrics = metrics
312
342
  end
313
343
 
344
+ # Custom attribute writer method with validation
345
+ # @param [Object] message Value to be assigned
346
+ def message=(message)
347
+ if message.nil?
348
+ fail ArgumentError, 'message cannot be nil'
349
+ end
350
+
351
+ if message.to_s.length < 1
352
+ fail ArgumentError, 'invalid value for "message", the character length must be great than or equal to 1.'
353
+ end
354
+
355
+ @message = message
356
+ end
357
+
314
358
  # Custom attribute writer method checking allowed values (enum).
315
359
  # @param [Object] type Object to be assigned
316
360
  def type=(type)
317
- validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
361
+ validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert"])
318
362
  unless validator.valid?(type)
319
363
  fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
320
364
  end
@@ -324,7 +368,7 @@ module OpenapiClient
324
368
  # Custom attribute writer method checking allowed values (enum).
325
369
  # @param [Object] color Object to be assigned
326
370
  def color=(color)
327
- validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
371
+ validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "gray"])
328
372
  unless validator.valid?(color)
329
373
  fail ArgumentError, "invalid value for \"color\", must be one of #{validator.allowable_values}."
330
374
  end
@@ -334,7 +378,7 @@ module OpenapiClient
334
378
  # Custom attribute writer method checking allowed values (enum).
335
379
  # @param [Object] step_color Object to be assigned
336
380
  def step_color=(step_color)
337
- validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
381
+ validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "gray"])
338
382
  unless validator.valid?(step_color)
339
383
  fail ArgumentError, "invalid value for \"step_color\", must be one of #{validator.allowable_values}."
340
384
  end
@@ -354,6 +398,9 @@ module OpenapiClient
354
398
  value == o.value &&
355
399
  upper_limit == o.upper_limit &&
356
400
  metrics == o.metrics &&
401
+ message == o.message &&
402
+ icon == o.icon &&
403
+ badge == o.badge &&
357
404
  type == o.type &&
358
405
  color == o.color &&
359
406
  step_color == o.step_color &&
@@ -369,7 +416,7 @@ module OpenapiClient
369
416
  # Calculates hash code according to all attributes.
370
417
  # @return [Integer] Hash code
371
418
  def hash
372
- [title, subtitle, number_of_steps, current_step, percentage, value, upper_limit, metrics, type, color, step_color, step_colors].hash
419
+ [title, subtitle, number_of_steps, current_step, percentage, value, upper_limit, metrics, message, icon, badge, type, color, step_color, step_colors].hash
373
420
  end
374
421
 
375
422
  # Builds the object from hash
@@ -21,7 +21,7 @@ module OpenapiClient
21
21
 
22
22
  attr_accessor :type
23
23
 
24
- # HTTPS URL. For open_url it is opened in browser. For webhook it is called by ActivitySmith backend.
24
+ # Action URL. For open_url, use an HTTPS or shortcuts:// URL. For webhook, use an HTTPS URL called by the ActivitySmith backend.
25
25
  attr_accessor :url
26
26
 
27
27
  # Webhook HTTP method. Used only when type=webhook.
@@ -30,28 +30,6 @@ module OpenapiClient
30
30
  # Optional webhook payload body. Used only when type=webhook.
31
31
  attr_accessor :body
32
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
33
  # Attribute mapping from ruby-style variable name to JSON key.
56
34
  def self.attribute_map
57
35
  {
@@ -117,6 +95,7 @@ module OpenapiClient
117
95
  else
118
96
  self.url = nil
119
97
  end
98
+ validate_action_url!
120
99
 
121
100
  if attributes.key?(:'method')
122
101
  self.method = attributes[:'method']
@@ -131,6 +110,16 @@ module OpenapiClient
131
110
  end
132
111
  end
133
112
 
113
+ def validate_action_url!
114
+ return if @url.nil? || @type.nil?
115
+ if @type == LiveActivityActionType::OPEN_URL && @url !~ /\A(https|shortcuts):\/\//
116
+ fail ArgumentError, 'invalid value for "url", open_url must use https or shortcuts.'
117
+ end
118
+ if @type == LiveActivityActionType::WEBHOOK && @url !~ /\Ahttps:\/\//
119
+ fail ArgumentError, 'invalid value for "url", webhook must use https.'
120
+ end
121
+ end
122
+
134
123
  # Show invalid properties with the reasons. Usually used together with valid?
135
124
  # @return Array for valid properties with the reasons
136
125
  def list_invalid_properties
@@ -147,10 +136,11 @@ module OpenapiClient
147
136
  if @url.nil?
148
137
  invalid_properties.push('invalid value for "url", url cannot be nil.')
149
138
  end
150
-
151
- pattern = Regexp.new(/^https:\/\//)
152
- if @url !~ pattern
153
- invalid_properties.push("invalid value for \"url\", must conform to the pattern #{pattern}.")
139
+ if !@url.nil? && @type == LiveActivityActionType::OPEN_URL && @url !~ /\A(https|shortcuts):\/\//
140
+ invalid_properties.push('invalid value for "url", open_url must use https or shortcuts.')
141
+ end
142
+ if !@url.nil? && @type == LiveActivityActionType::WEBHOOK && @url !~ /\Ahttps:\/\//
143
+ invalid_properties.push('invalid value for "url", webhook must use https.')
154
144
  end
155
145
 
156
146
  invalid_properties
@@ -163,25 +153,11 @@ module OpenapiClient
163
153
  return false if @title.nil?
164
154
  return false if @type.nil?
165
155
  return false if @url.nil?
166
- return false if @url !~ Regexp.new(/^https:\/\//)
156
+ return false if !@url.nil? && @type == LiveActivityActionType::OPEN_URL && @url !~ /\A(https|shortcuts):\/\//
157
+ return false if !@url.nil? && @type == LiveActivityActionType::WEBHOOK && @url !~ /\Ahttps:\/\//
167
158
  true
168
159
  end
169
160
 
170
- # Custom attribute writer method with validation
171
- # @param [Object] url Value to be assigned
172
- def url=(url)
173
- if url.nil?
174
- fail ArgumentError, 'url cannot be nil'
175
- end
176
-
177
- pattern = Regexp.new(/^https:\/\//)
178
- if url !~ pattern
179
- fail ArgumentError, "invalid value for \"url\", must conform to the pattern #{pattern}."
180
- end
181
-
182
- @url = url
183
- end
184
-
185
161
  # Checks equality by comparing each attribute.
186
162
  # @param [Object] Object to be compared
187
163
  def ==(o)
@@ -0,0 +1,273 @@
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
+ # Optional badge for Live Activities.
18
+ class LiveActivityAlertBadge
19
+ attr_accessor :title
20
+
21
+ # Optional badge color.
22
+ attr_accessor :color
23
+
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'title' => :'title',
50
+ :'color' => :'color'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'title' => :'String',
63
+ :'color' => :'LiveActivityColor'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::LiveActivityAlertBadge` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::LiveActivityAlertBadge`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'title')
89
+ self.title = attributes[:'title']
90
+ else
91
+ self.title = nil
92
+ end
93
+
94
+ if attributes.key?(:'color')
95
+ self.color = attributes[:'color']
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
103
+ invalid_properties = Array.new
104
+ if @title.nil?
105
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
106
+ end
107
+
108
+ if @title.to_s.length < 1
109
+ invalid_properties.push('invalid value for "title", the character length must be great than or equal to 1.')
110
+ end
111
+
112
+ invalid_properties
113
+ end
114
+
115
+ # Check to see if the all the properties in the model are valid
116
+ # @return true if the model is valid
117
+ def valid?
118
+ warn '[DEPRECATED] the `valid?` method is obsolete'
119
+ return false if @title.nil?
120
+ return false if @title.to_s.length < 1
121
+ true
122
+ end
123
+
124
+ # Custom attribute writer method with validation
125
+ # @param [Object] title Value to be assigned
126
+ def title=(title)
127
+ if title.nil?
128
+ fail ArgumentError, 'title cannot be nil'
129
+ end
130
+
131
+ if title.to_s.length < 1
132
+ fail ArgumentError, 'invalid value for "title", the character length must be great than or equal to 1.'
133
+ end
134
+
135
+ @title = title
136
+ end
137
+
138
+ # Checks equality by comparing each attribute.
139
+ # @param [Object] Object to be compared
140
+ def ==(o)
141
+ return true if self.equal?(o)
142
+ self.class == o.class &&
143
+ title == o.title &&
144
+ color == o.color
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(o)
150
+ self == o
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [title, color].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ return nil unless attributes.is_a?(Hash)
164
+ attributes = attributes.transform_keys(&:to_sym)
165
+ transformed_hash = {}
166
+ openapi_types.each_pair do |key, type|
167
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
168
+ transformed_hash["#{key}"] = nil
169
+ elsif type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[attribute_map[key]].is_a?(Array)
173
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
174
+ end
175
+ elsif !attributes[attribute_map[key]].nil?
176
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
177
+ end
178
+ end
179
+ new(transformed_hash)
180
+ end
181
+
182
+ # Deserializes the data based on type
183
+ # @param string type Data type
184
+ # @param string value Value to be deserialized
185
+ # @return [Object] Deserialized data
186
+ def self._deserialize(type, value)
187
+ case type.to_sym
188
+ when :Time
189
+ Time.parse(value)
190
+ when :Date
191
+ Date.parse(value)
192
+ when :String
193
+ value.to_s
194
+ when :Integer
195
+ value.to_i
196
+ when :Float
197
+ value.to_f
198
+ when :Boolean
199
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
+ true
201
+ else
202
+ false
203
+ end
204
+ when :Object
205
+ # generic object (usually a Hash), return directly
206
+ value
207
+ when /\AArray<(?<inner_type>.+)>\z/
208
+ inner_type = Regexp.last_match[:inner_type]
209
+ value.map { |v| _deserialize(inner_type, v) }
210
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
+ k_type = Regexp.last_match[:k_type]
212
+ v_type = Regexp.last_match[:v_type]
213
+ {}.tap do |hash|
214
+ value.each do |k, v|
215
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
216
+ end
217
+ end
218
+ else # model
219
+ # models (e.g. Pet) or oneOf
220
+ klass = OpenapiClient.const_get(type)
221
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
222
+ end
223
+ end
224
+
225
+ # Returns the string representation of the object
226
+ # @return [String] String presentation of the object
227
+ def to_s
228
+ to_hash.to_s
229
+ end
230
+
231
+ # to_body is an alias to to_hash (backward compatibility)
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_body
234
+ to_hash
235
+ end
236
+
237
+ # Returns the object in the form of hash
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_hash
240
+ hash = {}
241
+ self.class.attribute_map.each_pair do |attr, param|
242
+ value = self.send(attr)
243
+ if value.nil?
244
+ is_nullable = self.class.openapi_nullable.include?(attr)
245
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
+ end
247
+
248
+ hash[param] = _to_hash(value)
249
+ end
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+
271
+ end
272
+
273
+ end