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

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



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

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 (FactorTypes) (defaults to: nil)
  • 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 (NotificationPlatforms) (defaults to: :unset)
  • 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 (TotpAlgorithms) (defaults to: :unset)
  • metadata (Object) (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:



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb', line 54

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.create('POST', @uri, data: data, headers: headers)
    NewFactorInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
    )
end

#create_with_metadata(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 NewFactorInstanceMetadata

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 (FactorTypes) (defaults to: nil)
  • 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 (NotificationPlatforms) (defaults to: :unset)
  • 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 (TotpAlgorithms) (defaults to: :unset)
  • metadata (Object) (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:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb', line 120

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    new_factor_instance = NewFactorInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
    )
    NewFactorInstanceMetadata.new(
        @version,
        new_factor_instance,
        response.headers,
        response.status_code
    )
end

#to_sObject

Provide a user friendly representation



179
180
181
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb', line 179

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