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,
lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb,
lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person_usecase.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, UsAppToPersonContext, UsAppToPersonInstance, UsAppToPersonList, UsAppToPersonPage, UsAppToPersonUsecaseInstance, UsAppToPersonUsecaseList, UsAppToPersonUsecasePage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext



199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 199

def initialize(version, sid)
    super(version)

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

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

Instance Method Details

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

Access the alpha_senders

Raises:

  • (ArgumentError)


314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 314

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

Delete the ServiceInstance



216
217
218
219
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 216

def delete

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

#fetchServiceInstance

Fetch the ServiceInstance



224
225
226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 224

def fetch

    payload = @version.fetch('GET', @uri)
    ServiceInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



396
397
398
399
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 396

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

Raises:

  • (ArgumentError)


371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 371

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

Raises:

  • (ArgumentError)


333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 333

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



389
390
391
392
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 389

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, usecase: :unset, use_inbound_webhook_on_number: :unset) ⇒ ServiceInstance

Update the ServiceInstance



253
254
255
256
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 253

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, 
    usecase: :unset, 
    use_inbound_webhook_on_number: :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,
        'Usecase' => usecase,
        'UseInboundWebhookOnNumber' => use_inbound_webhook_on_number,
    })

    payload = @version.update('POST', @uri, data: data)
    ServiceInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#us_app_to_person(sid = :unset) ⇒ UsAppToPersonList, UsAppToPersonContext

Access the us_app_to_person

Raises:

  • (ArgumentError)


352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 352

def us_app_to_person(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

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

    unless @us_app_to_person
        @us_app_to_person = UsAppToPersonList.new(
            @version, messaging_service_sid: @solution[:sid], )
    end

 @us_app_to_person
end

#us_app_to_person_usecasesUsAppToPersonUsecaseList, UsAppToPersonUsecaseContext

Access the us_app_to_person_usecases



303
304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 303

def us_app_to_person_usecases
  unless @us_app_to_person_usecases
    @us_app_to_person_usecases = UsAppToPersonUsecaseList.new(
            @version, messaging_service_sid: @solution[:sid], )
  end
  @us_app_to_person_usecases
end