activitysmith 0.1.7 → 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.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +337 -77
  3. data/generated/activitysmith_openapi/api/live_activities_api.rb +168 -6
  4. data/generated/activitysmith_openapi/models/activity_metric.rb +293 -0
  5. data/generated/activitysmith_openapi/models/content_state_end.rb +47 -4
  6. data/generated/activitysmith_openapi/models/content_state_start.rb +50 -7
  7. data/generated/activitysmith_openapi/models/content_state_update.rb +50 -7
  8. data/generated/activitysmith_openapi/models/live_activity_action.rb +323 -0
  9. data/generated/activitysmith_openapi/models/live_activity_action_type.rb +40 -0
  10. data/generated/activitysmith_openapi/models/live_activity_end_request.rb +13 -4
  11. data/generated/activitysmith_openapi/models/live_activity_start_request.rb +10 -1
  12. data/generated/activitysmith_openapi/models/live_activity_stream_delete_request.rb +233 -0
  13. data/generated/activitysmith_openapi/models/live_activity_stream_delete_response.rb +332 -0
  14. data/generated/activitysmith_openapi/models/live_activity_stream_put_response.rb +361 -0
  15. data/generated/activitysmith_openapi/models/live_activity_stream_request.rb +280 -0
  16. data/generated/activitysmith_openapi/models/live_activity_update_request.rb +13 -4
  17. data/generated/activitysmith_openapi/models/live_activity_webhook_method.rb +40 -0
  18. data/generated/activitysmith_openapi/models/not_found_error.rb +237 -0
  19. data/generated/activitysmith_openapi/models/stream_content_state.rb +538 -0
  20. data/generated/activitysmith_openapi/version.rb +1 -1
  21. data/generated/activitysmith_openapi.rb +10 -0
  22. data/lib/activitysmith/live_activities.rb +19 -0
  23. data/lib/activitysmith/version.rb +1 -1
  24. metadata +12 -2
@@ -20,7 +20,7 @@ module OpenapiClient
20
20
  @api_client = api_client
21
21
  end
22
22
  # End a Live Activity
23
- # Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
23
+ # Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
24
24
  # @param live_activity_end_request [LiveActivityEndRequest]
25
25
  # @param [Hash] opts the optional parameters
26
26
  # @return [LiveActivityEndResponse]
@@ -30,7 +30,7 @@ module OpenapiClient
30
30
  end
31
31
 
32
32
  # End a Live Activity
33
- # Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
33
+ # Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
34
34
  # @param live_activity_end_request [LiveActivityEndRequest]
35
35
  # @param [Hash] opts the optional parameters
36
36
  # @return [Array<(LiveActivityEndResponse, Integer, Hash)>] LiveActivityEndResponse data, response status code and response headers
@@ -87,8 +87,170 @@ module OpenapiClient
87
87
  return data, status_code, headers
88
88
  end
89
89
 
