Class: Twilio::REST::Authy::V1::ServiceContext::EntityContext::FactorContext::ChallengeContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, identity, factor_sid, sid) ⇒ ChallengeContext

Initialize the ChallengeContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The unique SID identifier of the Service.

  • identity (String)

    Customer unique identity for the Entity owner of the Challenge

  • factor_sid (String)

    The unique SID identifier of the Factor.

  • sid (String)

    A 34 character string that uniquely identifies this Challenge. It also allows the keyword ‘latest` to fetch the most recent active Challenge created for a Factor.



125
126
127
128
129
130
131
# File 'lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb', line 125

def initialize(version, service_sid, identity, factor_sid, sid)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, identity: identity, factor_sid: factor_sid, sid: sid, }
  @uri = "/Services/#{@solution[:service_sid]}/Entities/#{@solution[:identity]}/Factors/#{@solution[:factor_sid]}/Challenges/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Deletes the ChallengeInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



136
137
138
# File 'lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb', line 136

def delete
  @version.delete('delete', @uri)
end

#fetchChallengeInstance

Fetch a ChallengeInstance

Returns:



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb', line 143

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  ChallengeInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      identity: @solution[:identity],
      factor_sid: @solution[:factor_sid],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation



195
196
197
198
# File 'lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb', line 195

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Authy.V1.ChallengeContext #{context}>"
end

#to_sObject

Provide a user friendly representation



188
189
190
191
# File 'lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb', line 188

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Authy.V1.ChallengeContext #{context}>"
end

#update(auth_payload: :unset) ⇒ ChallengeInstance

Update the ChallengeInstance

Parameters:

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

    The optional payload needed to verify the Challenge. E.g., a TOTP would use the numeric code.

Returns:



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb', line 167

def update(auth_payload: :unset)
  data = Twilio::Values.of({'AuthPayload' => auth_payload, })

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

  ChallengeInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      identity: @solution[:identity],
      factor_sid: @solution[:factor_sid],
      sid: @solution[:sid],
  )
end