Class: Twilio::REST::Verify::V2::ServiceContext::EntityContext::NewFactorList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid: nil, identity: nil) ⇒ NewFactorList

Initialize the NewFactorList

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String) (defaults to: nil)

    The unique SID identifier of the Service.

  • identity (String) (defaults to: nil)

    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.


27
28
29
30
31
32
33
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb', line 27

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

Instance Method Details

#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) ⇒ NewFactorInstance

Create the NewFactorInstance

Parameters:

  • friendly_name (String) (defaults to: nil)

    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.

  • factor_type (new_factor.FactorTypes) (defaults to: nil)

    The Type of this Factor. Currently `push` and `totp` are supported.

  • binding_alg (String) (defaults to: :unset)

    The algorithm used when `factor_type` is `push`. Algorithm supported: `ES256`

  • binding_public_key (String) (defaults to: :unset)

    The Ecdsa public key in PKIX, ASN.1 DER format encoded in Base64.

    Required when `factor_type` is `push`

  • config_app_id (String) (defaults to: :unset)

    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`.

  • config_notification_platform (new_factor.NotificationPlatforms) (defaults to: :unset)

    The transport technology used to generate the Notification Token. Can be `apn`, `fcm` or `none`.

    Required when `factor_type` is `push`.

  • config_notification_token (String) (defaults to: :unset)

    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`.

  • config_sdk_version (String) (defaults to: :unset)

    The Verify Push SDK version used to configure the factor

    Required when `factor_type` is `push`

  • binding_secret (String) (defaults to: :unset)

    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`

  • config_time_step (String) (defaults to: :unset)

    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`

  • config_skew (String) (defaults to: :unset)

    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`

  • config_code_length (String) (defaults to: :unset)

    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`

  • config_alg (new_factor.TotpAlgorithms) (defaults to: :unset)

    The algorithm used to derive the TOTP codes. Can be `sha1`, `sha256` or `sha512`. Defaults to `sha1`.

    Used when `factor_type` is `totp`

  • metadata (Hash) (defaults to: :unset)

    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. `“Android”`. Can be up to 1024 characters in length.

Returns:


102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb', line 102

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(),
  })

  payload = @version.create('POST', @uri, data: data)

  NewFactorInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      identity: @solution[:identity],
  )
end

#to_sObject

Provide a user friendly representation


132
133
134
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb', line 132

def to_s
  '#<Twilio.Verify.V2.NewFactorList>'
end