From c6e48dc6bb60023f29dfa6a98e77fcdc1ebadfa0 Mon Sep 17 00:00:00 2001 From: activitysmith-bot Date: Sat, 9 May 2026 12:15:23 +0000 Subject: [PATCH] chore: regenerate SDK --- generated/activitysmith_openapi.rb | 1 + .../models/activity_metric.rb | 76 ++++++++----- .../models/activity_metric_value.rb | 105 ++++++++++++++++++ 3 files changed, 152 insertions(+), 30 deletions(-) create mode 100644 generated/activitysmith_openapi/models/activity_metric_value.rb diff --git a/generated/activitysmith_openapi.rb b/generated/activitysmith_openapi.rb index 99e50ad..e7af8db 100644 --- a/generated/activitysmith_openapi.rb +++ b/generated/activitysmith_openapi.rb @@ -18,6 +18,7 @@ # Models require 'activitysmith_openapi/models/activity_metric' +require 'activitysmith_openapi/models/activity_metric_value' require 'activitysmith_openapi/models/alert_payload' require 'activitysmith_openapi/models/bad_request_error' require 'activitysmith_openapi/models/channel_target' diff --git a/generated/activitysmith_openapi/models/activity_metric.rb b/generated/activitysmith_openapi/models/activity_metric.rb index ba725db..67c8b2e 100644 --- a/generated/activitysmith_openapi/models/activity_metric.rb +++ b/generated/activitysmith_openapi/models/activity_metric.rb @@ -21,12 +21,38 @@ class ActivityMetric attr_accessor :unit + # Optional per-metric accent color for metrics and stats activities. + attr_accessor :color + + 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 { :'label' => :'label', :'value' => :'value', - :'unit' => :'unit' + :'unit' => :'unit', + :'color' => :'color' } end @@ -39,8 +65,9 @@ def self.acceptable_attributes def self.openapi_types { :'label' => :'String', - :'value' => :'Float', - :'unit' => :'String' + :'value' => :'ActivityMetricValue', + :'unit' => :'String', + :'color' => :'String' } end @@ -80,6 +107,10 @@ def initialize(attributes = {}) if attributes.key?(:'unit') self.unit = attributes[:'unit'] end + + if attributes.key?(:'color') + self.color = attributes[:'color'] + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -99,14 +130,6 @@ def list_invalid_properties invalid_properties.push('invalid value for "value", value cannot be nil.') end - if @value > 100 - invalid_properties.push('invalid value for "value", must be smaller than or equal to 100.') - end - - if @value < 0 - invalid_properties.push('invalid value for "value", must be greater than or equal to 0.') - end - invalid_properties end @@ -117,8 +140,8 @@ def valid? return false if @label.nil? return false if @label.to_s.length < 1 return false if @value.nil? - return false if @value > 100 - return false if @value < 0 + color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"]) + return false unless color_validator.valid?(@color) true end @@ -136,22 +159,14 @@ def label=(label) @label = label end - # Custom attribute writer method with validation - # @param [Object] value Value to be assigned - def value=(value) - if value.nil? - fail ArgumentError, 'value cannot be nil' + # Custom attribute writer method checking allowed values (enum). + # @param [Object] color Object to be assigned + def color=(color) + validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"]) + unless validator.valid?(color) + fail ArgumentError, "invalid value for \"color\", must be one of #{validator.allowable_values}." end - - if value > 100 - fail ArgumentError, 'invalid value for "value", must be smaller than or equal to 100.' - end - - if value < 0 - fail ArgumentError, 'invalid value for "value", must be greater than or equal to 0.' - end - - @value = value + @color = color end # Checks equality by comparing each attribute. @@ -161,7 +176,8 @@ def ==(o) self.class == o.class && label == o.label && value == o.value && - unit == o.unit + unit == o.unit && + color == o.color end # @see the `==` method @@ -173,7 +189,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [label, value, unit].hash + [label, value, unit, color].hash end # Builds the object from hash diff --git a/generated/activitysmith_openapi/models/activity_metric_value.rb b/generated/activitysmith_openapi/models/activity_metric_value.rb new file mode 100644 index 0000000..71fd8a7 --- /dev/null +++ b/generated/activitysmith_openapi/models/activity_metric_value.rb @@ -0,0 +1,105 @@ +=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 + module ActivityMetricValue + 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