class Twilio::REST::Verify::V2::ServiceContext::EntityContext::ChallengeList

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

Public Class Methods

new(version, service_sid: nil, identity: nil) click to toggle source

Initialize the ChallengeList @param [Version] version Version that contains the resource @param [String] service_sid The unique SID identifier of the Service. @param [String] identity Customer unique identity for the Entity owner of the

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

@return [ChallengeList] ChallengeList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb
27 def initialize(version, service_sid: nil, identity: nil)
28   super(version)
29 
30   # Path Solution
31   @solution = {service_sid: service_sid, identity: identity}
32   @uri = "/Services/#{@solution[:service_sid]}/Entities/#{@solution[:identity]}/Challenges"
33 end

Public Instance Methods

create(factor_sid: nil, expiration_date: :unset, details_message: :unset, details_fields: :unset, hidden_details: :unset, auth_payload: :unset) click to toggle source

Create the ChallengeInstance @param [String] factor_sid The unique SID identifier of the Factor. @param [Time] expiration_date The date-time when this Challenge expires, given

in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. The default value
is five (5) minutes after Challenge creation. The max value is sixty (60)
minutes after creation.

@param [String] details_message Shown to the user when the push notification

arrives. Required when `factor_type` is `push`. Can be up to 256 characters in
length

@param [Array] details_fields A list of objects that describe the Fields

included in the Challenge. Each object contains the label and value of the
field, the label can be up to 36 characters in length and the value can be up to
128 characters in length. Used when `factor_type` is `push`. There can be up to
20 details fields.

@param [Hash] hidden_details Details provided to give context about the

Challenge. Not shown to the end user. It must be a stringified JSON with only
strings values eg. `{"ip": "172.168.1.234"}`. Can be up to 1024 characters in
length

@param [String] auth_payload Optional payload used to verify the Challenge upon

creation. Only used with a Factor of type `totp` to carry the TOTP code that
needs to be verified. For `TOTP` this value must be between 3 and 8 characters
long.

@return [ChallengeInstance] Created ChallengeInstance

   # File lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb
59 def create(factor_sid: nil, expiration_date: :unset, details_message: :unset, details_fields: :unset, hidden_details: :unset, auth_payload: :unset)
60   data = Twilio::Values.of({
61       'FactorSid' => factor_sid,
62       'ExpirationDate' => Twilio.serialize_iso8601_datetime(expiration_date),
63       'Details.Message' => details_message,
64       'Details.Fields' => Twilio.serialize_list(details_fields) { |e| Twilio.serialize_object(e) },
65       'HiddenDetails' => Twilio.serialize_object(hidden_details),
66       'AuthPayload' => auth_payload,
67   })
68 
69   payload = @version.create('POST', @uri, data: data)
70 
71   ChallengeInstance.new(
72       @version,
73       payload,
74       service_sid: @solution[:service_sid],
75       identity: @solution[:identity],
76   )
77 end
each() { |x| ... } click to toggle source

When passed a block, yields ChallengeInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

    # File lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb
140 def each
141   limits = @version.read_limits
142 
143   page = self.page(page_size: limits[:page_size], )
144 
145   @version.stream(page,
146                   limit: limits[:limit],
147                   page_limit: limits[:page_limit]).each {|x| yield x}
148 end
get_page(target_url) click to toggle source

Retrieve a single page of ChallengeInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of ChallengeInstance

    # File lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb
183 def get_page(target_url)
184   response = @version.domain.request(
185       'GET',
186       target_url
187   )
188   ChallengePage.new(@version, response, @solution)
189 end
list(factor_sid: :unset, status: :unset, order: :unset, limit: nil, page_size: nil) click to toggle source

Lists ChallengeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] factor_sid The unique SID identifier of the Factor. @param [challenge.ChallengeStatuses] status The Status of the Challenges to

fetch. One of `pending`, `expired`, `approved` or `denied`.

@param [challenge.ListOrders] order The desired sort order of the Challenges

list. One of `asc` or `desc` for ascending and descending respectively. Defaults
to `asc`.

@param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records.  If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Array] Array of up to limit results

    # File lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb
 96 def list(factor_sid: :unset, status: :unset, order: :unset, limit: nil, page_size: nil)
 97   self.stream(
 98       factor_sid: factor_sid,
 99       status: status,
100       order: order,
101       limit: limit,
102       page_size: page_size
103   ).entries
104 end
page(factor_sid: :unset, status: :unset, order: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of ChallengeInstance records from the API. Request is executed immediately. @param [String] factor_sid The unique SID identifier of the Factor. @param [challenge.ChallengeStatuses] status The Status of the Challenges to

fetch. One of `pending`, `expired`, `approved` or `denied`.

@param [challenge.ListOrders] order The desired sort order of the Challenges

list. One of `asc` or `desc` for ascending and descending respectively. Defaults
to `asc`.

@param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of ChallengeInstance

    # File lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb
163 def page(factor_sid: :unset, status: :unset, order: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
164   params = Twilio::Values.of({
165       'FactorSid' => factor_sid,
166       'Status' => status,
167       'Order' => order,
168       'PageToken' => page_token,
169       'Page' => page_number,
170       'PageSize' => page_size,
171   })
172 
173   response = @version.page('GET', @uri, params: params)
174 
175   ChallengePage.new(@version, response, @solution)
176 end
stream(factor_sid: :unset, status: :unset, order: :unset, limit: nil, page_size: nil) click to toggle source

Streams ChallengeInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] factor_sid The unique SID identifier of the Factor. @param [challenge.ChallengeStatuses] status The Status of the Challenges to

fetch. One of `pending`, `expired`, `approved` or `denied`.

@param [challenge.ListOrders] order The desired sort order of the Challenges

list. One of `asc` or `desc` for ascending and descending respectively. Defaults
to `asc`.

@param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Enumerable] Enumerable that will yield up to limit results

    # File lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb
123 def stream(factor_sid: :unset, status: :unset, order: :unset, limit: nil, page_size: nil)
124   limits = @version.read_limits(limit, page_size)
125 
126   page = self.page(
127       factor_sid: factor_sid,
128       status: status,
129       order: order,
130       page_size: limits[:page_size],
131   )
132 
133   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
134 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb
193 def to_s
194   '#<Twilio.Verify.V2.ChallengeList>'
195 end