Class: Courier::Resources::Notifications
- Inherits:
-
Object
- Object
- Courier::Resources::Notifications
- Defined in:
- lib/courier/resources/notifications.rb,
lib/courier/resources/notifications/checks.rb
Defined Under Namespace
Classes: Checks
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#archive(id, request_options: {}) ⇒ nil
Archive a notification template.
-
#create(notification:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationTemplateResponse
Some parameter documentations has been truncated, see Models::NotificationCreateParams for more details.
-
#initialize(client:) ⇒ Notifications
constructor
private
A new instance of Notifications.
-
#list(cursor: nil, event_id: nil, notes: nil, request_options: {}) ⇒ Courier::Models::NotificationListResponse
List notification templates in your workspace.
-
#list_versions(id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::NotificationTemplateVersionListResponse
List versions of a notification template.
-
#publish(id, version: nil, request_options: {}) ⇒ nil
Publish a notification template.
-
#put_content(id, content:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Replace the elemental content of a notification template.
-
#put_element(element_id, id:, type:, channels: nil, data: nil, if_: nil, loop_: nil, ref: nil, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Update a single element within a notification template.
-
#put_locale(locale_id, id:, elements:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Set locale-specific content overrides for a notification template.
-
#replace(id, notification:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationTemplateResponse
Some parameter documentations has been truncated, see Models::NotificationReplaceParams for more details.
-
#retrieve(id, version: nil, request_options: {}) ⇒ Courier::Models::NotificationTemplateResponse
Some parameter documentations has been truncated, see Models::NotificationRetrieveParams for more details.
-
#retrieve_content(id, version: nil, request_options: {}) ⇒ Courier::Models::NotificationContentGetResponse, Courier::Models::NotificationGetContent
Some parameter documentations has been truncated, see Models::NotificationRetrieveContentParams for more details.
Constructor Details
#initialize(client:) ⇒ Notifications
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Notifications.
333 334 335 336 |
# File 'lib/courier/resources/notifications.rb', line 333 def initialize(client:) @client = client @checks = Courier::Resources::Notifications::Checks.new(client: client) end |
Instance Attribute Details
#checks ⇒ Courier::Resources::Notifications::Checks (readonly)
7 8 9 |
# File 'lib/courier/resources/notifications.rb', line 7 def checks @checks end |
Instance Method Details
#archive(id, request_options: {}) ⇒ nil
Archive a notification template.
104 105 106 107 108 109 110 111 |
# File 'lib/courier/resources/notifications.rb', line 104 def archive(id, params = {}) @client.request( method: :delete, path: ["notifications/%1$s", id], model: NilClass, options: params[:request_options] ) end |
#create(notification:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationTemplateResponse
Some parameter documentations has been truncated, see Models::NotificationCreateParams for more details.
Create a notification template. Requires all fields in the notification object. Templates are created in draft state by default.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/courier/resources/notifications.rb', line 26 def create(params) parsed, = Courier::NotificationCreateParams.dump_request(params) @client.request( method: :post, path: "notifications", body: parsed, model: Courier::NotificationTemplateResponse, options: ) end |
#list(cursor: nil, event_id: nil, notes: nil, request_options: {}) ⇒ Courier::Models::NotificationListResponse
List notification templates in your workspace.
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/courier/resources/notifications.rb', line 81 def list(params = {}) parsed, = Courier::NotificationListParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "notifications", query: query, model: Courier::Models::NotificationListResponse, options: ) end |
#list_versions(id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::NotificationTemplateVersionListResponse
List versions of a notification template.
128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/courier/resources/notifications.rb', line 128 def list_versions(id, params = {}) parsed, = Courier::NotificationListVersionsParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["notifications/%1$s/versions", id], query: query, model: Courier::NotificationTemplateVersionListResponse, options: ) end |
#publish(id, version: nil, request_options: {}) ⇒ nil
Publish a notification template. Publishes the current draft by default. Pass a version in the request body to publish a specific historical version.
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/courier/resources/notifications.rb', line 154 def publish(id, params = {}) parsed, = Courier::NotificationPublishParams.dump_request(params) @client.request( method: :post, path: ["notifications/%1$s/publish", id], body: parsed, model: NilClass, options: ) end |
#put_content(id, content:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Replace the elemental content of a notification template. Overwrites all elements in the template with the provided content. Only supported for V2 (elemental) templates.
182 183 184 185 186 187 188 189 190 191 |
# File 'lib/courier/resources/notifications.rb', line 182 def put_content(id, params) parsed, = Courier::NotificationPutContentParams.dump_request(params) @client.request( method: :put, path: ["notifications/%1$s/content", id], body: parsed, model: Courier::NotificationContentMutationResponse, options: ) end |
#put_element(element_id, id:, type:, channels: nil, data: nil, if_: nil, loop_: nil, ref: nil, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Update a single element within a notification template. Only supported for V2 (elemental) templates.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/courier/resources/notifications.rb', line 221 def put_element(element_id, params) parsed, = Courier::NotificationPutElementParams.dump_request(params) id = parsed.delete(:id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["notifications/%1$s/elements/%2$s", id, element_id], body: parsed, model: Courier::NotificationContentMutationResponse, options: ) end |
#put_locale(locale_id, id:, elements:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Set locale-specific content overrides for a notification template. Each element override must reference an existing element by ID. Only supported for V2 (elemental) templates.
255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/courier/resources/notifications.rb', line 255 def put_locale(locale_id, params) parsed, = Courier::NotificationPutLocaleParams.dump_request(params) id = parsed.delete(:id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["notifications/%1$s/locales/%2$s", id, locale_id], body: parsed, model: Courier::NotificationContentMutationResponse, options: ) end |
#replace(id, notification:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationTemplateResponse
Some parameter documentations has been truncated, see Models::NotificationReplaceParams for more details.
Replace a notification template. All fields are required.
288 289 290 291 292 293 294 295 296 297 |
# File 'lib/courier/resources/notifications.rb', line 288 def replace(id, params) parsed, = Courier::NotificationReplaceParams.dump_request(params) @client.request( method: :put, path: ["notifications/%1$s", id], body: parsed, model: Courier::NotificationTemplateResponse, options: ) end |
#retrieve(id, version: nil, request_options: {}) ⇒ Courier::Models::NotificationTemplateResponse
Some parameter documentations has been truncated, see Models::NotificationRetrieveParams for more details.
Retrieve a notification template by ID. Returns the published version by default. Pass version=draft to retrieve an unpublished template.
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/courier/resources/notifications.rb', line 54 def retrieve(id, params = {}) parsed, = Courier::NotificationRetrieveParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["notifications/%1$s", id], query: query, model: Courier::NotificationTemplateResponse, options: ) end |
#retrieve_content(id, version: nil, request_options: {}) ⇒ Courier::Models::NotificationContentGetResponse, Courier::Models::NotificationGetContent
Some parameter documentations has been truncated, see Models::NotificationRetrieveContentParams for more details.
Retrieve the content of a notification template. The response shape depends on whether the template uses V1 (blocks/channels) or V2 (elemental) content. Use the ‘version` query parameter to select draft, published, or a specific historical version.
318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/courier/resources/notifications.rb', line 318 def retrieve_content(id, params = {}) parsed, = Courier::NotificationRetrieveContentParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["notifications/%1$s/content", id], query: query, model: Courier::Models::NotificationRetrieveContentResponse, options: ) end |