Class: Twilio::REST::IpMessaging::V2::ServiceContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v2/service.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/role.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/binding.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_binding.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb

Defined Under Namespace

Classes: BindingContext, BindingInstance, BindingList, BindingPage, ChannelContext, ChannelInstance, ChannelList, ChannelPage, RoleContext, RoleInstance, RoleList, RolePage, UserContext, UserInstance, UserList, UserPage

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



165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 165

def initialize(version, sid)
  super(version)

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

  # Dependents
  @channels = nil
  @roles = nil
  @users = nil
  @bindings = nil
end

Instance Method Details

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

Access the bindings

Returns:

Raises:

  • (ArgumentError)


351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 351

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

#channels(sid = :unset) ⇒ ChannelList, ChannelContext

Access the channels

Returns:

Raises:

  • (ArgumentError)


297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 297

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

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

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

  @channels
end

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



197
198
199
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 197

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

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



182
183
184
185
186
187
188
189
190
191
192
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 182

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

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

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

#roles(sid = :unset) ⇒ RoleList, RoleContext

Access the roles

Returns:

Raises:

  • (ArgumentError)


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

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

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

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

  @roles
end

#to_sObject

Provide a user friendly representation



367
368
369
370
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 367

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

#update(friendly_name: :unset, default_service_role_sid: :unset, default_channel_role_sid: :unset, default_channel_creator_role_sid: :unset, read_status_enabled: :unset, reachability_enabled: :unset, typing_indicator_timeout: :unset, consumption_report_interval: :unset, notifications_new_message_enabled: :unset, notifications_new_message_template: :unset, notifications_new_message_sound: :unset, notifications_new_message_badge_count_enabled: :unset, notifications_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_added_to_channel_sound: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_removed_from_channel_sound: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, notifications_invited_to_channel_sound: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, limits_channel_members: :unset, limits_user_channels: :unset, media_compatibility_message: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, notifications_log_enabled: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

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

    The friendly_name

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

    The default_service_role_sid

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

    The default_channel_role_sid

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

    The default_channel_creator_role_sid

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

    The read_status_enabled

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

    The reachability_enabled

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

    The typing_indicator_timeout

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

    The consumption_report_interval

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

    The notifications.new_message.enabled

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

    The notifications.new_message.template

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

    The notifications.new_message.sound

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

    The notifications.new_message.badge_count_enabled

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

    The notifications.added_to_channel.enabled

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

    The notifications.added_to_channel.template

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

    The notifications.added_to_channel.sound

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

    The notifications.removed_from_channel.enabled

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

    The notifications.removed_from_channel.template

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

    The notifications.removed_from_channel.sound

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

    The notifications.invited_to_channel.enabled

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

    The notifications.invited_to_channel.template

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

    The notifications.invited_to_channel.sound

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

    The pre_webhook_url

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

    The post_webhook_url

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

    The webhook_method

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

    The webhook_filters

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

    The limits.channel_members

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

    The limits.user_channels

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

    The media.compatibility_message

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

    The pre_webhook_retry_count

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

    The post_webhook_retry_count

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

    The notifications.log_enabled

Returns:



249
250
251
252
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
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 249

def update(friendly_name: :unset, default_service_role_sid: :unset, default_channel_role_sid: :unset, default_channel_creator_role_sid: :unset, read_status_enabled: :unset, reachability_enabled: :unset, typing_indicator_timeout: :unset, consumption_report_interval: :unset, notifications_new_message_enabled: :unset, notifications_new_message_template: :unset, notifications_new_message_sound: :unset, notifications_new_message_badge_count_enabled: :unset, notifications_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_added_to_channel_sound: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_removed_from_channel_sound: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, notifications_invited_to_channel_sound: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, limits_channel_members: :unset, limits_user_channels: :unset, media_compatibility_message: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, notifications_log_enabled: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'DefaultServiceRoleSid' => default_service_role_sid,
      'DefaultChannelRoleSid' => default_channel_role_sid,
      'DefaultChannelCreatorRoleSid' => default_channel_creator_role_sid,
      'ReadStatusEnabled' => read_status_enabled,
      'ReachabilityEnabled' => reachability_enabled,
      'TypingIndicatorTimeout' => typing_indicator_timeout,
      'ConsumptionReportInterval' => consumption_report_interval,
      'Notifications.NewMessage.Enabled' => notifications_new_message_enabled,
      'Notifications.NewMessage.Template' => notifications_new_message_template,
      'Notifications.NewMessage.Sound' => notifications_new_message_sound,
      'Notifications.NewMessage.BadgeCountEnabled' => notifications_new_message_badge_count_enabled,
      'Notifications.AddedToChannel.Enabled' => notifications_added_to_channel_enabled,
      'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template,
      'Notifications.AddedToChannel.Sound' => notifications_added_to_channel_sound,
      'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled,
      'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template,
      'Notifications.RemovedFromChannel.Sound' => notifications_removed_from_channel_sound,
      'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled,
      'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template,
      'Notifications.InvitedToChannel.Sound' => notifications_invited_to_channel_sound,
      'PreWebhookUrl' => pre_webhook_url,
      'PostWebhookUrl' => post_webhook_url,
      'WebhookMethod' => webhook_method,
      'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e },
      'Limits.ChannelMembers' => limits_channel_members,
      'Limits.UserChannels' => limits_user_channels,
      'Media.CompatibilityMessage' => media_compatibility_message,
      'PreWebhookRetryCount' => pre_webhook_retry_count,
      'PostWebhookRetryCount' => post_webhook_retry_count,
      'Notifications.LogEnabled' => notifications_log_enabled,
  })

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

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

#users(sid = :unset) ⇒ UserList, UserContext

Access the users

Returns:

Raises:

  • (ArgumentError)


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

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

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

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

  @users
end