Class: Twilio::REST::Proxy::V1::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/proxy/v1/service.rb,
lib/twilio-ruby/rest/proxy/v1/service/session.rb,
lib/twilio-ruby/rest/proxy/v1/service/short_code.rb,
lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb,
lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb,
lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb,
lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb

Overview

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

Defined Under Namespace

Classes: PhoneNumberContext, PhoneNumberInstance, PhoneNumberList, PhoneNumberPage, SessionContext, SessionInstance, SessionList, SessionPage, ShortCodeContext, ShortCodeInstance, ShortCodeList, ShortCodePage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    A 34 character string that uniquely identifies this Service.



190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 190

def initialize(version, sid)
  super(version)

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

  # Dependents
  @sessions = nil
  @phone_numbers = nil
  @short_codes = nil
end

Instance Method Details

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



221
222
223
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 221

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

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



206
207
208
209
210
211
212
213
214
215
216
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 206

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

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

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

#phone_numbers(sid = :unset) ⇒ PhoneNumberList, PhoneNumberContext

Access the phone_numbers

Returns:

Raises:

  • (ArgumentError)


282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 282

def phone_numbers(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return PhoneNumberContext.new(@version, @solution[:sid], sid, )
  end

  unless @phone_numbers
    @phone_numbers = PhoneNumberList.new(@version, service_sid: @solution[:sid], )
  end

  @phone_numbers
end

#sessions(sid = :unset) ⇒ SessionList, SessionContext

Access the sessions

Returns:

Raises:

  • (ArgumentError)


264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 264

def sessions(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return SessionContext.new(@version, @solution[:sid], sid, )
  end

  unless @sessions
    @sessions = SessionList.new(@version, service_sid: @solution[:sid], )
  end

  @sessions
end

#short_codes(sid = :unset) ⇒ ShortCodeList, ShortCodeContext

Access the short_codes

Returns:

Raises:

  • (ArgumentError)


300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 300

def short_codes(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return ShortCodeContext.new(@version, @solution[:sid], sid, )
  end

  unless @short_codes
    @short_codes = ShortCodeList.new(@version, service_sid: @solution[:sid], )
  end

  @short_codes
end

#to_sObject

Provide a user friendly representation



316
317
318
319
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 316

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

#update(unique_name: :unset, default_ttl: :unset, callback_url: :unset, geo_match_level: :unset, number_selection_behavior: :unset, intercept_callback_url: :unset, out_of_session_callback_url: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

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

    A human readable description of this resource, up to 64 characters.

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

    The default Time to Live for a Session, in seconds.

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

    The URL Twilio will send callbacks to.

  • geo_match_level (service.GeoMatchLevel) (defaults to: :unset)

    Whether to find proxy numbers in the same areacode.

  • number_selection_behavior (service.NumberSelectionBehavior) (defaults to: :unset)

    What behavior to use when choosing a proxy number.

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

    A URL for Twilio call before each Interaction. An error status code will prevent the interaction from continuing.

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

    A URL for Twilio call when a new Interaction has no Session.

Returns:



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 240

def update(unique_name: :unset, default_ttl: :unset, callback_url: :unset, geo_match_level: :unset, number_selection_behavior: :unset, intercept_callback_url: :unset, out_of_session_callback_url: :unset)
  data = Twilio::Values.of({
      'UniqueName' => unique_name,
      'DefaultTtl' => default_ttl,
      'CallbackUrl' => callback_url,
      'GeoMatchLevel' => geo_match_level,
      'NumberSelectionBehavior' => number_selection_behavior,
      'InterceptCallbackUrl' => intercept_callback_url,
      'OutOfSessionCallbackUrl' => out_of_session_callback_url,
  })

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

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