Class: RelayGrid::Resources::Notifications
- Inherits:
-
Object
- Object
- RelayGrid::Resources::Notifications
- Defined in:
- lib/relaygrid/resources/notifications.rb
Overview
Sending. The developer contract the gem exists for: a user, a template name, and the attributes the template needs.
Constant Summary collapse
- RECIPIENT_ATTRIBUTES =
Recipient details a send may carry alongside the id.
emailbecomes the contact email deliveries resolve their recipient through. %i[first_name middle_name last_name email].freeze
Instance Method Summary collapse
-
#initialize(client) ⇒ Notifications
constructor
A new instance of Notifications.
-
#notify(user:, template:, attributes: {}) ⇒ RelayGrid::SendResult
Send a notification, creating or updating the recipient on the way.
Constructor Details
#initialize(client) ⇒ Notifications
Returns a new instance of Notifications.
12 13 14 |
# File 'lib/relaygrid/resources/notifications.rb', line 12 def initialize(client) @client = client end |
Instance Method Details
#notify(user:, template:, attributes: {}) ⇒ RelayGrid::SendResult
Send a notification, creating or updating the recipient on the way.
44 45 46 47 48 49 50 51 52 |
# File 'lib/relaygrid/resources/notifications.rb', line 44 def notify(user:, template:, attributes: {}) = { message_template_name: template.to_s, message_attributes_attributes: format_attributes(attributes), } .merge!(recipient_params(user)) SendResult.new(@client.post("/api/v1/messages", body: { message: }), client: @client) end |