Class: Twilio::REST::Notify::V1::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/notify/v1/service.rb,
lib/twilio-ruby/rest/notify/v1/service/binding.rb,
lib/twilio-ruby/rest/notify/v1/service/notification.rb

Overview

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

Defined Under Namespace

Classes: BindingContext, BindingInstance, BindingList, BindingPage, NotificationInstance, NotificationList, NotificationPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • Version that contains the resource

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



230
231
232
233
234
235
236
237
238
239
240
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 230

def initialize(version, sid)
  super(version)

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

  # Dependents
  @bindings = nil
  @notifications = nil
end

Instance Method Details

#bindings(sid = :unset) ⇒ BindingList, BindingContext

Access the bindings

Returns:

  • if sid was passed.

Raises:



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

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

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

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

  @bindings
end

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • true if delete succeeds, false otherwise



245
246
247
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 245

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

#fetchServiceInstance

Fetch a ServiceInstance

Returns:

  • Fetched ServiceInstance



252
253
254
255
256
257
258
259
260
261
262
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 252

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



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

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

#notificationsNotificationList, NotificationContext

Access the notifications

Returns:



351
352
353
354
355
356
357
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 351

def notifications
  unless @notifications
    @notifications = NotificationList.new(@version, service_sid: @solution[:sid], )
  end

  @notifications
end

#to_sObject

Provide a user friendly representation



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

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

#update(friendly_name: :unset, apn_credential_sid: :unset, gcm_credential_sid: :unset, messaging_service_sid: :unset, facebook_messenger_page_id: :unset, default_apn_notification_protocol_version: :unset, default_gcm_notification_protocol_version: :unset, fcm_credential_sid: :unset, default_fcm_notification_protocol_version: :unset, log_enabled: :unset, alexa_skill_id: :unset, default_alexa_notification_protocol_version: :unset, delivery_callback_url: :unset, delivery_callback_enabled: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

Returns:

  • Updated ServiceInstance



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 302

def update(friendly_name: :unset, apn_credential_sid: :unset, gcm_credential_sid: :unset, messaging_service_sid: :unset, facebook_messenger_page_id: :unset, default_apn_notification_protocol_version: :unset, default_gcm_notification_protocol_version: :unset, fcm_credential_sid: :unset, default_fcm_notification_protocol_version: :unset, log_enabled: :unset, alexa_skill_id: :unset, default_alexa_notification_protocol_version: :unset, delivery_callback_url: :unset, delivery_callback_enabled: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'ApnCredentialSid' => apn_credential_sid,
      'GcmCredentialSid' => gcm_credential_sid,
      'MessagingServiceSid' => messaging_service_sid,
      'FacebookMessengerPageId' => facebook_messenger_page_id,
      'DefaultApnNotificationProtocolVersion' => default_apn_notification_protocol_version,
      'DefaultGcmNotificationProtocolVersion' => default_gcm_notification_protocol_version,
      'FcmCredentialSid' => fcm_credential_sid,
      'DefaultFcmNotificationProtocolVersion' => default_fcm_notification_protocol_version,
      'LogEnabled' => log_enabled,
      'AlexaSkillId' => alexa_skill_id,
      'DefaultAlexaNotificationProtocolVersion' => default_alexa_notification_protocol_version,
      'DeliveryCallbackUrl' => delivery_callback_url,
      'DeliveryCallbackEnabled' => delivery_callback_enabled,
  })

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

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