90
+ # End a stream
91
+ # Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
92
+ # @param stream_key [String] Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens.
93
+ # @param [Hash] opts the optional parameters
94
+ # @option opts [LiveActivityStreamDeleteRequest] :live_activity_stream_delete_request
95
+ # @return [LiveActivityStreamDeleteResponse]
96
+ def end_live_activity_stream(stream_key, opts = {})
97
+ data, _status_code, _headers = end_live_activity_stream_with_http_info(stream_key, opts)
98
+ data
99
+ end
100
+
101
+ # End a stream
102
+ # Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
103
+ # @param stream_key [String] Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens.
104
+ # @param [Hash] opts the optional parameters
105
+ # @option opts [LiveActivityStreamDeleteRequest] :live_activity_stream_delete_request
106
+ # @return [Array<(LiveActivityStreamDeleteResponse, Integer, Hash)>] LiveActivityStreamDeleteResponse data, response status code and response headers
107
+ def end_live_activity_stream_with_http_info(stream_key, opts = {})
108
+ if @api_client.config.debugging
109
+ @api_client.config.logger.debug 'Calling API: LiveActivitiesApi.end_live_activity_stream ...'
110
+ end
111
+ # verify the required parameter 'stream_key' is set
112
+ if @api_client.config.client_side_validation && stream_key.nil?
113
+ fail ArgumentError, "Missing the required parameter 'stream_key' when calling LiveActivitiesApi.end_live_activity_stream"
114
+ end
115
+ if @api_client.config.client_side_validation && stream_key.to_s.length > 255
116
+ fail ArgumentError, 'invalid value for "stream_key" when calling LiveActivitiesApi.end_live_activity_stream, the character length must be smaller than or equal to 255.'
117
+ end
118
+
119
+ pattern = Regexp.new(/^[A-Za-z0-9_-]+$/)
120
+ if @api_client.config.client_side_validation && stream_key !~ pattern
121
+ fail ArgumentError, "invalid value for 'stream_key' when calling LiveActivitiesApi.end_live_activity_stream, must conform to the pattern #{pattern}."
122
+ end
123
+
124
+ # resource path
125
+ local_var_path = '/live-activity/stream/{stream_key}'.sub('{' + 'stream_key' + '}', CGI.escape(stream_key.to_s))
126
+
127
+ # query parameters
128
+ query_params = opts[:query_params] || {}
129
+
130
+ # header parameters
131
+ header_params = opts[:header_params] || {}
132
+ # HTTP header 'Accept' (if needed)
133
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
134
+ # HTTP header 'Content-Type'
135
+ content_type = @api_client.select_header_content_type(['application/json'])
136
+ if !content_type.nil?
137
+ header_params['Content-Type'] = content_type
138
+ end
139
+
140
+ # form parameters
141
+ form_params = opts[:form_params] || {}
142
+
143
+ # http body (model)
144
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'live_activity_stream_delete_request'])
145
+
146
+ # return_type
147
+ return_type = opts[:debug_return_type] || 'LiveActivityStreamDeleteResponse'
148
+
149
+ # auth_names
150
+ auth_names = opts[:debug_auth_names] || ['apiKeyAuth']
151
+
152
+ new_options = opts.merge(
153
+ :operation => :"LiveActivitiesApi.end_live_activity_stream",
154
+ :header_params => header_params,
155
+ :query_params => query_params,
156
+ :form_params => form_params,
157
+ :body => post_body,
158
+ :auth_names => auth_names,
159
+ :return_type => return_type
160
+ )
161
+
162
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
163
+ if @api_client.config.debugging
164
+ @api_client.config.logger.debug "API called: LiveActivitiesApi#end_live_activity_stream\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
165
+ end
166
+ return data, status_code, headers
167
+ end
168
+
169
+ # Send a stream update
170
+ # Use this endpoint when you want the easiest, stateless way to trigger Live Activities. You do not need to store activity_id or manage the Live Activity lifecycle yourself. Send the latest state for a stable stream_key and ActivitySmith will handle the rest for you: if there is no Live Activity yet, it starts one; if there is already one for this stream, it updates it. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
171
+ # @param stream_key [String] Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens.
172
+ # @param live_activity_stream_request [LiveActivityStreamRequest]
173
+ # @param [Hash] opts the optional parameters
174
+ # @return [LiveActivityStreamPutResponse]
175
+ def reconcile_live_activity_stream(stream_key, live_activity_stream_request, opts = {})
176
+ data, _status_code, _headers = reconcile_live_activity_stream_with_http_info(stream_key, live_activity_stream_request, opts)
177
+ data
178
+ end
179
+
180
+ # Send a stream update
181
+ # Use this endpoint when you want the easiest, stateless way to trigger Live Activities. You do not need to store activity_id or manage the Live Activity lifecycle yourself. Send the latest state for a stable stream_key and ActivitySmith will handle the rest for you: if there is no Live Activity yet, it starts one; if there is already one for this stream, it updates it. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
182
+ # @param stream_key [String] Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens.
183
+ # @param live_activity_stream_request [LiveActivityStreamRequest]
184
+ # @param [Hash] opts the optional parameters
185
+ # @return [Array<(LiveActivityStreamPutResponse, Integer, Hash)>] LiveActivityStreamPutResponse data, response status code and response headers
186
+ def reconcile_live_activity_stream_with_http_info(stream_key, live_activity_stream_request, opts = {})
187
+ if @api_client.config.debugging
188
+ @api_client.config.logger.debug 'Calling API: LiveActivitiesApi.reconcile_live_activity_stream ...'
189
+ end
190
+ # verify the required parameter 'stream_key' is set
191
+ if @api_client.config.client_side_validation && stream_key.nil?
192
+ fail ArgumentError, "Missing the required parameter 'stream_key' when calling LiveActivitiesApi.reconcile_live_activity_stream"
193
+ end
194
+ if @api_client.config.client_side_validation && stream_key.to_s.length > 255
195
+ fail ArgumentError, 'invalid value for "stream_key" when calling LiveActivitiesApi.reconcile_live_activity_stream, the character length must be smaller than or equal to 255.'
196
+ end
197
+
198
+ pattern = Regexp.new(/^[A-Za-z0-9_-]+$/)
199
+ if @api_client.config.client_side_validation && stream_key !~ pattern
200
+ fail ArgumentError, "invalid value for 'stream_key' when calling LiveActivitiesApi.reconcile_live_activity_stream, must conform to the pattern #{pattern}."
201
+ end
202
+
203
+ # verify the required parameter 'live_activity_stream_request' is set
204
+ if @api_client.config.client_side_validation && live_activity_stream_request.nil?
205
+ fail ArgumentError, "Missing the required parameter 'live_activity_stream_request' when calling LiveActivitiesApi.reconcile_live_activity_stream"
206
+ end
207
+ # resource path
208
+ local_var_path = '/live-activity/stream/{stream_key}'.sub('{' + 'stream_key' + '}', CGI.escape(stream_key.to_s))
209
+
210
+ # query parameters
211
+ query_params = opts[:query_params] || {}
212
+
213
+ # header parameters
214
+ header_params = opts[:header_params] || {}
215
+ # HTTP header 'Accept' (if needed)
216
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
217
+ # HTTP header 'Content-Type'
218
+ content_type = @api_client.select_header_content_type(['application/json'])
219
+ if !content_type.nil?
220
+ header_params['Content-Type'] = content_type
221
+ end
222
+
223
+ # form parameters
224
+ form_params = opts[:form_params] || {}
225
+
226
+ # http body (model)
227
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(live_activity_stream_request)
228
+
229
+ # return_type
230
+ return_type = opts[:debug_return_type] || 'LiveActivityStreamPutResponse'
231
+
232
+ # auth_names
233
+ auth_names = opts[:debug_auth_names] || ['apiKeyAuth']
234
+
235
+ new_options = opts.merge(
236
+ :operation => :"LiveActivitiesApi.reconcile_live_activity_stream",
237
+ :header_params => header_params,
238
+ :query_params => query_params,
239
+ :form_params => form_params,
240
+ :body => post_body,
241
+ :auth_names => auth_names,
242
+ :return_type => return_type
243
+ )
244
+
245
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
246
+ if @api_client.config.debugging
247
+ @api_client.config.logger.debug "API called: LiveActivitiesApi#reconcile_live_activity_stream\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
248
+ end
249
+ return data, status_code, headers
250
+ end
251
+
90
252
  # Start a Live Activity
