diff --git a/CHANGELOG.md b/CHANGELOG.md index d6bf11e..8e9a429 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.12.0 + +Adds the new `value` Live Activity type. + ## 1.11.0 This version adds support for Metadata and iOS deep links, and expands Tags support when updating or ending Live Activities. diff --git a/README.md b/README.md index 8adcc76..1314fe6 100644 --- a/README.md +++ b/README.md @@ -140,33 +140,45 @@ activitysmith.notifications.send( Choose the Live Activity type that matches what you want to show: -![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) +- ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature. -**Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion. +- ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion. -![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) +- ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint. -**Metrics**: Track two related values with segmented bars, such as CPU and memory. +- ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory. -![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) +- ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify. -**Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify. +- ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion. -![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) +- ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs. -**Progress**: Show percentage progress for jobs that move continuously toward completion. - -![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) +### Start & Update Live Activity -**Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint. +Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `stream_key` update it. -![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) +#### Value -**Timer**: Count down from a duration, or count up from 00:00 while a job runs. +![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png) -### Start & Update Live Activity +```ruby +activitysmith.live_activities.stream( + "revenue-today", + { + content_state: { + title: "Revenue", + type: "value", + value: "$1,240", + color: "green", + icon: { symbol: "dollarsign.circle", color: "green" }, + badge: { title: "↑ 18%", color: "purple" } + } + } +) +``` -Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `stream_key` update it. +Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places. #### Stats @@ -193,6 +205,25 @@ activitysmith.live_activities.stream( ) ``` +#### Alert + +![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png) + +```ruby +activitysmith.live_activities.stream( + "customer-ops", + { + content_state: ActivitySmith::LiveActivities.content_state( + title: "Reactivation", + message: "Lumen came back after 2 weeks", + type: ActivitySmith::LiveActivities::TYPE_ALERT, + icon: ActivitySmith::LiveActivities.alert_icon("cloud.sun", color: "yellow"), + badge: ActivitySmith::LiveActivities.alert_badge("Customer", color: "magenta") + ) + } +) +``` + #### Metrics ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) @@ -251,25 +282,6 @@ activitysmith.live_activities.stream( ) ``` -#### Alert - -![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png) - -```ruby -activitysmith.live_activities.stream( - "customer-ops", - { - content_state: ActivitySmith::LiveActivities.content_state( - title: "Reactivation", - message: "Lumen came back after 2 weeks", - type: ActivitySmith::LiveActivities::TYPE_ALERT, - icon: ActivitySmith::LiveActivities.alert_icon("cloud.sun", color: "yellow"), - badge: ActivitySmith::LiveActivities.alert_badge("Customer", color: "magenta") - ) - } -) -``` - #### Timer ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png) @@ -321,7 +333,7 @@ Add more context to Live Activities with icons and badges. #### Icon -Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, `alert`, and `timer`. +Supported Live Activity types: `value`, `stats`, `alert`, `metrics`, `segmented_progress`, `progress`, and `timer`. ![Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen](https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png) @@ -351,7 +363,7 @@ The `icon` symbol value is an Apple SF Symbol name. Browse the catalog with one #### Badge -Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities. +Badges are supported by `value`, `alert`, `segmented_progress`, and `progress` Live Activities. ![Progress Live Activity with a badge on the iPhone Lock Screen](https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png) @@ -471,7 +483,7 @@ activitysmith.live_activities.stream( Use `secondary_action` when you want a second button beside the primary `action`. -The secondary action button is supported for `alert`, `progress`, and `segmented_progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes. +The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes. ```ruby activitysmith.live_activities.stream( @@ -653,3 +665,7 @@ end ### [RubyGems Package](https://rubygems.org/gems/activitysmith) Install the ActivitySmith Ruby SDK from RubyGems + +### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-ruby) + +View the Ruby SDK source on GitHub diff --git a/generated/activitysmith_openapi.rb b/generated/activitysmith_openapi.rb index 87bdaa3..14c26ef 100644 --- a/generated/activitysmith_openapi.rb +++ b/generated/activitysmith_openapi.rb @@ -45,6 +45,7 @@ require 'activitysmith_openapi/models/live_activity_stream_request' require 'activitysmith_openapi/models/live_activity_update_request' require 'activitysmith_openapi/models/live_activity_update_response' +require 'activitysmith_openapi/models/live_activity_value' require 'activitysmith_openapi/models/live_activity_webhook_method' require 'activitysmith_openapi/models/metadata_value' require 'activitysmith_openapi/models/metric_error' diff --git a/generated/activitysmith_openapi/api/live_activities_api.rb b/generated/activitysmith_openapi/api/live_activities_api.rb index 18c7cb4..c106b10 100644 --- a/generated/activitysmith_openapi/api/live_activities_api.rb +++ b/generated/activitysmith_openapi/api/live_activities_api.rb @@ -20,7 +20,7 @@ def initialize(api_client = ApiClient.default) @api_client = api_client end # End a Live Activity (legacy manual lifecycle) - # Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. + # Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, stats, alert, timer, and value activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. # @param live_activity_end_request [LiveActivityEndRequest] # @param [Hash] opts the optional parameters # @return [LiveActivityEndResponse] @@ -30,7 +30,7 @@ def end_live_activity(live_activity_end_request, opts = {}) end # End a Live Activity (legacy manual lifecycle) - # Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. + # Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, stats, alert, timer, and value activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. # @param live_activity_end_request [LiveActivityEndRequest] # @param [Hash] opts the optional parameters # @return [Array<(LiveActivityEndResponse, Integer, Hash)>] LiveActivityEndResponse data, response status code and response headers @@ -88,7 +88,7 @@ def end_live_activity_with_http_info(live_activity_end_request, opts = {}) end # End a stream - # 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. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. + # 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. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. # @param stream_key [String] Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens. # @param [Hash] opts the optional parameters # @option opts [LiveActivityStreamDeleteRequest] :live_activity_stream_delete_request @@ -99,7 +99,7 @@ def end_live_activity_stream(stream_key, opts = {}) end # End a stream - # 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. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. + # 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. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. # @param stream_key [String] Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens. # @param [Hash] opts the optional parameters # @option opts [LiveActivityStreamDeleteRequest] :live_activity_stream_delete_request @@ -167,7 +167,7 @@ def end_live_activity_stream_with_http_info(stream_key, opts = {}) end # Start a new Live Activity or update an existing one - # Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them. + # Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them. # @param stream_key [String] Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens. # @param live_activity_stream_request [LiveActivityStreamRequest] # @param [Hash] opts the optional parameters @@ -178,7 +178,7 @@ def reconcile_live_activity_stream(stream_key, live_activity_stream_request, opt end # Start a new Live Activity or update an existing one - # Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them. + # Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them. # @param stream_key [String] Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens. # @param live_activity_stream_request [LiveActivityStreamRequest] # @param [Hash] opts the optional parameters @@ -250,7 +250,7 @@ def reconcile_live_activity_stream_with_http_info(stream_key, live_activity_stre end # Start a Live Activity (legacy manual lifecycle) - # Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. Optional tags to organize and filter notification history. + # Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, stats, alert, timer, and value activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. # @param live_activity_start_request [LiveActivityStartRequest] # @param [Hash] opts the optional parameters # @return [LiveActivityStartResponse] @@ -260,7 +260,7 @@ def start_live_activity(live_activity_start_request, opts = {}) end # Start a Live Activity (legacy manual lifecycle) - # Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. Optional tags to organize and filter notification history. + # Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, stats, alert, timer, and value activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. # @param live_activity_start_request [LiveActivityStartRequest] # @param [Hash] opts the optional parameters # @return [Array<(LiveActivityStartResponse, Integer, Hash)>] LiveActivityStartResponse data, response status code and response headers @@ -318,7 +318,7 @@ def start_live_activity_with_http_info(live_activity_start_request, opts = {}) end # Update a Live Activity (legacy manual lifecycle) - # Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. For timer activities, send duration_seconds only when you want to reset the timer window; omit it to keep the current timer running. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. + # Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, stats, alert, timer, and value activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. For timer activities, send duration_seconds only when you want to reset the timer window; omit it to keep the current timer running. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. # @param live_activity_update_request [LiveActivityUpdateRequest] # @param [Hash] opts the optional parameters # @return [LiveActivityUpdateResponse] @@ -328,7 +328,7 @@ def update_live_activity(live_activity_update_request, opts = {}) end # Update a Live Activity (legacy manual lifecycle) - # Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. For timer activities, send duration_seconds only when you want to reset the timer window; omit it to keep the current timer running. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. + # Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, stats, alert, timer, and value activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. For timer activities, send duration_seconds only when you want to reset the timer window; omit it to keep the current timer running. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. # @param live_activity_update_request [LiveActivityUpdateRequest] # @param [Hash] opts the optional parameters # @return [Array<(LiveActivityUpdateResponse, Integer, Hash)>] LiveActivityUpdateResponse data, response status code and response headers diff --git a/generated/activitysmith_openapi/api/metrics_api.rb b/generated/activitysmith_openapi/api/metrics_api.rb index e625768..1efa62b 100644 --- a/generated/activitysmith_openapi/api/metrics_api.rb +++ b/generated/activitysmith_openapi/api/metrics_api.rb @@ -20,7 +20,7 @@ def initialize(api_client = ApiClient.default) @api_client = api_client end # Update a widget metric value - # Updates the latest value for a metric displayed in ActivitySmith widgets. Create the metric in the web app first, then update its value using the key. + # Updates the latest value for a metric displayed in ActivitySmith widgets. Create the metric in the web app first, then update its value using the key. Metric updates have an independent 300-requests-per-minute account allowance. They do not consume the Push Notification, badge, or Live Activity allowances. # @param key [String] Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. # @param metric_value_update_request [MetricValueUpdateRequest] # @param [Hash] opts the optional parameters @@ -31,7 +31,7 @@ def update_metric_value(key, metric_value_update_request, opts = {}) end # Update a widget metric value - # Updates the latest value for a metric displayed in ActivitySmith widgets. Create the metric in the web app first, then update its value using the key. + # Updates the latest value for a metric displayed in ActivitySmith widgets. Create the metric in the web app first, then update its value using the key. Metric updates have an independent 300-requests-per-minute account allowance. They do not consume the Push Notification, badge, or Live Activity allowances. # @param key [String] Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. # @param metric_value_update_request [MetricValueUpdateRequest] # @param [Hash] opts the optional parameters diff --git a/generated/activitysmith_openapi/models/content_state_end.rb b/generated/activitysmith_openapi/models/content_state_end.rb index bc72c5a..30a186b 100644 --- a/generated/activitysmith_openapi/models/content_state_end.rb +++ b/generated/activitysmith_openapi/models/content_state_end.rb @@ -14,7 +14,7 @@ require 'time' module OpenapiClient - # 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 and stats include a non-empty metrics array. For alert include message. For timer, omit duration_seconds to preserve and freeze the latest timer state. Optional icon is supported by all Live Activity types. Optional badge is supported by alert, progress, and segmented_progress. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start. + # 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 and stats include a non-empty metrics array. For value include a string or number in value; strings preserve currency, units, and other formatting. For alert include message. For timer, omit duration_seconds to preserve and freeze the latest timer state. Optional icon is supported by all Live Activity types. Optional badge is supported by alert, progress, segmented_progress, and value. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start. class ContentStateEnd attr_accessor :title @@ -29,7 +29,7 @@ class ContentStateEnd # Progress percentage (0–100). Use for type=progress. Takes precedence over value/upper_limit if both are provided. attr_accessor :percentage - # Current progress value. Use with upper_limit for type=progress. + # For type=value, the required prominent readout (string or finite number); strings preserve exact formatting. For type=progress, a numeric progress value used with upper_limit. attr_accessor :value # Maximum progress value. Use with value for type=progress. @@ -50,16 +50,16 @@ class ContentStateEnd # Alert message. Use for type=alert. attr_accessor :message - # Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, stats, and timer. + # Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, stats, timer, and value. attr_accessor :icon - # Optional badge. Supported by alert, progress, and segmented_progress. + # Optional badge. Supported by alert, progress, segmented_progress, and value. attr_accessor :badge # Optional. When omitted, the API uses the existing Live Activity type. attr_accessor :type - # Optional. Accent color for progress, segmented_progress, metrics, and timer Live Activities. For Alert Live Activities, this tints action and secondary_action buttons when included. + # Optional. Accent color for progress, segmented_progress, metrics, timer, and value Live Activities. For Alert Live Activities, this tints action and secondary_action buttons when included. attr_accessor :color # Optional. Overrides color for the current step. Only applies to type=segmented_progress. @@ -131,7 +131,7 @@ def self.openapi_types :'number_of_steps' => :'Integer', :'current_step' => :'Integer', :'percentage' => :'Float', - :'value' => :'Float', + :'value' => :'LiveActivityValue', :'upper_limit' => :'Float', :'duration_seconds' => :'Float', :'counts_down' => :'Boolean', @@ -314,7 +314,7 @@ def valid? return false if !@metrics.nil? && @metrics.length > 8 return false if !@metrics.nil? && @metrics.length < 1 return false if !@message.nil? && @message.to_s.length < 1 - type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer"]) + type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer", "value"]) return false unless type_validator.valid?(@type) color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "gray"]) return false unless color_validator.valid?(@color) @@ -405,7 +405,7 @@ def message=(message) # Custom attribute writer method checking allowed values (enum). # @param [Object] type Object to be assigned def type=(type) - validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer"]) + validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer", "value"]) unless validator.valid?(type) fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." end diff --git a/generated/activitysmith_openapi/models/content_state_start.rb b/generated/activitysmith_openapi/models/content_state_start.rb index e1bbdcb..933085e 100644 --- a/generated/activitysmith_openapi/models/content_state_start.rb +++ b/generated/activitysmith_openapi/models/content_state_start.rb @@ -14,7 +14,7 @@ require 'time' module OpenapiClient - # Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. For alert include message. For timer include duration_seconds for countdowns, or set counts_down false without duration_seconds for an open-ended elapsed timer. Optional icon is supported by all Live Activity types. Optional badge is supported by alert, progress, and segmented_progress. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls. + # Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. For value include a string or number in value; strings preserve currency, units, and other formatting. For alert include message. For timer include duration_seconds for countdowns, or set counts_down false without duration_seconds for an open-ended elapsed timer. Optional icon is supported by all Live Activity types. Optional badge is supported by alert, progress, segmented_progress, and value. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls. class ContentStateStart attr_accessor :title @@ -29,7 +29,7 @@ class ContentStateStart # Progress percentage (0–100). Use for type=progress. Takes precedence over value/upper_limit if both are provided. attr_accessor :percentage - # Current progress value. Use with upper_limit for type=progress. + # For type=value, the required prominent readout (string or finite number); strings preserve exact formatting. For type=progress, a numeric progress value used with upper_limit. attr_accessor :value # Maximum progress value. Use with value for type=progress. @@ -50,15 +50,15 @@ class ContentStateStart # Required for type=alert. attr_accessor :message - # Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, stats, and timer. + # Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, stats, timer, and value. attr_accessor :icon - # Optional badge. Supported by alert, progress, and segmented_progress. + # Optional badge. Supported by alert, progress, segmented_progress, and value. attr_accessor :badge attr_accessor :type - # Optional. Accent color for progress, segmented_progress, metrics, and timer Live Activities. For Alert Live Activities, this tints action and secondary_action buttons when included. + # Optional. Accent color for progress, segmented_progress, metrics, timer, and value Live Activities. For Alert Live Activities, this tints action and secondary_action buttons when included. attr_accessor :color # Optional. Overrides color for the current step. Only applies to type=segmented_progress. @@ -126,7 +126,7 @@ def self.openapi_types :'number_of_steps' => :'Integer', :'current_step' => :'Integer', :'percentage' => :'Float', - :'value' => :'Float', + :'value' => :'LiveActivityValue', :'upper_limit' => :'Float', :'duration_seconds' => :'Float', :'counts_down' => :'Boolean', @@ -305,7 +305,7 @@ def valid? return false if !@metrics.nil? && @metrics.length < 1 return false if !@message.nil? && @message.to_s.length < 1 return false if @type.nil? - type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer"]) + type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer", "value"]) return false unless type_validator.valid?(@type) color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "gray"]) return false unless color_validator.valid?(@color) @@ -395,7 +395,7 @@ def message=(message) # Custom attribute writer method checking allowed values (enum). # @param [Object] type Object to be assigned def type=(type) - validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer"]) + validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer", "value"]) unless validator.valid?(type) fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." end diff --git a/generated/activitysmith_openapi/models/content_state_update.rb b/generated/activitysmith_openapi/models/content_state_update.rb index af2cac6..79d9a54 100644 --- a/generated/activitysmith_openapi/models/content_state_update.rb +++ b/generated/activitysmith_openapi/models/content_state_update.rb @@ -14,7 +14,7 @@ require 'time' module OpenapiClient - # 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. For timer, omit duration_seconds to preserve the current timer window or send duration_seconds to reset the timer from the update request time. 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. + # 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 value include a string or number in value; strings preserve currency, units, and other formatting. For alert include message. For timer, omit duration_seconds to preserve the current timer window or send duration_seconds to reset the timer from the update request time. Optional icon is supported by all Live Activity types. Optional badge is supported by alert, progress, segmented_progress, and value. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates. class ContentStateUpdate attr_accessor :title @@ -29,7 +29,7 @@ class ContentStateUpdate # Progress percentage (0–100). Use for type=progress. Takes precedence over value/upper_limit if both are provided. attr_accessor :percentage - # Current progress value. Use with upper_limit for type=progress. + # For type=value, the required prominent readout (string or finite number); strings preserve exact formatting. For type=progress, a numeric progress value used with upper_limit. attr_accessor :value # Maximum progress value. Use with value for type=progress. @@ -50,16 +50,16 @@ class ContentStateUpdate # Alert message. Use for type=alert. attr_accessor :message - # Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, stats, and timer. + # Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, stats, timer, and value. attr_accessor :icon - # Optional badge. Supported by alert, progress, and segmented_progress. + # Optional badge. Supported by alert, progress, segmented_progress, and value. attr_accessor :badge # Optional. When omitted, the API uses the existing Live Activity type. attr_accessor :type - # Optional. Accent color for progress, segmented_progress, metrics, and timer Live Activities. For Alert Live Activities, this tints action and secondary_action buttons when included. + # Optional. Accent color for progress, segmented_progress, metrics, timer, and value Live Activities. For Alert Live Activities, this tints action and secondary_action buttons when included. attr_accessor :color # Optional. Overrides color for the current step. Only applies to type=segmented_progress. @@ -127,7 +127,7 @@ def self.openapi_types :'number_of_steps' => :'Integer', :'current_step' => :'Integer', :'percentage' => :'Float', - :'value' => :'Float', + :'value' => :'LiveActivityValue', :'upper_limit' => :'Float', :'duration_seconds' => :'Float', :'counts_down' => :'Boolean', @@ -299,7 +299,7 @@ def valid? return false if !@metrics.nil? && @metrics.length > 8 return false if !@metrics.nil? && @metrics.length < 1 return false if !@message.nil? && @message.to_s.length < 1 - type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer"]) + type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer", "value"]) return false unless type_validator.valid?(@type) color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "gray"]) return false unless color_validator.valid?(@color) @@ -389,7 +389,7 @@ def message=(message) # Custom attribute writer method checking allowed values (enum). # @param [Object] type Object to be assigned def type=(type) - validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer"]) + validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer", "value"]) unless validator.valid?(type) fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." end diff --git a/generated/activitysmith_openapi/models/live_activity_action.rb b/generated/activitysmith_openapi/models/live_activity_action.rb index 682acfe..4cb941e 100644 --- a/generated/activitysmith_openapi/models/live_activity_action.rb +++ b/generated/activitysmith_openapi/models/live_activity_action.rb @@ -14,7 +14,7 @@ require 'time' module OpenapiClient - # Optional action button shown in the Live Activity UI. Use action for the primary button, or secondary_action for a secondary button on alert, progress, and segmented_progress Live Activities. + # Optional action button shown in the Live Activity UI. Use action for the primary button, or secondary_action for a secondary button on alert, progress, segmented_progress, and value Live Activities. class LiveActivityAction # Button title displayed in the Live Activity UI. attr_accessor :title @@ -30,6 +30,28 @@ class LiveActivityAction # Optional webhook payload body. Used only when type=webhook. attr_accessor :body + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/generated/activitysmith_openapi/models/live_activity_end_request.rb b/generated/activitysmith_openapi/models/live_activity_end_request.rb index d8877d0..e571922 100644 --- a/generated/activitysmith_openapi/models/live_activity_end_request.rb +++ b/generated/activitysmith_openapi/models/live_activity_end_request.rb @@ -28,7 +28,7 @@ class LiveActivityEndRequest attr_accessor :action - # Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + # Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. attr_accessor :secondary_action # Attribute mapping from ruby-style variable name to JSON key. diff --git a/generated/activitysmith_openapi/models/live_activity_start_request.rb b/generated/activitysmith_openapi/models/live_activity_start_request.rb index 135006f..edee64d 100644 --- a/generated/activitysmith_openapi/models/live_activity_start_request.rb +++ b/generated/activitysmith_openapi/models/live_activity_start_request.rb @@ -23,7 +23,7 @@ class LiveActivityStartRequest attr_accessor :action - # Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + # Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. attr_accessor :secondary_action attr_accessor :alert diff --git a/generated/activitysmith_openapi/models/live_activity_stream_delete_request.rb b/generated/activitysmith_openapi/models/live_activity_stream_delete_request.rb index 0cb5d09..edb68c1 100644 --- a/generated/activitysmith_openapi/models/live_activity_stream_delete_request.rb +++ b/generated/activitysmith_openapi/models/live_activity_stream_delete_request.rb @@ -26,7 +26,7 @@ class LiveActivityStreamDeleteRequest attr_accessor :action - # Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + # Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. attr_accessor :secondary_action attr_accessor :alert diff --git a/generated/activitysmith_openapi/models/live_activity_stream_request.rb b/generated/activitysmith_openapi/models/live_activity_stream_request.rb index 0253e2b..8d849f4 100644 --- a/generated/activitysmith_openapi/models/live_activity_stream_request.rb +++ b/generated/activitysmith_openapi/models/live_activity_stream_request.rb @@ -23,7 +23,7 @@ class LiveActivityStreamRequest attr_accessor :action - # Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + # Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. attr_accessor :secondary_action attr_accessor :alert diff --git a/generated/activitysmith_openapi/models/live_activity_update_request.rb b/generated/activitysmith_openapi/models/live_activity_update_request.rb index ae174e2..0e2295a 100644 --- a/generated/activitysmith_openapi/models/live_activity_update_request.rb +++ b/generated/activitysmith_openapi/models/live_activity_update_request.rb @@ -28,7 +28,7 @@ class LiveActivityUpdateRequest attr_accessor :action - # Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + # Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. attr_accessor :secondary_action # Attribute mapping from ruby-style variable name to JSON key. diff --git a/generated/activitysmith_openapi/models/live_activity_value.rb b/generated/activitysmith_openapi/models/live_activity_value.rb new file mode 100644 index 0000000..71bcda3 --- /dev/null +++ b/generated/activitysmith_openapi/models/live_activity_value.rb @@ -0,0 +1,106 @@ +=begin +#ActivitySmith API + +#Send push notifications and Live Activities to your own devices via a single API key. + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +Generator version: 7.7.0 + +=end + +require 'date' +require 'time' + +module OpenapiClient + # A formatted string or finite numeric Live Activity value. String formatting is preserved. + module LiveActivityValue + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'Float', + :'String' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = OpenapiClient.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/generated/activitysmith_openapi/models/push_notification_action.rb b/generated/activitysmith_openapi/models/push_notification_action.rb index a3dd68d..efa93af 100644 --- a/generated/activitysmith_openapi/models/push_notification_action.rb +++ b/generated/activitysmith_openapi/models/push_notification_action.rb @@ -29,6 +29,28 @@ class PushNotificationAction # Optional webhook payload body. Used only when type=webhook. attr_accessor :body + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/generated/activitysmith_openapi/models/rate_limit_error.rb b/generated/activitysmith_openapi/models/rate_limit_error.rb index 3015532..d123af0 100644 --- a/generated/activitysmith_openapi/models/rate_limit_error.rb +++ b/generated/activitysmith_openapi/models/rate_limit_error.rb @@ -15,13 +15,38 @@ module OpenapiClient class RateLimitError + attr_accessor :code + attr_accessor :error attr_accessor :message + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'code' => :'code', :'error' => :'error', :'message' => :'message' } @@ -35,6 +60,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'code' => :'String', :'error' => :'String', :'message' => :'String' } @@ -61,6 +87,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + if attributes.key?(:'error') self.error = attributes[:'error'] else @@ -94,16 +124,29 @@ def list_invalid_properties # @return true if the model is valid def valid? warn '[DEPRECATED] the `valid?` method is obsolete' + code_validator = EnumAttributeValidator.new('String', ["rate_limited"]) + return false unless code_validator.valid?(@code) return false if @error.nil? return false if @message.nil? true end + # Custom attribute writer method checking allowed values (enum). + # @param [Object] code Object to be assigned + def code=(code) + validator = EnumAttributeValidator.new('String', ["rate_limited"]) + unless validator.valid?(code) + fail ArgumentError, "invalid value for \"code\", must be one of #{validator.allowable_values}." + end + @code = code + end + # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && + code == o.code && error == o.error && message == o.message end @@ -117,7 +160,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [error, message].hash + [code, error, message].hash end # Builds the object from hash diff --git a/generated/activitysmith_openapi/models/stream_content_state.rb b/generated/activitysmith_openapi/models/stream_content_state.rb index 44bfe73..2aa7739 100644 --- a/generated/activitysmith_openapi/models/stream_content_state.rb +++ b/generated/activitysmith_openapi/models/stream_content_state.rb @@ -14,7 +14,7 @@ require 'time' module OpenapiClient - # Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, metrics, stats, alert, and timer types. For timer, send duration_seconds to start or reset a bounded timer; omit duration_seconds on later updates to preserve the existing timer window. + # Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, metrics, stats, alert, timer, and value types. For timer, send duration_seconds to start or reset a bounded timer; omit duration_seconds on later updates to preserve the existing timer window. class StreamContentState attr_accessor :title @@ -29,7 +29,7 @@ class StreamContentState # Use for progress. Takes precedence over value/upper_limit if both are provided. attr_accessor :percentage - # Current progress value. Use with upper_limit for progress. + # For type=value, the required prominent readout (string or finite number); strings preserve exact formatting. For progress, a numeric progress value used with upper_limit. attr_accessor :value # Maximum progress value. Use with value for progress. @@ -47,7 +47,7 @@ class StreamContentState # Required on the first PUT or whenever the stream cannot infer the current activity type. attr_accessor :type - # Optional. Accent color for progress, segmented_progress, metrics, and timer Live Activities. For Alert Live Activities, this tints action and secondary_action buttons when included. + # Optional. Accent color for progress, segmented_progress, metrics, timer, and value Live Activities. For Alert Live Activities, this tints action and secondary_action buttons when included. attr_accessor :color # Optional. Overrides color for the current step. Only applies to segmented_progress. @@ -62,10 +62,10 @@ class StreamContentState # Required for type=alert. attr_accessor :message - # Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, stats, and timer. + # Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, stats, timer, and value. attr_accessor :icon - # Optional badge. Supported by alert, progress, and segmented_progress. + # Optional badge. Supported by alert, progress, segmented_progress, and value. attr_accessor :badge # Optional. Seconds before the ended Live Activity is dismissed. @@ -135,7 +135,7 @@ def self.openapi_types :'number_of_steps' => :'Integer', :'current_step' => :'Integer', :'percentage' => :'Float', - :'value' => :'Float', + :'value' => :'LiveActivityValue', :'upper_limit' => :'Float', :'duration_seconds' => :'Float', :'counts_down' => :'Boolean', @@ -322,7 +322,7 @@ def valid? return false if !@current_step.nil? && @current_step < 0 return false if !@percentage.nil? && @percentage > 100 return false if !@percentage.nil? && @percentage < 0 - type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer"]) + type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer", "value"]) return false unless type_validator.valid?(@type) color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "gray"]) return false unless color_validator.valid?(@color) @@ -385,7 +385,7 @@ def percentage=(percentage) # Custom attribute writer method checking allowed values (enum). # @param [Object] type Object to be assigned def type=(type) - validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer"]) + validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats", "alert", "timer", "value"]) unless validator.valid?(type) fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." end diff --git a/generated/activitysmith_openapi/version.rb b/generated/activitysmith_openapi/version.rb index 6a445ea..f59e041 100644 --- a/generated/activitysmith_openapi/version.rb +++ b/generated/activitysmith_openapi/version.rb @@ -11,5 +11,5 @@ =end module OpenapiClient - VERSION = '1.11.0' + VERSION = '1.12.0' end diff --git a/generated/openapi-source.json b/generated/openapi-source.json index dc05717..aeeecd6 100644 --- a/generated/openapi-source.json +++ b/generated/openapi-source.json @@ -1,6 +1,6 @@ { "repository": "ActivitySmithHQ/activitysmith-backend", - "commit": "49ad7b083b50f53bc3d81edb77ca6597845160a2", + "commit": "6832df646de7de8a6aaf0110960c37074b513c48", "path": "openapi.json", - "sha256": "b7e33cd485df8ddc5d7fb7b57b61106fd6f8ff3ffa7cc7bef4ac1ccbbb0cede7" + "sha256": "9ae85ad6127cfa2d50c33261459f5f9e85e011939d01ac4a9d507fa6ed11aa61" } diff --git a/lib/activitysmith/live_activities.rb b/lib/activitysmith/live_activities.rb index 7a81805..808d9a6 100644 --- a/lib/activitysmith/live_activities.rb +++ b/lib/activitysmith/live_activities.rb @@ -8,6 +8,7 @@ class LiveActivities TYPE_STATS = "stats" TYPE_ALERT = "alert" TYPE_TIMER = "timer" + TYPE_VALUE = "value" class << self def content_state(title:, type: nil, subtitle: nil, message: nil, icon: nil, badge: nil, color: nil, duration_seconds: nil, counts_down: nil, **fields) diff --git a/lib/activitysmith/version.rb b/lib/activitysmith/version.rb index 1937611..9515913 100644 --- a/lib/activitysmith/version.rb +++ b/lib/activitysmith/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ActivitySmith - VERSION = "1.11.0" + VERSION = "1.12.0" end diff --git a/test/resources_test.rb b/test/resources_test.rb index 6409987..1d814f0 100644 --- a/test/resources_test.rb +++ b/test/resources_test.rb @@ -806,3 +806,22 @@ def test_custom_schemes_and_stream_end_tags end end end + +class ValueSerializationTest < Minitest::Test + def test_formatted_values_and_zero + ["$1,240", "0007", "", 0, -12.75].each do |value| + api = FakeLiveApi.new + resource = ActivitySmith::LiveActivities.new(api) + state = ActivitySmith::LiveActivities.content_state(title: "Revenue", type: ActivitySmith::LiveActivities::TYPE_VALUE, value: value) + [:start, :update, :end, :stream, :end_stream].each do |method| + request = { content_state: state } + args = [:stream, :end_stream].include?(method) ? ["revenue", request] : [request] + resource.public_send(method, *args) + captured = api.calls.last + payload = method == :stream ? captured[2] : method == :end_stream ? captured[2][:live_activity_stream_delete_request] : captured[1] + body = JSON.parse(JSON.generate(payload)) + assert_equal value, body["content_state"]["value"] + end + end + end +end