Class: Auth0::Guardian::Factors::Phone::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/auth0/guardian/factors/phone/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



11
12
13
# File 'lib/auth0/guardian/factors/phone/client.rb', line 11

def initialize(client:)
  @client = client
end

Instance Method Details

#get(request_options: {}, **_params) ⇒ Auth0::Types::GetPhoneFactorSettingsResponseContent

TODO: Link this endpoint to relevant documentation when available.

Examples:

client.guardian.factors.phone.get

Parameters:

  • request_options (Hash) (defaults to: {})
  • _params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/auth0/guardian/factors/phone/client.rb', line 253

def get(request_options: {}, **_params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "guardian/factors/phone/settings",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::GetPhoneFactorSettingsResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_message_types(request_options: {}, **_params) ⇒ Auth0::Types::GetGuardianFactorPhoneMessageTypesResponseContent

Retrieve list of phone-type MFA factors (i.e., sms and voice) that are enabled for your tenant.

Examples:

client.guardian.factors.phone.get_message_types

Parameters:

  • request_options (Hash) (defaults to: {})
  • _params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/auth0/guardian/factors/phone/client.rb', line 31

def get_message_types(request_options: {}, **_params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "guardian/factors/phone/message-types",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::GetGuardianFactorPhoneMessageTypesResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_selected_provider(request_options: {}, **_params) ⇒ Auth0::Types::GetGuardianFactorsProviderPhoneResponseContent

Retrieve details of the multi-factor authentication phone provider configured for your tenant.

Examples:

client.guardian.factors.phone.get_selected_provider

Parameters:

  • request_options (Hash) (defaults to: {})
  • _params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/auth0/guardian/factors/phone/client.rb', line 183

def get_selected_provider(request_options: {}, **_params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "guardian/factors/phone/selected-provider",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::GetGuardianFactorsProviderPhoneResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_templates(request_options: {}, **_params) ⇒ Auth0::Types::GetGuardianFactorPhoneTemplatesResponseContent

Retrieve details of the multi-factor authentication enrollment and verification templates for phone-type factors available in your tenant.

Examples:

client.guardian.factors.phone.get_templates

Parameters:

  • request_options (Hash) (defaults to: {})
  • _params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/auth0/guardian/factors/phone/client.rb', line 329

def get_templates(request_options: {}, **_params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "guardian/factors/phone/templates",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::GetGuardianFactorPhoneTemplatesResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_twilio_provider(request_options: {}, **_params) ⇒ Auth0::Types::GetGuardianFactorsProviderPhoneTwilioResponseContent

Retrieve configuration details for a Twilio phone provider that has been set up in your tenant. To learn more, review Configure SMS and Voice Notifications for MFA.

Examples:

client.guardian.factors.phone.get_twilio_provider

Parameters:

  • request_options (Hash) (defaults to: {})
  • _params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/auth0/guardian/factors/phone/client.rb', line 108

def get_twilio_provider(request_options: {}, **_params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "guardian/factors/phone/providers/twilio",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::GetGuardianFactorsProviderPhoneTwilioResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#set(request_options: {}, **params) ⇒ Auth0::Types::SetPhoneFactorSettingsResponseContent

TODO: Link this endpoint to relevant documentation when available.

Examples:

client.guardian.factors.phone.set(
  otp_length: 1,
  otp_expiration_time: 1
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/auth0/guardian/factors/phone/client.rb', line 291

def set(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "guardian/factors/phone/settings",
    body: Auth0::Guardian::Factors::Phone::Types::SetPhoneFactorSettingsRequestContent.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::SetPhoneFactorSettingsResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#set_message_types(request_options: {}, **params) ⇒ Auth0::Types::SetGuardianFactorPhoneMessageTypesResponseContent

Replace the list of phone-type MFA factors (i.e., sms and voice) that are enabled for your tenant.

Examples:

client.guardian.factors.phone.set_message_types(message_types: ["sms"])

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/auth0/guardian/factors/phone/client.rb', line 68

def set_message_types(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "guardian/factors/phone/message-types",
    body: Auth0::Guardian::Factors::Phone::Types::SetGuardianFactorPhoneMessageTypesRequestContent.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::SetGuardianFactorPhoneMessageTypesResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#set_provider(request_options: {}, **params) ⇒ Auth0::Types::SetGuardianFactorsProviderPhoneResponseContent

Examples:

client.guardian.factors.phone.set_provider(provider: "auth0")

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/auth0/guardian/factors/phone/client.rb', line 216

def set_provider(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "guardian/factors/phone/selected-provider",
    body: Auth0::Guardian::Factors::Phone::Types::SetGuardianFactorsProviderPhoneRequestContent.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::SetGuardianFactorsProviderPhoneResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#set_templates(request_options: {}, **params) ⇒ Auth0::Types::SetGuardianFactorPhoneTemplatesResponseContent

Customize the messages sent to complete phone enrollment and verification (subscription required).

Examples:

client.guardian.factors.phone.set_templates(
  enrollment_message: "enrollment_message",
  verification_message: "verification_message"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/auth0/guardian/factors/phone/client.rb', line 367

def set_templates(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "guardian/factors/phone/templates",
    body: Auth0::Guardian::Factors::Phone::Types::SetGuardianFactorPhoneTemplatesRequestContent.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::SetGuardianFactorPhoneTemplatesResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#set_twilio_provider(request_options: {}, **params) ⇒ Auth0::Types::SetGuardianFactorsProviderPhoneTwilioResponseContent

Update the configuration of a Twilio phone provider that has been set up in your tenant. To learn more, review Configure SMS and Voice Notifications for MFA.

Examples:

client.guardian.factors.phone.set_twilio_provider

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/auth0/guardian/factors/phone/client.rb', line 146

def set_twilio_provider(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "guardian/factors/phone/providers/twilio",
    body: Auth0::Guardian::Factors::Phone::Types::SetGuardianFactorsProviderPhoneTwilioRequestContent.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::SetGuardianFactorsProviderPhoneTwilioResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end