91
- # Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
253
+ # Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
92
254
  # @param live_activity_start_request [LiveActivityStartRequest]
93
255
  # @param [Hash] opts the optional parameters
94
256
  # @return [LiveActivityStartResponse]
@@ -98,7 +260,7 @@ module OpenapiClient
98
260
  end
99
261
 
100
262
  # Start a Live Activity
101
- # Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
263
+ # Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
102
264
  # @param live_activity_start_request [LiveActivityStartRequest]
103
265
  # @param [Hash] opts the optional parameters
104
266
  # @return [Array<(LiveActivityStartResponse, Integer, Hash)>] LiveActivityStartResponse data, response status code and response headers
@@ -156,7 +318,7 @@ module OpenapiClient
156
318
  end
157
319
 
158
320
  # Update a Live Activity
159
- # Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
321
+ # Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
160
322
  # @param live_activity_update_request [LiveActivityUpdateRequest]
161
323
  # @param [Hash] opts the optional parameters
162
324
  # @return [LiveActivityUpdateResponse]
@@ -166,7 +328,7 @@ module OpenapiClient
166
328
  end
167
329
 
168
330
  # Update a Live Activity
169
- # Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
331
+ # Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
170
332
  # @param live_activity_update_request [LiveActivityUpdateRequest]
171
333
  # @param [Hash] opts the optional parameters
172
334
  # @return [Array<(LiveActivityUpdateResponse, Integer, Hash)>] LiveActivityUpdateResponse data, response status code and response headers
