Class: Twilio::REST::Notify::V1::ServiceContext
- Inherits:
-
InstanceContext
- Object
- InstanceContext
- Twilio::REST::Notify::V1::ServiceContext
- Defined in:
- lib/twilio-ruby/rest/notify/v1/service.rb,
lib/twilio-ruby/rest/notify/v1/service/user.rb,
lib/twilio-ruby/rest/notify/v1/service/binding.rb,
lib/twilio-ruby/rest/notify/v1/service/segment.rb,
lib/twilio-ruby/rest/notify/v1/service/notification.rb,
lib/twilio-ruby/rest/notify/v1/service/user/user_binding.rb,
lib/twilio-ruby/rest/notify/v1/service/user/segment_memberships.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, SegmentInstance, SegmentList, SegmentPage, UserContext, UserInstance, UserList, UserPage
Instance Method Summary collapse
-
#bindings(sid = :unset) ⇒ BindingList, BindingContext
Access the bindings.
-
#delete ⇒ Boolean
Deletes the ServiceInstance.
-
#fetch ⇒ ServiceInstance
Fetch a ServiceInstance.
-
#initialize(version, sid) ⇒ ServiceContext
constructor
Initialize the ServiceContext.
-
#notifications ⇒ NotificationList, NotificationContext
Access the notifications.
-
#segments ⇒ SegmentList, SegmentContext
Access the segments.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#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) ⇒ ServiceInstance
Update the ServiceInstance.
-
#users(identity = :unset) ⇒ UserList, UserContext
Access the users.
Constructor Details
#initialize(version, sid) ⇒ ServiceContext
Initialize the ServiceContext
203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 203 def initialize(version, sid) super(version) # Path Solution @solution = {sid: sid, } @uri = "/Services/#{@solution[:sid]}" # Dependents @bindings = nil @notifications = nil @users = nil @segments = nil end |
Instance Method Details
#bindings(sid = :unset) ⇒ BindingList, BindingContext
Access the bindings
287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 287 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 |
#delete ⇒ Boolean
Deletes the ServiceInstance
220 221 222 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 220 def delete @version.delete('delete', @uri) end |
#fetch ⇒ ServiceInstance
Fetch a ServiceInstance
227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 227 def fetch params = Twilio::Values.of({}) payload = @version.fetch( 'GET', @uri, params, ) ServiceInstance.new(@version, payload, sid: @solution[:sid], ) end |
#notifications ⇒ NotificationList, NotificationContext
Access the notifications
305 306 307 308 309 310 311 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 305 def notifications unless @notifications @notifications = NotificationList.new(@version, service_sid: @solution[:sid], ) end @notifications end |
#segments ⇒ SegmentList, SegmentContext
Access the segments
335 336 337 338 339 340 341 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 335 def segments unless @segments @segments = SegmentList.new(@version, service_sid: @solution[:sid], ) end @segments end |
#to_s ⇒ Object
Provide a user friendly representation
345 346 347 348 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 345 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) ⇒ ServiceInstance
Update the ServiceInstance
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 258 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) 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, }) payload = @version.update( 'POST', @uri, data: data, ) ServiceInstance.new(@version, payload, sid: @solution[:sid], ) end |
#users(identity = :unset) ⇒ UserList, UserContext
Access the users
317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 317 def users(identity=:unset) raise ArgumentError, 'identity cannot be nil' if identity.nil? if identity != :unset return UserContext.new(@version, @solution[:sid], identity, ) end unless @users @users = UserList.new(@version, service_sid: @solution[:sid], ) end @users end |