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

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/notify/v1/service/notification.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil) ⇒ NotificationInstance

Initialize the NotificationInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this Notification resource.

  • sid (String)

    The SID of the Call resource to fetch.



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 152

def initialize(version, payload , service_sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'account_sid' => payload['account_sid'],
        'service_sid' => payload['service_sid'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'identities' => payload['identities'],
        'tags' => payload['tags'],
        'segments' => payload['segments'],
        'priority' => payload['priority'],
        'ttl' => payload['ttl'] == nil ? payload['ttl'] : payload['ttl'].to_i,
        'title' => payload['title'],
        'body' => payload['body'],
        'sound' => payload['sound'],
        'action' => payload['action'],
        'data' => payload['data'],
        'apn' => payload['apn'],
        'gcm' => payload['gcm'],
        'fcm' => payload['fcm'],
        'sms' => payload['sms'],
        'facebook_messenger' => payload['facebook_messenger'],
        'alexa' => payload['alexa'],
    }
end

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Notification resource.

Returns:



189
190
191
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 189

def 
    @properties['account_sid']
end

#actionString

Returns The actions to display for the notification. For APNS, translates to the ‘aps.category` value. For GCM, translates to the `data.twi_action` value. For SMS, this parameter is not supported and is omitted from deliveries to those channels.

Returns:

  • (String)

    The actions to display for the notification. For APNS, translates to the ‘aps.category` value. For GCM, translates to the `data.twi_action` value. For SMS, this parameter is not supported and is omitted from deliveries to those channels.



255
256
257
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 255

def action
    @properties['action']
end

#alexaHash

Returns Deprecated.

Returns:

  • (Hash)

    Deprecated.



297
298
299
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 297

def alexa
    @properties['alexa']
end

#apnHash

Returns The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS ‘Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed.

Returns:



267
268
269
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 267

def apn
    @properties['apn']
end

#bodyString

Returns The notification text. For FCM and GCM, translates to ‘data.twi_body`. For APNS, translates to `aps.alert.body`. For SMS, translates to `body`. SMS requires either this `body` value, or `media_urls` attribute defined in the `sms` parameter of the notification.

Returns:

  • (String)

    The notification text. For FCM and GCM, translates to ‘data.twi_body`. For APNS, translates to `aps.alert.body`. For SMS, translates to `body`. SMS requires either this `body` value, or `media_urls` attribute defined in the `sms` parameter of the notification.



243
244
245
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 243

def body
    @properties['body']
end

#dataHash

Returns The custom key-value pairs of the notification’s payload. For FCM and GCM, this value translates to ‘data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels.

Returns:

  • (Hash)

    The custom key-value pairs of the notification’s payload. For FCM and GCM, this value translates to ‘data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels.



261
262
263
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 261

def data
    @properties['data']
end

#date_createdTime

Returns The date and time in GMT when the resource was created specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



201
202
203
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 201

def date_created
    @properties['date_created']
end

#facebook_messengerHash

Returns Deprecated.

Returns:

  • (Hash)

    Deprecated.



291
292
293
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 291

def facebook_messenger
    @properties['facebook_messenger']
end

#fcmHash

Returns The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters ‘to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel.

Returns:

  • (Hash)

    The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters ‘to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel.



279
280
281
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 279

def fcm
    @properties['fcm']
end

#gcmHash

Returns The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings. This property maps to the root JSON dictionary. Target parameters ‘to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed.

Returns:

  • (Hash)

    The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings. This property maps to the root JSON dictionary. Target parameters ‘to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed.



273
274
275
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 273

def gcm
    @properties['gcm']
end

#identitiesArray<String>

Returns The list of ‘identity` values of the Users to notify. We will attempt to deliver notifications only to Bindings with an identity in this list.

Returns:

  • (Array<String>)

    The list of ‘identity` values of the Users to notify. We will attempt to deliver notifications only to Bindings with an identity in this list.



207
208
209
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 207

def identities
    @properties['identities']
end

#inspectObject

Provide a detailed, user friendly representation



309
310
311
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 309

def inspect
    "<Twilio.Notify.V1.NotificationInstance>"
end

#priorityPriority

Returns:

  • (Priority)


225
226
227
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 225

def priority
    @properties['priority']
end

#segmentsArray<String>

Returns The list of Segments to notify. The [Segment](www.twilio.com/docs/notify/api/segment-resource) resource is deprecated. Use the ‘tags` property, instead.

Returns:



219
220
221
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 219

def segments
    @properties['segments']
end

#service_sidString

Returns The SID of the [Service](www.twilio.com/docs/notify/api/service-resource) the resource is associated with.

Returns:



195
196
197
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 195

def service_sid
    @properties['service_sid']
end

#sidString

Returns The unique string that we created to identify the Notification resource.

Returns:

  • (String)

    The unique string that we created to identify the Notification resource.



183
184
185
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 183

def sid
    @properties['sid']
end

#smsHash

Returns The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding ‘form` parameter of the Twilio [Message](www.twilio.com/docs/sms/api/message-resource) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array.

Returns:

  • (Hash)

    The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding ‘form` parameter of the Twilio [Message](www.twilio.com/docs/sms/api/message-resource) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array.



285
286
287
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 285

def sms
    @properties['sms']
end

#soundString

Returns The name of the sound to be played for the notification. For FCM and GCM, this Translates to ‘data.twi_sound`. For APNS, this translates to `aps.sound`. SMS does not support this property.

Returns:

  • (String)

    The name of the sound to be played for the notification. For FCM and GCM, this Translates to ‘data.twi_sound`. For APNS, this translates to `aps.sound`. SMS does not support this property.



249
250
251
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 249

def sound
    @properties['sound']
end

#tagsArray<String>

Returns The tags that select the Bindings to notify. Notifications will be attempted only to Bindings that have all of the tags listed in this property.

Returns:

  • (Array<String>)

    The tags that select the Bindings to notify. Notifications will be attempted only to Bindings that have all of the tags listed in this property.



213
214
215
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 213

def tags
    @properties['tags']
end

#titleString

Returns The notification title. For FCM and GCM, this translates to the ‘data.twi_title` value. For APNS, this translates to the `aps.alert.title` value. SMS does not support this property. This field is not visible on iOS phones and tablets but appears on Apple Watch and Android devices.

Returns:

  • (String)

    The notification title. For FCM and GCM, this translates to the ‘data.twi_title` value. For APNS, this translates to the `aps.alert.title` value. SMS does not support this property. This field is not visible on iOS phones and tablets but appears on Apple Watch and Android devices.



237
238
239
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 237

def title
    @properties['title']
end

#to_sObject

Provide a user friendly representation



303
304
305
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 303

def to_s
    "<Twilio.Notify.V1.NotificationInstance>"
end

#ttlString

Returns How long, in seconds, the notification is valid. Can be an integer between 0 and 2,419,200, which is 4 weeks, the default and the maximum supported time to live (TTL). Delivery should be attempted if the device is offline until the TTL elapses. Zero means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. SMS does not support this property.

Returns:

  • (String)

    How long, in seconds, the notification is valid. Can be an integer between 0 and 2,419,200, which is 4 weeks, the default and the maximum supported time to live (TTL). Delivery should be attempted if the device is offline until the TTL elapses. Zero means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. SMS does not support this property.



231
232
233
# File 'lib/twilio-ruby/rest/notify/v1/service/notification.rb', line 231

def ttl
    @properties['ttl']
end