@@ -0,0 +1,293 @@
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
+ class ActivityMetric
18
+ attr_accessor :label
19
+
20
+ attr_accessor :value
21
+
22
+ attr_accessor :unit
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'label' => :'label',
28
+ :'value' => :'value',
29
+ :'unit' => :'unit'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'label' => :'String',
42
+ :'value' => :'Float',
43
+ :'unit' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::ActivityMetric` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::ActivityMetric`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'label')
69
+ self.label = attributes[:'label']
70
+ else
71
+ self.label = nil
72
+ end
73
+
74
+ if attributes.key?(:'value')
75
+ self.value = attributes[:'value']
76
+ else
77
+ self.value = nil
78
+ end
79
+
80
+ if attributes.key?(:'unit')
81
+ self.unit = attributes[:'unit']
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
89
+ invalid_properties = Array.new
90
+ if @label.nil?
91
+ invalid_properties.push('invalid value for "label", label cannot be nil.')
92
+ end
93
+
94
+ if @label.to_s.length < 1
95
+ invalid_properties.push('invalid value for "label", the character length must be great than or equal to 1.')
96
+ end
97
+
98
+ if @value.nil?
99
+ invalid_properties.push('invalid value for "value", value cannot be nil.')
100
+ end
101
+
102
+ if @value > 100
103
+ invalid_properties.push('invalid value for "value", must be smaller than or equal to 100.')
104
+ end
105
+
106
+ if @value < 0
107
+ invalid_properties.push('invalid value for "value", must be greater than or equal to 0.')
108
+ end
109
+
110
+ invalid_properties
111
+ end
112
+
113
+ # Check to see if the all the properties in the model are valid
114
+ # @return true if the model is valid
115
+ def valid?
116
+ warn '[DEPRECATED] the `valid?` method is obsolete'
117
+ return false if @label.nil?
118
+ return false if @label.to_s.length < 1
119
+ return false if @value.nil?
120
+ return false if @value > 100
121
+ return false if @value < 0
122
+ true
123
+ end
124
+
125
+ # Custom attribute writer method with validation
126
+ # @param [Object] label Value to be assigned
127
+ def label=(label)
128
+ if label.nil?
129
+ fail ArgumentError, 'label cannot be nil'
130
+ end
131
+
132
+ if label.to_s.length < 1
133
+ fail ArgumentError, 'invalid value for "label", the character length must be great than or equal to 1.'
134
+ end
135
+
136
+ @label = label
137
+ end
138
+
139
+ # Custom attribute writer method with validation
140
+ # @param [Object] value Value to be assigned
141
+ def value=(value)
142
+ if value.nil?
143
+ fail ArgumentError, 'value cannot be nil'
144
+ end
145
+
146
+ if value > 100
147
+ fail ArgumentError, 'invalid value for "value", must be smaller than or equal to 100.'
148
+ end
149
+
150
+ if value < 0
151
+ fail ArgumentError, 'invalid value for "value", must be greater than or equal to 0.'
152
+ end
153
+
154
+ @value = value
155
+ end
156
+
157
+ # Checks equality by comparing each attribute.
158
+ # @param [Object] Object to be compared
159
+ def ==(o)
160
+ return true if self.equal?(o)
161
+ self.class == o.class &&
162
+ label == o.label &&
163
+ value == o.value &&
164
+ unit == o.unit
165
+ end
166
+
167
+ # @see the `==` method
168
+ # @param [Object] Object to be compared
169
+ def eql?(o)
170
+ self == o
171
+ end
172
+
173
+ # Calculates hash code according to all attributes.
174
+ # @return [Integer] Hash code
175
+ def hash
176
+ [label, value, unit].hash
177
+ end
178
+
179
+ # Builds the object from hash
180
+ # @param [Hash] attributes Model attributes in the form of hash
181
+ # @return [Object] Returns the model itself
182
+ def self.build_from_hash(attributes)
183
+ return nil unless attributes.is_a?(Hash)
184
+ attributes = attributes.transform_keys(&:to_sym)
185
+ transformed_hash = {}
186
+ openapi_types.each_pair do |key, type|
187
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
188
+ transformed_hash["#{key}"] = nil
189
+ elsif type =~ /\AArray<(.*)>/i
190
+ # check to ensure the input is an array given that the attribute
191
+ # is documented as an array but the input is not
192
+ if attributes[attribute_map[key]].is_a?(Array)
193
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
194
+ end
195
+ elsif !attributes[attribute_map[key]].nil?
196
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
197
+ end
198
+ end
199
+ new(transformed_hash)
200
+ end
201
+
202
+ # Deserializes the data based on type
203
+ # @param string type Data type
204
+ # @param string value Value to be deserialized
205
+ # @return [Object] Deserialized data
206
+ def self._deserialize(type, value)
207
+ case type.to_sym
208
+ when :Time
209
+ Time.parse(value)
210
+ when :Date
211
+ Date.parse(value)
212
+ when :String
213
+ value.to_s
214
+ when :Integer
215
+ value.to_i
216
+ when :Float
217
+ value.to_f
218
+ when :Boolean
219
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
220
+ true
221
+ else
222
+ false
223
+ end
224
+ when :Object
225
+ # generic object (usually a Hash), return directly
226
+ value
227
+ when /\AArray<(?<inner_type>.+)>\z/
228
+ inner_type = Regexp.last_match[:inner_type]
229
+ value.map { |v| _deserialize(inner_type, v) }
230
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
231
+ k_type = Regexp.last_match[:k_type]
232
+ v_type = Regexp.last_match[:v_type]
233
+ {}.tap do |hash|
234
+ value.each do |k, v|
235
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
236
+ end
237
+ end
238
+ else # model
239
+ # models (e.g. Pet) or oneOf
240
+ klass = OpenapiClient.const_get(type)
241
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
242
+ end
243
+ end
244
+
245
+ # Returns the string representation of the object
246
+ # @return [String] String presentation of the object
247
+ def to_s
248
+ to_hash.to_s
249
+ end
250
+
251
+ # to_body is an alias to to_hash (backward compatibility)
252
+ # @return [Hash] Returns the object in the form of hash
253
+ def to_body
254
+ to_hash
255
+ end
256
+
257
+ # Returns the object in the form of hash
258
+ # @return [Hash] Returns the object in the form of hash
259
+ def to_hash
260
+ hash = {}
261
+ self.class.attribute_map.each_pair do |attr, param|
262
+ value = self.send(attr)
263
+ if value.nil?
264
+ is_nullable = self.class.openapi_nullable.include?(attr)
265
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
266
+ end
267
+
268
+ hash[param] = _to_hash(value)
269
+ end
270
+ hash
271
+ end
272
+
273
+ # Outputs non-array value in the form of hash
274
+ # For object, use to_hash. Otherwise, just return the value
275
+ # @param [Object] value Any valid value
276
+ # @return [Hash] Returns the value in the form of hash
277
+ def _to_hash(value)
278
+ if value.is_a?(Array)
279
+ value.compact.map { |v| _to_hash(v) }
280
+ elsif value.is_a?(Hash)
281
+ {}.tap do |hash|
282
+ value.each { |k, v| hash[k] = _to_hash(v) }
283
+ end
284
+ elsif value.respond_to? :to_hash
285
+ value.to_hash
286
+ else
287
+ value
288
+ end
289
+ end
290
+
291
+ end
292
+
293
+ end
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module OpenapiClient
17
- # End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
17
+ # End 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 include a non-empty metrics array. Legacy counter/timer/countdown types also use current_step and number_of_steps. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
18
18
  class ContentStateEnd
