Class: Twilio::REST::Messaging::V1::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/messaging/v1/service.rb,
lib/twilio-ruby/rest/messaging/v1/service/short_code.rb,
lib/twilio-ruby/rest/messaging/v1/service/alpha_sender.rb,
lib/twilio-ruby/rest/messaging/v1/service/phone_number.rb

Overview

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

Defined Under Namespace

Classes: AlphaSenderContext, AlphaSenderInstance, AlphaSenderList, AlphaSenderPage, PhoneNumberContext, PhoneNumberInstance, PhoneNumberList, PhoneNumberPage, 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)

    The sid



226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 226

def initialize(version, sid)
  super(version)

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

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

Instance Method Details

#alpha_senders(sid = :unset) ⇒ AlphaSenderList, AlphaSenderContext

Access the alpha_senders

Returns:

Raises:

  • (ArgumentError)


346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 346

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

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

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

  @alpha_senders
end

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



302
303
304
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 302

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

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



287
288
289
290
291
292
293
294
295
296
297
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 287

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

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

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

#inspectObject

Provide a detailed, user friendly representation



369
370
371
372
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 369

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

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

Access the phone_numbers

Returns:

Raises:

  • (ArgumentError)


310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 310

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

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

Access the short_codes

Returns:

Raises:

  • (ArgumentError)


328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 328

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



362
363
364
365
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 362

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

#update(friendly_name: :unset, inbound_request_url: :unset, inbound_method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, sticky_sender: :unset, mms_converter: :unset, smart_encoding: :unset, scan_message_content: :unset, fallback_to_long_code: :unset, area_code_geomatch: :unset, validity_period: :unset, synchronous_validation: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

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

    The friendly_name

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

    The inbound_request_url

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

    The inbound_method

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

    The fallback_url

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

    The fallback_method

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

    The status_callback

  • sticky_sender (Boolean) (defaults to: :unset)

    The sticky_sender

  • mms_converter (Boolean) (defaults to: :unset)

    The mms_converter

  • smart_encoding (Boolean) (defaults to: :unset)

    The smart_encoding

  • scan_message_content (service.ScanMessageContent) (defaults to: :unset)

    The scan_message_content

  • fallback_to_long_code (Boolean) (defaults to: :unset)

    The fallback_to_long_code

  • area_code_geomatch (Boolean) (defaults to: :unset)

    The area_code_geomatch

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

    The validity_period

  • synchronous_validation (Boolean) (defaults to: :unset)

    The synchronous_validation

Returns:



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 257

def update(friendly_name: :unset, inbound_request_url: :unset, inbound_method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, sticky_sender: :unset, mms_converter: :unset, smart_encoding: :unset, scan_message_content: :unset, fallback_to_long_code: :unset, area_code_geomatch: :unset, validity_period: :unset, synchronous_validation: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'InboundRequestUrl' => inbound_request_url,
      'InboundMethod' => inbound_method,
      'FallbackUrl' => fallback_url,
      'FallbackMethod' => fallback_method,
      'StatusCallback' => status_callback,
      'StickySender' => sticky_sender,
      'MmsConverter' => mms_converter,
      'SmartEncoding' => smart_encoding,
      'ScanMessageContent' => scan_message_content,
      'FallbackToLongCode' => fallback_to_long_code,
      'AreaCodeGeomatch' => area_code_geomatch,
      'ValidityPeriod' => validity_period,
      'SynchronousValidation' => synchronous_validation,
  })

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

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