diff --git a/generated/activitysmith_openapi.rb b/generated/activitysmith_openapi.rb index 9928336..21ab24c 100644 --- a/generated/activitysmith_openapi.rb +++ b/generated/activitysmith_openapi.rb @@ -20,6 +20,7 @@ require 'activitysmith_openapi/models/activity_metric' require 'activitysmith_openapi/models/activity_metric_value' require 'activitysmith_openapi/models/alert_payload' +require 'activitysmith_openapi/models/app_icon_badge_count_update_error' require 'activitysmith_openapi/models/app_icon_badge_count_update_request' require 'activitysmith_openapi/models/app_icon_badge_count_update_response' require 'activitysmith_openapi/models/bad_request_error' @@ -59,6 +60,7 @@ require 'activitysmith_openapi/models/rate_limit_error' require 'activitysmith_openapi/models/send_push_notification429_response' require 'activitysmith_openapi/models/stream_content_state' +require 'activitysmith_openapi/models/update_app_icon_badge_count422_response' # APIs require 'activitysmith_openapi/api/app_icon_badges_api' diff --git a/generated/activitysmith_openapi/models/app_icon_badge_count_update_error.rb b/generated/activitysmith_openapi/models/app_icon_badge_count_update_error.rb new file mode 100644 index 0000000..5cc0896 --- /dev/null +++ b/generated/activitysmith_openapi/models/app_icon_badge_count_update_error.rb @@ -0,0 +1,386 @@ +=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 + class AppIconBadgeCountUpdateError + attr_accessor :error + + attr_accessor :code + + attr_accessor :message + + attr_accessor :badge + + attr_accessor :devices_targeted + + attr_accessor :devices_updated + + attr_accessor :users_updated + + # Deprecated compatibility alias for devices_updated. + attr_accessor :devices_notified + + attr_accessor :effective_channel_slugs + + 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 + { + :'error' => :'error', + :'code' => :'code', + :'message' => :'message', + :'badge' => :'badge', + :'devices_targeted' => :'devices_targeted', + :'devices_updated' => :'devices_updated', + :'users_updated' => :'users_updated', + :'devices_notified' => :'devices_notified', + :'effective_channel_slugs' => :'effective_channel_slugs' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'error' => :'String', + :'code' => :'String', + :'message' => :'String', + :'badge' => :'Integer', + :'devices_targeted' => :'Integer', + :'devices_updated' => :'Integer', + :'users_updated' => :'Integer', + :'devices_notified' => :'Integer', + :'effective_channel_slugs' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::AppIconBadgeCountUpdateError` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::AppIconBadgeCountUpdateError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'error') + self.error = attributes[:'error'] + else + self.error = nil + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + else + self.message = nil + end + + if attributes.key?(:'badge') + self.badge = attributes[:'badge'] + else + self.badge = nil + end + + if attributes.key?(:'devices_targeted') + self.devices_targeted = attributes[:'devices_targeted'] + end + + if attributes.key?(:'devices_updated') + self.devices_updated = attributes[:'devices_updated'] + else + self.devices_updated = nil + end + + if attributes.key?(:'users_updated') + self.users_updated = attributes[:'users_updated'] + end + + if attributes.key?(:'devices_notified') + self.devices_notified = attributes[:'devices_notified'] + end + + if attributes.key?(:'effective_channel_slugs') + if (value = attributes[:'effective_channel_slugs']).is_a?(Array) + self.effective_channel_slugs = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @error.nil? + invalid_properties.push('invalid value for "error", error cannot be nil.') + end + + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + if @message.nil? + invalid_properties.push('invalid value for "message", message cannot be nil.') + end + + if @badge.nil? + invalid_properties.push('invalid value for "badge", badge cannot be nil.') + end + + if @badge > 2147483647 + invalid_properties.push('invalid value for "badge", must be smaller than or equal to 2147483647.') + end + + if @badge < 0 + invalid_properties.push('invalid value for "badge", must be greater than or equal to 0.') + end + + if @devices_updated.nil? + invalid_properties.push('invalid value for "devices_updated", devices_updated cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @error.nil? + return false if @code.nil? + code_validator = EnumAttributeValidator.new('String', ["badge_device_disconnected", "badge_update_failed"]) + return false unless code_validator.valid?(@code) + return false if @message.nil? + return false if @badge.nil? + return false if @badge > 2147483647 + return false if @badge < 0 + return false if @devices_updated.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', ["badge_device_disconnected", "badge_update_failed"]) + unless validator.valid?(code) + fail ArgumentError, "invalid value for \"code\", must be one of #{validator.allowable_values}." + end + @code = code + end + + # Custom attribute writer method with validation + # @param [Object] badge Value to be assigned + def badge=(badge) + if badge.nil? + fail ArgumentError, 'badge cannot be nil' + end + + if badge > 2147483647 + fail ArgumentError, 'invalid value for "badge", must be smaller than or equal to 2147483647.' + end + + if badge < 0 + fail ArgumentError, 'invalid value for "badge", must be greater than or equal to 0.' + end + + @badge = badge + 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 && + error == o.error && + code == o.code && + message == o.message && + badge == o.badge && + devices_targeted == o.devices_targeted && + devices_updated == o.devices_updated && + users_updated == o.users_updated && + devices_notified == o.devices_notified && + effective_channel_slugs == o.effective_channel_slugs + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [error, code, message, badge, devices_targeted, devices_updated, users_updated, devices_notified, effective_channel_slugs].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = OpenapiClient.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb b/generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb index 9faa31c..4482afc 100644 --- a/generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb +++ b/generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb @@ -19,8 +19,16 @@ class AppIconBadgeCountUpdateResponse attr_accessor :badge + # Number of devices whose App Icon Badge Count was updated. + attr_accessor :devices_updated + + # Number of account users with at least one updated device. + attr_accessor :users_updated + + # Deprecated compatibility alias for devices_updated. attr_accessor :devices_notified + # Deprecated compatibility alias for users_updated. attr_accessor :users_notified attr_accessor :effective_channel_slugs @@ -32,6 +40,8 @@ def self.attribute_map { :'success' => :'success', :'badge' => :'badge', + :'devices_updated' => :'devices_updated', + :'users_updated' => :'users_updated', :'devices_notified' => :'devices_notified', :'users_notified' => :'users_notified', :'effective_channel_slugs' => :'effective_channel_slugs', @@ -49,6 +59,8 @@ def self.openapi_types { :'success' => :'Boolean', :'badge' => :'Integer', + :'devices_updated' => :'Integer', + :'users_updated' => :'Integer', :'devices_notified' => :'Integer', :'users_notified' => :'Integer', :'effective_channel_slugs' => :'Array', @@ -89,16 +101,24 @@ def initialize(attributes = {}) self.badge = nil end + if attributes.key?(:'devices_updated') + self.devices_updated = attributes[:'devices_updated'] + else + self.devices_updated = nil + end + + if attributes.key?(:'users_updated') + self.users_updated = attributes[:'users_updated'] + else + self.users_updated = nil + end + if attributes.key?(:'devices_notified') self.devices_notified = attributes[:'devices_notified'] - else - self.devices_notified = nil end if attributes.key?(:'users_notified') self.users_notified = attributes[:'users_notified'] - else - self.users_notified = nil end if attributes.key?(:'effective_channel_slugs') @@ -137,12 +157,12 @@ def list_invalid_properties invalid_properties.push('invalid value for "badge", must be greater than or equal to 0.') end - if @devices_notified.nil? - invalid_properties.push('invalid value for "devices_notified", devices_notified cannot be nil.') + if @devices_updated.nil? + invalid_properties.push('invalid value for "devices_updated", devices_updated cannot be nil.') end - if @users_notified.nil? - invalid_properties.push('invalid value for "users_notified", users_notified cannot be nil.') + if @users_updated.nil? + invalid_properties.push('invalid value for "users_updated", users_updated cannot be nil.') end if @effective_channel_slugs.nil? @@ -164,8 +184,8 @@ def valid? return false if @badge.nil? return false if @badge > 2147483647 return false if @badge < 0 - return false if @devices_notified.nil? - return false if @users_notified.nil? + return false if @devices_updated.nil? + return false if @users_updated.nil? return false if @effective_channel_slugs.nil? return false if @timestamp.nil? true @@ -196,6 +216,8 @@ def ==(o) self.class == o.class && success == o.success && badge == o.badge && + devices_updated == o.devices_updated && + users_updated == o.users_updated && devices_notified == o.devices_notified && users_notified == o.users_notified && effective_channel_slugs == o.effective_channel_slugs && @@ -211,7 +233,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [success, badge, devices_notified, users_notified, effective_channel_slugs, timestamp].hash + [success, badge, devices_updated, users_updated, devices_notified, users_notified, effective_channel_slugs, timestamp].hash end # Builds the object from hash diff --git a/generated/activitysmith_openapi/models/live_activity_limit_error.rb b/generated/activitysmith_openapi/models/live_activity_limit_error.rb index c10f24d..52f964c 100644 --- a/generated/activitysmith_openapi/models/live_activity_limit_error.rb +++ b/generated/activitysmith_openapi/models/live_activity_limit_error.rb @@ -21,16 +21,24 @@ class LiveActivityLimitError attr_accessor :limit - # Current number of active Live Activities. + # Highest number of active Live Activities among the targeted devices. attr_accessor :active + # Number of targeted devices that have reached the enforced iOS Live Activity concurrency threshold. Included only when targeted devices have mixed capacity. + attr_accessor :blocked_devices + + # Total number of targeted devices. Included only when targeted devices have mixed capacity. + attr_accessor :targeted_devices + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'error' => :'error', :'message' => :'message', :'limit' => :'limit', - :'active' => :'active' + :'active' => :'active', + :'blocked_devices' => :'blocked_devices', + :'targeted_devices' => :'targeted_devices' } end @@ -45,7 +53,9 @@ def self.openapi_types :'error' => :'String', :'message' => :'String', :'limit' => :'Integer', - :'active' => :'Integer' + :'active' => :'Integer', + :'blocked_devices' => :'Integer', + :'targeted_devices' => :'Integer' } end @@ -93,6 +103,14 @@ def initialize(attributes = {}) else self.active = nil end + + if attributes.key?(:'blocked_devices') + self.blocked_devices = attributes[:'blocked_devices'] + end + + if attributes.key?(:'targeted_devices') + self.targeted_devices = attributes[:'targeted_devices'] + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -138,7 +156,9 @@ def ==(o) error == o.error && message == o.message && limit == o.limit && - active == o.active + active == o.active && + blocked_devices == o.blocked_devices && + targeted_devices == o.targeted_devices end # @see the `==` method @@ -150,7 +170,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [error, message, limit, active].hash + [error, message, limit, active, blocked_devices, targeted_devices].hash end # Builds the object from hash diff --git a/generated/activitysmith_openapi/models/update_app_icon_badge_count422_response.rb b/generated/activitysmith_openapi/models/update_app_icon_badge_count422_response.rb new file mode 100644 index 0000000..3cba603 --- /dev/null +++ b/generated/activitysmith_openapi/models/update_app_icon_badge_count422_response.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 UpdateAppIconBadgeCount422Response + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'AppIconBadgeCountUpdateError', + :'NoRecipientsError' + ] + 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