diff --git a/lib/openapi_client.rb b/lib/openapi_client.rb index 80d993b..929c68f 100644 --- a/lib/openapi_client.rb +++ b/lib/openapi_client.rb @@ -28,6 +28,7 @@ require_relative 'openapi_client/models/list_paginated_users_response' require_relative 'openapi_client/models/magic_link' require_relative 'openapi_client/models/magic_link_channel' +require_relative 'openapi_client/models/magic_link_language' require_relative 'openapi_client/models/magic_link_response' require_relative 'openapi_client/models/magic_link_type' require_relative 'openapi_client/models/model400_error' diff --git a/lib/openapi_client/models/create_magic_link_request.rb b/lib/openapi_client/models/create_magic_link_request.rb index 7a020fc..92927da 100644 --- a/lib/openapi_client/models/create_magic_link_request.rb +++ b/lib/openapi_client/models/create_magic_link_request.rb @@ -19,7 +19,6 @@ class CreateMagicLinkRequest attr_accessor :email - # language of the email to send (optional) attr_accessor :language # must be a relative url @@ -31,6 +30,7 @@ class CreateMagicLinkRequest attr_accessor :_send + # time to live in minutes attr_accessor :ttl attr_accessor :type @@ -85,7 +85,7 @@ def self.openapi_types { :'channel' => :'MagicLinkChannel', :'email' => :'String', - :'language' => :'String', + :'language' => :'MagicLinkLanguage', :'magic_link_path' => :'String', :'phone' => :'String', :'redirect_url' => :'String', @@ -163,6 +163,10 @@ def initialize(attributes = {}) def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new + if !@ttl.nil? && @ttl < 1 + invalid_properties.push('invalid value for "ttl", must be greater than or equal to 1.') + end + invalid_properties end @@ -170,9 +174,24 @@ def list_invalid_properties # @return true if the model is valid def valid? warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@ttl.nil? && @ttl < 1 true end + # Custom attribute writer method with validation + # @param [Object] ttl Value to be assigned + def ttl=(ttl) + if ttl.nil? + fail ArgumentError, 'ttl cannot be nil' + end + + if ttl < 1 + fail ArgumentError, 'invalid value for "ttl", must be greater than or equal to 1.' + end + + @ttl = ttl + end + # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) diff --git a/lib/openapi_client/models/magic_link.rb b/lib/openapi_client/models/magic_link.rb index 89e5689..2f7007f 100644 --- a/lib/openapi_client/models/magic_link.rb +++ b/lib/openapi_client/models/magic_link.rb @@ -27,6 +27,7 @@ class MagicLink attr_accessor :secret + # time to live in minutes attr_accessor :ttl attr_accessor :type diff --git a/lib/openapi_client/models/magic_link_language.rb b/lib/openapi_client/models/magic_link_language.rb new file mode 100644 index 0000000..1781a3a --- /dev/null +++ b/lib/openapi_client/models/magic_link_language.rb @@ -0,0 +1,45 @@ +=begin +#Passage Management API + +#Passage's management API to manage your Passage apps and users. + +The version of the OpenAPI document: 1 +Contact: support@passage.id +Generated by: https://openapi-generator.tech +Generator version: 7.11.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module OpenapiClient + class MagicLinkLanguage + DE = "de".freeze + EN = "en".freeze + ES = "es".freeze + IT = "it".freeze + PL = "pl".freeze + PT = "pt".freeze + ZH = "zh".freeze + + def self.all_vars + @all_vars ||= [DE, EN, ES, IT, PL, PT, ZH].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if MagicLinkLanguage.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #MagicLinkLanguage" + end + end +end diff --git a/lib/passageidentity/auth.rb b/lib/passageidentity/auth.rb index 22f8262..04794f2 100644 --- a/lib/passageidentity/auth.rb +++ b/lib/passageidentity/auth.rb @@ -93,7 +93,12 @@ def fetch_jwks end def create_magic_link(args, opts) - args['language'] = opts['language'] + language = opts['language'] + if language && !OpenapiClient::MagicLinkLanguage.all_vars.include?(language) + raise ArgumentError, "language must be one of #{OpenapiClient::MagicLinkLanguage.all_vars}" + end + + args['language'] = language args['magic_link_path'] = opts['magic_link_path'] args['redirect_url'] = opts['redirect_url'] args['ttl'] = opts['ttl']