diff --git a/lib/imagekitio/models/custom_metadata_field_create_params.rb b/lib/imagekitio/models/custom_metadata_field_create_params.rb index 570b94cb..845ef897 100644 --- a/lib/imagekitio/models/custom_metadata_field_create_params.rb +++ b/lib/imagekitio/models/custom_metadata_field_create_params.rb @@ -41,12 +41,6 @@ class CustomMetadataFieldCreateParams < Imagekitio::Internal::Type::BaseModel # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] class Schema < Imagekitio::Internal::Type::BaseModel - # @!attribute type - # Type of the custom metadata field. - # - # @return [Symbol, Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::Type] - required :type, enum: -> { Imagekitio::CustomMetadataFieldCreateParams::Schema::Type } - # @!attribute default_value # The default value for this custom metadata field. This property is only required # if `isValueRequired` property is set to `true`. The value should match the @@ -110,12 +104,16 @@ class Schema < Imagekitio::Internal::Type::BaseModel }, api_name: :selectOptions - # @!method initialize(type:, default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, select_options: nil) + # @!attribute type + # Type of the custom metadata field. + # + # @return [Symbol, Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::Type, nil] + optional :type, enum: -> { Imagekitio::CustomMetadataFieldCreateParams::Schema::Type } + + # @!method initialize(default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, select_options: nil, type: nil) # Some parameter documentations has been truncated, see # {Imagekitio::Models::CustomMetadataFieldCreateParams::Schema} for more details. # - # @param type [Symbol, Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::Type] Type of the custom metadata field. - # # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. This property is only required # # @param is_value_required [Boolean] Sets this custom metadata field as required. Setting custom metadata fields on a @@ -129,24 +127,8 @@ class Schema < Imagekitio::Internal::Type::BaseModel # @param min_value [String, Float] Minimum value of the field. Only set this property if field type is `Date` or `N # # @param select_options [Array] An array of allowed values. This property is only required if `type` property is - - # Type of the custom metadata field. # - # @see Imagekitio::Models::CustomMetadataFieldCreateParams::Schema#type - module Type - extend Imagekitio::Internal::Type::Enum - - TEXT = :Text - TEXTAREA = :Textarea - NUMBER = :Number - DATE = :Date - BOOLEAN = :Boolean - SINGLE_SELECT = :SingleSelect - MULTI_SELECT = :MultiSelect - - # @!method self.values - # @return [Array] - end + # @param type [Symbol, Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::Type] Type of the custom metadata field. # The default value for this custom metadata field. This property is only required # if `isValueRequired` property is set to `true`. The value should match the @@ -232,6 +214,24 @@ module SelectOption # @!method self.variants # @return [Array(String, Float, Boolean)] end + + # Type of the custom metadata field. + # + # @see Imagekitio::Models::CustomMetadataFieldCreateParams::Schema#type + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT = :Text + TEXTAREA = :Textarea + NUMBER = :Number + DATE = :Date + BOOLEAN = :Boolean + SINGLE_SELECT = :SingleSelect + MULTI_SELECT = :MultiSelect + + # @!method self.values + # @return [Array] + end end end end diff --git a/rbi/imagekitio/models/custom_metadata_field_create_params.rbi b/rbi/imagekitio/models/custom_metadata_field_create_params.rbi index a6622776..487e76a3 100644 --- a/rbi/imagekitio/models/custom_metadata_field_create_params.rbi +++ b/rbi/imagekitio/models/custom_metadata_field_create_params.rbi @@ -80,14 +80,6 @@ module Imagekitio ) end - # Type of the custom metadata field. - sig do - returns( - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol - ) - end - attr_accessor :type - # The default value for this custom metadata field. This property is only required # if `isValueRequired` property is set to `true`. The value should match the # `type` of custom metadata field. @@ -196,10 +188,26 @@ module Imagekitio end attr_writer :select_options + # Type of the custom metadata field. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol + ) + ) + end + attr_reader :type + sig do params( type: - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol + ).void + end + attr_writer :type + + sig do + params( default_value: Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants, is_value_required: T::Boolean, @@ -212,12 +220,12 @@ module Imagekitio select_options: T::Array[ Imagekitio::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants - ] + ], + type: + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol ).returns(T.attached_class) end def self.new( - # Type of the custom metadata field. - type:, # The default value for this custom metadata field. This property is only required # if `isValueRequired` property is set to `true`. The value should match the # `type` of custom metadata field. @@ -242,15 +250,15 @@ module Imagekitio min_value: nil, # An array of allowed values. This property is only required if `type` property is # set to `SingleSelect` or `MultiSelect`. - select_options: nil + select_options: nil, + # Type of the custom metadata field. + type: nil ) end sig do override.returns( { - type: - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol, default_value: Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants, is_value_required: T::Boolean, @@ -263,73 +271,15 @@ module Imagekitio select_options: T::Array[ Imagekitio::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants - ] + ], + type: + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol } ) end def to_hash end - # Type of the custom metadata field. - module Type - extend Imagekitio::Internal::Type::Enum - - TaggedSymbol = - T.type_alias do - T.all( - Symbol, - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type - ) - end - OrSymbol = T.type_alias { T.any(Symbol, String) } - - TEXT = - T.let( - :Text, - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol - ) - TEXTAREA = - T.let( - :Textarea, - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol - ) - NUMBER = - T.let( - :Number, - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol - ) - DATE = - T.let( - :Date, - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol - ) - BOOLEAN = - T.let( - :Boolean, - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol - ) - SINGLE_SELECT = - T.let( - :SingleSelect, - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol - ) - MULTI_SELECT = - T.let( - :MultiSelect, - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol - ) - - sig do - override.returns( - T::Array[ - Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol - ] - ) - end - def self.values - end - end - # The default value for this custom metadata field. This property is only required # if `isValueRequired` property is set to `true`. The value should match the # `type` of custom metadata field. @@ -437,6 +387,66 @@ module Imagekitio def self.variants end end + + # Type of the custom metadata field. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TEXT = + T.let( + :Text, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + TEXTAREA = + T.let( + :Textarea, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + NUMBER = + T.let( + :Number, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + DATE = + T.let( + :Date, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + BOOLEAN = + T.let( + :Boolean, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + SINGLE_SELECT = + T.let( + :SingleSelect, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + MULTI_SELECT = + T.let( + :MultiSelect, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ] + ) + end + def self.values + end + end end end end diff --git a/sig/imagekitio/models/custom_metadata_field_create_params.rbs b/sig/imagekitio/models/custom_metadata_field_create_params.rbs index 78f2ab99..3e35db7d 100644 --- a/sig/imagekitio/models/custom_metadata_field_create_params.rbs +++ b/sig/imagekitio/models/custom_metadata_field_create_params.rbs @@ -34,19 +34,17 @@ module Imagekitio type schema = { - type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_, default_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value, is_value_required: bool, max_length: Float, max_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value, min_length: Float, min_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value, - select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option], + type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_ } class Schema < Imagekitio::Internal::Type::BaseModel - attr_accessor type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_ - attr_reader default_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value? def default_value=: ( @@ -83,51 +81,34 @@ module Imagekitio ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] ) -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + attr_reader type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_? + + def type=: ( + Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_ + ) -> Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_ + def initialize: ( - type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_, ?default_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value, ?is_value_required: bool, ?max_length: Float, ?max_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value, ?min_length: Float, ?min_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value, - ?select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + ?select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option], + ?type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_ ) -> void def to_hash: -> { - type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_, default_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value, is_value_required: bool, max_length: Float, max_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value, min_length: Float, min_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value, - select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option], + type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_ } - type type_ = - :Text - | :Textarea - | :Number - | :Date - | :Boolean - | :SingleSelect - | :MultiSelect - - module Type - extend Imagekitio::Internal::Type::Enum - - TEXT: :Text - TEXTAREA: :Textarea - NUMBER: :Number - DATE: :Date - BOOLEAN: :Boolean - SINGLE_SELECT: :SingleSelect - MULTI_SELECT: :MultiSelect - - def self?.values: -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_] - end - type default_value = String | Float @@ -173,6 +154,29 @@ module Imagekitio def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] end + + type type_ = + :Text + | :Textarea + | :Number + | :Date + | :Boolean + | :SingleSelect + | :MultiSelect + + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT: :Text + TEXTAREA: :Textarea + NUMBER: :Number + DATE: :Date + BOOLEAN: :Boolean + SINGLE_SELECT: :SingleSelect + MULTI_SELECT: :MultiSelect + + def self?.values: -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_] + end end end end diff --git a/test/imagekitio/resources/custom_metadata_fields_test.rb b/test/imagekitio/resources/custom_metadata_fields_test.rb index 1d455ad6..7a1d1b98 100644 --- a/test/imagekitio/resources/custom_metadata_fields_test.rb +++ b/test/imagekitio/resources/custom_metadata_fields_test.rb @@ -6,8 +6,7 @@ class Imagekitio::Test::Resources::CustomMetadataFieldsTest < Imagekitio::Test:: def test_create_required_params skip("Mock server tests are disabled") - response = - @image_kit.custom_metadata_fields.create(label: "price", name: "price", schema: {type: :Number}) + response = @image_kit.custom_metadata_fields.create(label: "price", name: "price", schema: {}) assert_pattern do response => Imagekitio::CustomMetadataField