19
19
  attr_accessor :title
20
20
 
@@ -35,6 +35,9 @@ module OpenapiClient
35
35
  # Maximum progress value. Use with value for type=progress.
36
36
  attr_accessor :upper_limit
37
37
 
38
+ # Use for type=metrics.
39
+ attr_accessor :metrics
40
+
38
41
  # Optional. When omitted, the API uses the existing Live Activity type.
39
42
  attr_accessor :type
40
43
 
@@ -44,6 +47,9 @@ module OpenapiClient
44
47
  # Optional. Overrides color for the current step. Only applies to type=segmented_progress.
45
48
  attr_accessor :step_color
46
49
 
50
+ # Optional. Colors for completed steps. When used with segmented_progress, the array length should match current_step.
51
+ attr_accessor :step_colors
52
+
47
53
  # Optional. Minutes before the ended Live Activity is dismissed. Default 3. Set 0 for immediate dismissal. iOS will dismiss ended Live Activities after ~4 hours max.
48
54
  attr_accessor :auto_dismiss_minutes
49
55
 
@@ -79,9 +85,11 @@ module OpenapiClient
79
85
  :'percentage' => :'percentage',
80
86
  :'value' => :'value',
81
87
  :'upper_limit' => :'upper_limit',
88
+ :'metrics' => :'metrics',
82
89
  :'type' => :'type',
83
90
  :'color' => :'color',
84
91
  :'step_color' => :'step_color',
92
+ :'step_colors' => :'step_colors',
85
93
  :'auto_dismiss_minutes' => :'auto_dismiss_minutes'
86
94
  }
87
95
  end
@@ -101,9 +109,11 @@ module OpenapiClient
101
109
  :'percentage' => :'Float',
102
110
  :'value' => :'Float',
103
111
  :'upper_limit' => :'Float',
