Class: Twilio::REST::Verify::V2::ServiceContext::VerificationContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/verify/v2/service/verification.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ VerificationContext

Initialize the VerificationContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the verification Service to fetch the resource from.

  • sid (String)

    The Twilio-provided string that uniquely identifies the Verification resource to fetch.


146
147
148
149
150
151
152
# File 'lib/twilio-ruby/rest/verify/v2/service/verification.rb', line 146

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

  # Path Solution
  @solution = {service_sid: service_sid, sid: sid, }
  @uri = "/Services/#{@solution[:service_sid]}/Verifications/#{@solution[:sid]}"
end

Instance Method Details

#fetchVerificationInstance

Fetch the VerificationInstance

Returns:


175
176
177
178
179
180
181
182
183
184
# File 'lib/twilio-ruby/rest/verify/v2/service/verification.rb', line 175

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

  VerificationInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation


195
196
197
198
# File 'lib/twilio-ruby/rest/verify/v2/service/verification.rb', line 195

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

#to_sObject

Provide a user friendly representation


188
189
190
191
# File 'lib/twilio-ruby/rest/verify/v2/service/verification.rb', line 188

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

#update(status: nil) ⇒ VerificationInstance

Update the VerificationInstance

Parameters:

  • status (verification.Status) (defaults to: nil)

    The new status of the resource. Can be: `canceled` or `approved`.

Returns:


159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/twilio-ruby/rest/verify/v2/service/verification.rb', line 159

def update(status: nil)
  data = Twilio::Values.of({'Status' => status, })

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

  VerificationInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      sid: @solution[:sid],
  )
end