class Twilio::REST::Notify::V1::ServiceContext::NotificationList

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

Public Class Methods

new(version, service_sid: nil) click to toggle source

Initialize the NotificationList @param [Version] version Version that contains the resource @param [String] service_sid The SID of the

{Service}[https://www.twilio.com/docs/notify/api/service-resource] the resource
is associated with.

@return [NotificationList] NotificationList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/notify/v1/service/notification.rb
24 def initialize(version, service_sid: nil)
25   super(version)
26 
27   # Path Solution
28   @solution = {service_sid: service_sid}
29   @uri = "/Services/#{@solution[:service_sid]}/Notifications"
30 end

Public Instance Methods

create(body: :unset, priority: :unset, ttl: :unset, title: :unset, sound: :unset, action: :unset, data: :unset, apn: :unset, gcm: :unset, sms: :unset, facebook_messenger: :unset, fcm: :unset, segment: :unset, alexa: :unset, to_binding: :unset, delivery_callback_url: :unset, identity: :unset, tag: :unset) click to toggle source

Create the NotificationInstance @param [String] body 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.

@param [notification.Priority] priority The priority of the notification. Can

be: `low` or `high` and the default is `high`. A value of `low` optimizes the
client app's battery consumption; however, notifications may be delivered with
unspecified delay. For FCM and GCM, `low` priority is the same as `Normal`
priority. For APNS `low` priority is the same as `5`. A value of `high` sends
the notification immediately, and can wake up a sleeping device. For FCM and
GCM, `high` is the same as `High` priority. For APNS, `high` is a priority `10`.
SMS does not support this property.

@param [String] ttl 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.

@param [String] title 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.

@param [String] sound 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.

@param [String] action 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.

@param [Hash] data 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}[https://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.

@param [Hash] apn 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}[https://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.

@param [Hash] gcm The GCM-specific payload that overrides corresponding

attributes in the generic payload for GCM Bindings.  This property maps to the
root JSON dictionary. See the {GCM
documentation}[https://firebase.google.com/docs/cloud-messaging/http-server-ref]
for more details. 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. GCM also
{reserves certain
keys}[https://firebase.google.com/docs/cloud-messaging/http-server-ref].

@param [Hash] sms 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}[https://www.twilio.com/docs/sms/send-messages] 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.

@param [Hash] facebook_messenger Deprecated. @param [Hash] fcm 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}[https://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}[https://firebase.google.com/docs/cloud-messaging/http-server-ref], which
cannot be used in that channel.

@param [Array] segment The Segment resource is deprecated. Use the `tag`

parameter, instead.

@param [Hash] alexa Deprecated. @param [Array] to_binding The destination address specified as a JSON

string.  Multiple `to_binding` parameters can be included but the total size of
the request entity should not exceed 1MB. This is typically sufficient for
10,000 phone numbers.

@param [String] delivery_callback_url URL to send webhooks. @param [Array] identity The `identity` value that uniquely identifies

the new resource's {User}[https://www.twilio.com/docs/chat/rest/user-resource]
within the {Service}[https://www.twilio.com/docs/notify/api/service-resource].
Delivery will be attempted only to Bindings with an Identity in this list. No
more than 20 items are allowed in this list.

@param [Array] tag A tag that selects the Bindings to notify. Repeat

this parameter to specify more than one tag, up to a total of 5 tags. The
implicit tag `all` is available to notify all Bindings in a Service instance.
Similarly, the implicit tags `apn`, `fcm`, `gcm`, `sms` and `facebook-messenger`
are available to notify all Bindings in a specific channel.

@return [NotificationInstance] Created NotificationInstance

    # File lib/twilio-ruby/rest/notify/v1/service/notification.rb
129 def create(body: :unset, priority: :unset, ttl: :unset, title: :unset, sound: :unset, action: :unset, data: :unset, apn: :unset, gcm: :unset, sms: :unset, facebook_messenger: :unset, fcm: :unset, segment: :unset, alexa: :unset, to_binding: :unset, delivery_callback_url: :unset, identity: :unset, tag: :unset)
130   data = Twilio::Values.of({
131       'Identity' => Twilio.serialize_list(identity) { |e| e },
132       'Tag' => Twilio.serialize_list(tag) { |e| e },
133       'Body' => body,
134       'Priority' => priority,
135       'Ttl' => ttl,
136       'Title' => title,
137       'Sound' => sound,
138       'Action' => action,
139       'Data' => Twilio.serialize_object(data),
140       'Apn' => Twilio.serialize_object(apn),
141       'Gcm' => Twilio.serialize_object(gcm),
142       'Sms' => Twilio.serialize_object(sms),
143       'FacebookMessenger' => Twilio.serialize_object(facebook_messenger),
144       'Fcm' => Twilio.serialize_object(fcm),
145       'Segment' => Twilio.serialize_list(segment) { |e| e },
146       'Alexa' => Twilio.serialize_object(alexa),
147       'ToBinding' => Twilio.serialize_list(to_binding) { |e| e },
148       'DeliveryCallbackUrl' => delivery_callback_url,
149   })
150 
151   payload = @version.create('POST', @uri, data: data)
152 
153   NotificationInstance.new(@version, payload, service_sid: @solution[:service_sid], )
154 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/notify/v1/service/notification.rb
158 def to_s
159   '#<Twilio.Notify.V1.NotificationList>'
160 end