112
+ :'metrics' => :'Array<ActivityMetric>',
104
113
  :'type' => :'String',
105
114
  :'color' => :'String',
106
115
  :'step_color' => :'String',
116
+ :'step_colors' => :'Array<String>',
107
117
  :'auto_dismiss_minutes' => :'Integer'
108
118
  }
109
119
  end
@@ -159,6 +169,12 @@ module OpenapiClient
159
169
  self.upper_limit = attributes[:'upper_limit']
160
170
  end
161
171
 
172
+ if attributes.key?(:'metrics')
173
+ if (value = attributes[:'metrics']).is_a?(Array)
174
+ self.metrics = value
175
+ end
176
+ end
177
+
162
178
  if attributes.key?(:'type')
163
179
  self.type = attributes[:'type']
164
180
  end
@@ -173,6 +189,12 @@ module OpenapiClient
173
189
  self.step_color = attributes[:'step_color']
174
190
  end
175
191
 
192
+ if attributes.key?(:'step_colors')
193
+ if (value = attributes[:'step_colors']).is_a?(Array)
194
+ self.step_colors = value
195
+ end
196
+ end
197
+
176
198
  if attributes.key?(:'auto_dismiss_minutes')
177
199
  self.auto_dismiss_minutes = attributes[:'auto_dismiss_minutes']
178
200
  else
@@ -205,6 +227,10 @@ module OpenapiClient
205
227
  invalid_properties.push('invalid value for "percentage", must be greater than or equal to 0.')
206
228
  end
207
229
 
230
+ if !@metrics.nil? && @metrics.length < 1
231
+ invalid_properties.push('invalid value for "metrics", number of items must be greater than or equal to 1.')
232
+ end
233
+
208
234
  if !@auto_dismiss_minutes.nil? && @auto_dismiss_minutes < 0
209
235
  invalid_properties.push('invalid value for "auto_dismiss_minutes", must be greater than or equal to 0.')
210
236
  end
@@ -221,7 +247,8 @@ module OpenapiClient
221
247
  return false if !@current_step.nil? && @current_step < 1
222
248
  return false if !@percentage.nil? && @percentage > 100
223
249
  return false if !@percentage.nil? && @percentage < 0
224
- type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress"])
250
+ return false if !@metrics.nil? && @metrics.length < 1
251
+ type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "counter", "timer", "countdown"])
225
252
  return false unless type_validator.valid?(@type)
226
253
  color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
227
254
  return false unless color_validator.valid?(@color)
@@ -277,10 +304,24 @@ module OpenapiClient
277
304
  @percentage = percentage
278
305
  end
279
306
 
307
+ # Custom attribute writer method with validation
308
+ # @param [Object] metrics Value to be assigned
309
+ def metrics=(metrics)
310
+ if metrics.nil?
311
+ fail ArgumentError, 'metrics cannot be nil'
312
+ end
313
+
314
+ if metrics.length < 1
315
+ fail ArgumentError, 'invalid value for "metrics", number of items must be greater than or equal to 1.'
316
+ end
317
+
318
+ @metrics = metrics
319
+ end
320
+
280
321
  # Custom attribute writer method checking allowed values (enum).
281
322
  # @param [Object] type Object to be assigned
282
323
  def type=(type)
283
- validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress"])
324
+ validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "counter", "timer", "countdown"])
284
325
  unless validator.valid?(type)
285
326
  fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
286
327
  end
@@ -333,9 +374,11 @@ module OpenapiClient
333
374
  percentage == o.percentage &&
334
375
  value == o.value &&
335
376
  upper_limit == o.upper_limit &&
377
+ metrics == o.metrics &&
336
378
  type == o.type &&
337
379
  color == o.color &&
338
380
  step_color == o.step_color &&
381
+ step_colors == o.step_colors &&
339
382
  auto_dismiss_minutes == o.auto_dismiss_minutes
340
383
  end
341
384
 
@@ -348,7 +391,7 @@ module OpenapiClient
348
391
  # Calculates hash code according to all attributes.
349
392
  # @return [Integer] Hash code
350
393
  def hash
351
- [title, subtitle, number_of_steps, current_step, percentage, value, upper_limit, type, color, step_color, auto_dismiss_minutes].hash
394
+ [title, subtitle, number_of_steps, current_step, percentage, value, upper_limit, metrics, type, color, step_color, step_colors, auto_dismiss_minutes].hash
352
395
  end
353
396
 
354
397
  # Builds the object from hash