## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true module Twilio module REST class Verify < Domain class V2 < Version class ServiceContext < InstanceContext class EntityContext < InstanceContext class NewFactorList < ListResource ## # Initialize the NewFactorList # @param [Version] version Version that contains the resource # @param [String] service_sid The unique SID identifier of the Service. # @param [String] identity Customer unique identity for the Entity owner of the # Factor. This identifier should be immutable, not PII, length between 8 and 64 # characters, and generated by your external system, such as your user's UUID, # GUID, or SID. It can only contain dash (-) separated alphanumeric characters. # @return [NewFactorList] NewFactorList def initialize(version, service_sid: nil, identity: nil) super(version) # Path Solution @solution = {service_sid: service_sid, identity: identity} @uri = "/Services/#{@solution[:service_sid]}/Entities/#{@solution[:identity]}/Factors" end ## # Create the NewFactorInstance # @param [String] friendly_name The friendly name of this Factor. This can be any # string up to 64 characters, meant for humans to distinguish between Factors. # For `factor_type` `push`, this could be a device name. # For `factor_type` `totp`, this value is used as the “account name” in # constructing the `binding.uri` property. # At the same time, we recommend avoiding providing PII. # @param [new_factor.FactorTypes] factor_type The Type of this Factor. Currently # `push` and `totp` are supported. # @param [String] binding_alg The algorithm used when `factor_type` is `push`. # Algorithm supported: `ES256` # @param [String] binding_public_key The Ecdsa public key in PKIX, ASN.1 DER # format encoded in Base64. # # Required when `factor_type` is `push` # @param [String] config_app_id The ID that uniquely identifies your app in the # Google or Apple store, such as `com.example.myapp`. It can be up to 100 # characters long. # # Required when `factor_type` is `push`. # @param [new_factor.NotificationPlatforms] config_notification_platform The # transport technology used to generate the Notification Token. Can be `apn`, # `fcm` or `none`. # # Required when `factor_type` is `push`. # @param [String] config_notification_token For APN, the device token. For FCM, # the registration token. It is used to send the push notifications. Must be # between 32 and 255 characters long. # # Required when `factor_type` is `push`. # @param [String] config_sdk_version The Verify Push SDK version used to configure # the factor # # Required when `factor_type` is `push` # @param [String] binding_secret The shared secret for TOTP factors encoded in # Base32. This can be provided when creating the Factor, otherwise it will be # generated. # # Used when `factor_type` is `totp` # @param [String] config_time_step Defines how often, in seconds, are TOTP codes # generated. i.e, a new TOTP code is generated every time_step seconds. Must be # between 20 and 60 seconds, inclusive. The default value is defined at the # service level in the property `totp.time_step`. Defaults to 30 seconds if not # configured. # # Used when `factor_type` is `totp` # @param [String] config_skew The number of time-steps, past and future, that are # valid for validation of TOTP codes. Must be between 0 and 2, inclusive. The # default value is defined at the service level in the property `totp.skew`. If # not configured defaults to 1. # # Used when `factor_type` is `totp` # @param [String] config_code_length Number of digits for generated TOTP codes. # Must be between 3 and 8, inclusive. The default value is defined at the service # level in the property `totp.code_length`. If not configured defaults to 6. # # Used when `factor_type` is `totp` # @param [new_factor.TotpAlgorithms] config_alg The algorithm used to derive the # TOTP codes. Can be `sha1`, `sha256` or `sha512`. Defaults to `sha1`. # # Used when `factor_type` is `totp` # @param [Hash] metadata Custom metadata associated with the factor. This is added # by the Device/SDK directly to allow for the inclusion of device information. It # must be a stringified JSON with only strings values eg. `{"os": "Android"}`. Can # be up to 1024 characters in length. # @return [NewFactorInstance] Created NewFactorInstance def create(friendly_name: nil, factor_type: nil, binding_alg: :unset, binding_public_key: :unset, config_app_id: :unset, config_notification_platform: :unset, config_notification_token: :unset, config_sdk_version: :unset, binding_secret: :unset, config_time_step: :unset, config_skew: :unset, config_code_length: :unset, config_alg: :unset, metadata: :unset) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'FactorType' => factor_type, 'Binding.Alg' => binding_alg, 'Binding.PublicKey' => binding_public_key, 'Config.AppId' => config_app_id, 'Config.NotificationPlatform' => config_notification_platform, 'Config.NotificationToken' => config_notification_token, 'Config.SdkVersion' => config_sdk_version, 'Binding.Secret' => binding_secret, 'Config.TimeStep' => config_time_step, 'Config.Skew' => config_skew, 'Config.CodeLength' => config_code_length, 'Config.Alg' => config_alg, 'Metadata' => Twilio.serialize_object(metadata), }) payload = @version.create('POST', @uri, data: data) NewFactorInstance.new( @version, payload, service_sid: @solution[:service_sid], identity: @solution[:identity], ) end ## # Provide a user friendly representation def to_s '#' end end class NewFactorPage < Page ## # Initialize the NewFactorPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [NewFactorPage] NewFactorPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of NewFactorInstance # @param [Hash] payload Payload response from the API # @return [NewFactorInstance] NewFactorInstance def get_instance(payload) NewFactorInstance.new( @version, payload, service_sid: @solution[:service_sid], identity: @solution[:identity], ) end ## # Provide a user friendly representation def to_s '' end end class NewFactorInstance < InstanceResource ## # Initialize the NewFactorInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] service_sid The unique SID identifier of the Service. # @param [String] identity Customer unique identity for the Entity owner of the # Factor. This identifier should be immutable, not PII, length between 8 and 64 # characters, and generated by your external system, such as your user's UUID, # GUID, or SID. It can only contain dash (-) separated alphanumeric characters. # @return [NewFactorInstance] NewFactorInstance def initialize(version, payload, service_sid: nil, identity: nil) super(version) # Marshaled Properties @properties = { 'sid' => payload['sid'], 'account_sid' => payload['account_sid'], 'service_sid' => payload['service_sid'], 'entity_sid' => payload['entity_sid'], 'identity' => payload['identity'], 'binding' => payload['binding'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'friendly_name' => payload['friendly_name'], 'status' => payload['status'], 'factor_type' => payload['factor_type'], 'config' => payload['config'], 'metadata' => payload['metadata'], 'url' => payload['url'], } end ## # @return [String] A string that uniquely identifies this Factor. def sid @properties['sid'] end ## # @return [String] Account Sid. def account_sid @properties['account_sid'] end ## # @return [String] Service Sid. def service_sid @properties['service_sid'] end ## # @return [String] Entity Sid. def entity_sid @properties['entity_sid'] end ## # @return [String] Unique external identifier of the Entity def identity @properties['identity'] end ## # @return [Hash] Binding of the factor def binding @properties['binding'] end ## # @return [Time] The date this Factor was created def date_created @properties['date_created'] end ## # @return [Time] The date this Factor was updated def date_updated @properties['date_updated'] end ## # @return [String] A human readable description of this resource. def friendly_name @properties['friendly_name'] end ## # @return [new_factor.FactorStatuses] The Status of this Factor def status @properties['status'] end ## # @return [new_factor.FactorTypes] The Type of this Factor def factor_type @properties['factor_type'] end ## # @return [Hash] Configurations for a `factor_type`. def config @properties['config'] end ## # @return [Hash] Metadata of the factor. def metadata @properties['metadata'] end ## # @return [String] The URL of this resource. def url @properties['url'] end ## # Provide a user friendly representation def to_s "" end ## # Provide a detailed, user friendly representation def inspect "" end end end end end end end end