Class: Auth0::Guardian::Factors::Sms::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



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

def initialize(client:)
  @client = client
end

Instance Method Details

#get_selected_provider(request_options: {}, **params) ⇒ Auth0::Types::GetGuardianFactorsProviderSmsResponseContent

This endpoint has been deprecated. To complete this action, use the <a href=“auth0.com/docs/api/management/v2/guardian/get-phone-providers”>Retrieve phone configuration</a> endpoint instead.

Previous functionality: Retrieve details for the multi-factor authentication SMS provider configured for your tenant.

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:



107
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/sms/client.rb', line 107

def get_selected_provider(request_options: {}, **params)
  Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "guardian/factors/sms/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)
    Auth0::Types::GetGuardianFactorsProviderSmsResponseContent.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::GetGuardianFactorSmsTemplatesResponseContent

This endpoint has been deprecated. To complete this action, use the <a href=“auth0.com/docs/api/management/v2/guardian/get-factor-phone-templates”>Retrieve enrollment and verification phone templates</a> endpoint instead.

Previous function: Retrieve details of SMS enrollment and verification templates configured for your tenant.

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:



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

def get_templates(request_options: {}, **params)
  Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "guardian/factors/sms/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)
    Auth0::Types::GetGuardianFactorSmsTemplatesResponseContent.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::GetGuardianFactorsProviderSmsTwilioResponseContent

Retrieve the <a href=“auth0.com/docs/multifactor-authentication/twilio-configuration”>Twilio SMS provider configuration</a> (subscription required).

A new endpoint is available to retrieve the Twilio configuration related to phone factors (<a href=‘auth0.com/docs/api/management/v2/#!/Guardian/get_twilio’>phone Twilio configuration</a>). It has the same payload as this one. Please use it instead.

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
51
# File 'lib/auth0/guardian/factors/sms/client.rb', line 31

def get_twilio_provider(request_options: {}, **params)
  Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "guardian/factors/sms/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)
    Auth0::Types::GetGuardianFactorsProviderSmsTwilioResponseContent.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::SetGuardianFactorsProviderSmsResponseContent

This endpoint has been deprecated. To complete this action, use the <a href=“auth0.com/docs/api/management/v2/guardian/put-phone-providers”>Update phone configuration</a> endpoint instead.

Previous functionality: Update the multi-factor authentication SMS provider configuration in your tenant.

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:



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

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/sms/selected-provider",
    body: Auth0::Guardian::Factors::Sms::Types::SetGuardianFactorsProviderSmsRequestContent.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)
    Auth0::Types::SetGuardianFactorsProviderSmsResponseContent.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::SetGuardianFactorSmsTemplatesResponseContent

This endpoint has been deprecated. To complete this action, use the <a href=“auth0.com/docs/api/management/v2/guardian/put-factor-phone-templates”>Update enrollment and verification phone templates</a> endpoint instead.

<b>Previous functionality</b>: Customize the messages sent to complete SMS enrollment and verification.

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:



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/auth0/guardian/factors/sms/client.rb', line 221

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/sms/templates",
    body: Auth0::Guardian::Factors::Sms::Types::SetGuardianFactorSmsTemplatesRequestContent.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)
    Auth0::Types::SetGuardianFactorSmsTemplatesResponseContent.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::SetGuardianFactorsProviderSmsTwilioResponseContent

This endpoint has been deprecated. To complete this action, use the <a href=“auth0.com/docs/api/management/v2/guardian/put-twilio”>Update Twilio phone configuration</a> endpoint.

<b>Previous functionality</b>: Update the Twilio SMS provider configuration.

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/sms/client.rb', line 68

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/sms/providers/twilio",
    body: Auth0::Guardian::Factors::Sms::Types::SetGuardianFactorsProviderSmsTwilioRequestContent.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)
    Auth0::Types::SetGuardianFactorsProviderSmsTwilioResponseContent.load(response.body)
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end