trycourier 4.6.3 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/README.md +1 -1
  4. data/lib/courier/internal/transport/pooled_net_requester.rb +1 -1
  5. data/lib/courier/models/post_tenant_template_publish_request.rb +22 -0
  6. data/lib/courier/models/post_tenant_template_publish_response.rb +34 -0
  7. data/lib/courier/models/put_tenant_template_request.rb +31 -0
  8. data/lib/courier/models/put_tenant_template_response.rb +38 -0
  9. data/lib/courier/models/send_message_params.rb +49 -3
  10. data/lib/courier/models/tenant_template_input.rb +192 -0
  11. data/lib/courier/models/tenants/template_publish_params.rb +22 -0
  12. data/lib/courier/models/tenants/template_replace_params.rb +22 -0
  13. data/lib/courier/models/tenants/templates/version_retrieve_params.rb +30 -0
  14. data/lib/courier/models.rb +10 -0
  15. data/lib/courier/resources/tenants/templates/versions.rb +60 -0
  16. data/lib/courier/resources/tenants/templates.rb +81 -0
  17. data/lib/courier/version.rb +1 -1
  18. data/lib/courier.rb +9 -0
  19. data/rbi/courier/models/post_tenant_template_publish_request.rbi +36 -0
  20. data/rbi/courier/models/post_tenant_template_publish_response.rbi +49 -0
  21. data/rbi/courier/models/put_tenant_template_request.rbi +53 -0
  22. data/rbi/courier/models/put_tenant_template_response.rbi +52 -0
  23. data/rbi/courier/models/send_message_params.rbi +86 -4
  24. data/rbi/courier/models/tenant_template_input.rbi +408 -0
  25. data/rbi/courier/models/tenants/template_publish_params.rbi +40 -0
  26. data/rbi/courier/models/tenants/template_replace_params.rbi +40 -0
  27. data/rbi/courier/models/tenants/templates/version_retrieve_params.rbi +50 -0
  28. data/rbi/courier/models.rbi +12 -0
  29. data/rbi/courier/resources/tenants/templates/versions.rbi +43 -0
  30. data/rbi/courier/resources/tenants/templates.rbi +59 -0
  31. data/sig/courier/models/post_tenant_template_publish_request.rbs +15 -0
  32. data/sig/courier/models/post_tenant_template_publish_response.rbs +22 -0
  33. data/sig/courier/models/put_tenant_template_request.rbs +24 -0
  34. data/sig/courier/models/put_tenant_template_response.rbs +22 -0
  35. data/sig/courier/models/send_message_params.rbs +19 -0
  36. data/sig/courier/models/tenant_template_input.rbs +167 -0
  37. data/sig/courier/models/tenants/template_publish_params.rbs +27 -0
  38. data/sig/courier/models/tenants/template_replace_params.rbs +27 -0
  39. data/sig/courier/models/tenants/templates/version_retrieve_params.rbs +32 -0
  40. data/sig/courier/models.rbs +10 -0
  41. data/sig/courier/resources/tenants/templates/versions.rbs +18 -0
  42. data/sig/courier/resources/tenants/templates.rbs +17 -0
  43. metadata +29 -2
@@ -4,6 +4,9 @@ module Courier
4
4
  module Resources
5
5
  class Tenants
6
6
  class Templates
7
+ # @return [Courier::Resources::Tenants::Templates::Versions]
8
+ attr_reader :versions
9
+
7
10
  # Get a Template in Tenant
8
11
  #
9
12
  # @overload retrieve(template_id, tenant_id:, request_options: {})
@@ -57,11 +60,89 @@ module Courier
57
60
  )
58
61
  end
59
62
 
63
+ # Some parameter documentations has been truncated, see
64
+ # {Courier::Models::Tenants::TemplatePublishParams} for more details.
65
+ #
66
+ # Publishes a specific version of a notification template for a tenant.
67
+ #
68
+ # The template must already exist in the tenant's notification map. If no version
69
+ # is specified, defaults to publishing the "latest" version.
70
+ #
71
+ # @overload publish(template_id, tenant_id:, version: nil, request_options: {})
72
+ #
73
+ # @param template_id [String] Path param: Id of the template to be published.
74
+ #
75
+ # @param tenant_id [String] Path param: Id of the tenant that owns the template.
76
+ #
77
+ # @param version [String] Body param: The version of the template to publish (e.g., "v1", "v2", "latest").
78
+ #
79
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
80
+ #
81
+ # @return [Courier::Models::PostTenantTemplatePublishResponse]
82
+ #
83
+ # @see Courier::Models::Tenants::TemplatePublishParams
84
+ def publish(template_id, params)
85
+ parsed, options = Courier::Tenants::TemplatePublishParams.dump_request(params)
86
+ tenant_id =
87
+ parsed.delete(:tenant_id) do
88
+ raise ArgumentError.new("missing required path argument #{_1}")
89
+ end
90
+ @client.request(
91
+ method: :post,
92
+ path: ["tenants/%1$s/templates/%2$s/publish", tenant_id, template_id],
93
+ body: parsed,
94
+ model: Courier::PostTenantTemplatePublishResponse,
95
+ options: options
96
+ )
97
+ end
98
+
99
+ # Some parameter documentations has been truncated, see
100
+ # {Courier::Models::Tenants::TemplateReplaceParams} for more details.
101
+ #
102
+ # Creates or updates a notification template for a tenant.
103
+ #
104
+ # If the template already exists for the tenant, it will be updated (200).
105
+ # Otherwise, a new template is created (201).
106
+ #
107
+ # Optionally publishes the template immediately if the `published` flag is set to
108
+ # true.
109
+ #
110
+ # @overload replace(template_id, tenant_id:, template:, published: nil, request_options: {})
111
+ #
112
+ # @param template_id [String] Path param: Id of the template to be created or updated.
113
+ #
114
+ # @param tenant_id [String] Path param: Id of the tenant for which to create or update the template.
115
+ #
116
+ # @param template [Courier::Models::TenantTemplateInput] Body param: Template configuration for creating or updating a tenant notificatio
117
+ #
118
+ # @param published [Boolean] Body param: Whether to publish the template immediately after saving. When true,
119
+ #
120
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
121
+ #
122
+ # @return [Courier::Models::PutTenantTemplateResponse]
123
+ #
124
+ # @see Courier::Models::Tenants::TemplateReplaceParams
125
+ def replace(template_id, params)
126
+ parsed, options = Courier::Tenants::TemplateReplaceParams.dump_request(params)
127
+ tenant_id =
128
+ parsed.delete(:tenant_id) do
129
+ raise ArgumentError.new("missing required path argument #{_1}")
130
+ end
131
+ @client.request(
132
+ method: :put,
133
+ path: ["tenants/%1$s/templates/%2$s", tenant_id, template_id],
134
+ body: parsed,
135
+ model: Courier::PutTenantTemplateResponse,
136
+ options: options
137
+ )
138
+ end
139
+
60
140
  # @api private
61
141
  #
62
142
  # @param client [Courier::Client]
63
143
  def initialize(client:)
64
144
  @client = client
145
+ @versions = Courier::Resources::Tenants::Templates::Versions.new(client: client)
65
146
  end
66
147
  end
67
148
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Courier
4
- VERSION = "4.6.3"
4
+ VERSION = "4.7.0"
5
5
  end
data/lib/courier.rb CHANGED
@@ -60,6 +60,8 @@ require_relative "courier/models/subscription_topic_new"
60
60
  require_relative "courier/models/elemental_channel_node"
61
61
  require_relative "courier/models/message_details"
62
62
  require_relative "courier/models/base_template_tenant_association"
63
+ require_relative "courier/models/post_tenant_template_publish_request"
64
+ require_relative "courier/models/put_tenant_template_request"
63
65
  require_relative "courier/models/users/user_token"
64
66
  require_relative "courier/models/airship_profile"
65
67
  require_relative "courier/models/airship_profile_audience"
@@ -182,6 +184,7 @@ require_relative "courier/models/notifications/draft_retrieve_content_params"
182
184
  require_relative "courier/models/pagerduty"
183
185
  require_relative "courier/models/pagerduty_recipient"
184
186
  require_relative "courier/models/paging"
187
+ require_relative "courier/models/post_tenant_template_publish_response"
185
188
  require_relative "courier/models/preference"
186
189
  require_relative "courier/models/preference_status"
187
190
  require_relative "courier/models/profile_create_params"
@@ -199,6 +202,7 @@ require_relative "courier/models/profiles/list_subscribe_params"
199
202
  require_relative "courier/models/profiles/list_subscribe_response"
200
203
  require_relative "courier/models/profile_update_params"
201
204
  require_relative "courier/models/put_subscriptions_recipient"
205
+ require_relative "courier/models/put_tenant_template_response"
202
206
  require_relative "courier/models/recipient_preferences"
203
207
  require_relative "courier/models/request_archive_params"
204
208
  require_relative "courier/models/rule"
@@ -231,7 +235,11 @@ require_relative "courier/models/tenants/preferences/item_delete_params"
231
235
  require_relative "courier/models/tenants/preferences/item_update_params"
232
236
  require_relative "courier/models/tenants/template_list_params"
233
237
  require_relative "courier/models/tenants/template_list_response"
238
+ require_relative "courier/models/tenants/template_publish_params"
239
+ require_relative "courier/models/tenants/template_replace_params"
234
240
  require_relative "courier/models/tenants/template_retrieve_params"
241
+ require_relative "courier/models/tenants/templates/version_retrieve_params"
242
+ require_relative "courier/models/tenant_template_input"
235
243
  require_relative "courier/models/tenant_update_params"
236
244
  require_relative "courier/models/text_style"
237
245
  require_relative "courier/models/token"
@@ -293,6 +301,7 @@ require_relative "courier/resources/tenants"
293
301
  require_relative "courier/resources/tenants/preferences"
294
302
  require_relative "courier/resources/tenants/preferences/items"
295
303
  require_relative "courier/resources/tenants/templates"
304
+ require_relative "courier/resources/tenants/templates/versions"
296
305
  require_relative "courier/resources/translations"
297
306
  require_relative "courier/resources/users"
298
307
  require_relative "courier/resources/users/preferences"
@@ -0,0 +1,36 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PostTenantTemplatePublishRequest < Courier::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Courier::PostTenantTemplatePublishRequest,
10
+ Courier::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # The version of the template to publish (e.g., "v1", "v2", "latest"). If not
15
+ # provided, defaults to "latest".
16
+ sig { returns(T.nilable(String)) }
17
+ attr_reader :version
18
+
19
+ sig { params(version: String).void }
20
+ attr_writer :version
21
+
22
+ # Request body for publishing a tenant template version
23
+ sig { params(version: String).returns(T.attached_class) }
24
+ def self.new(
25
+ # The version of the template to publish (e.g., "v1", "v2", "latest"). If not
26
+ # provided, defaults to "latest".
27
+ version: nil
28
+ )
29
+ end
30
+
31
+ sig { override.returns({ version: String }) }
32
+ def to_hash
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,49 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PostTenantTemplatePublishResponse < Courier::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Courier::PostTenantTemplatePublishResponse,
10
+ Courier::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # The template ID
15
+ sig { returns(String) }
16
+ attr_accessor :id
17
+
18
+ # The timestamp when the template was published
19
+ sig { returns(String) }
20
+ attr_accessor :published_at
21
+
22
+ # The published version of the template
23
+ sig { returns(String) }
24
+ attr_accessor :version
25
+
26
+ # Response from publishing a tenant template
27
+ sig do
28
+ params(id: String, published_at: String, version: String).returns(
29
+ T.attached_class
30
+ )
31
+ end
32
+ def self.new(
33
+ # The template ID
34
+ id:,
35
+ # The timestamp when the template was published
36
+ published_at:,
37
+ # The published version of the template
38
+ version:
39
+ )
40
+ end
41
+
42
+ sig do
43
+ override.returns({ id: String, published_at: String, version: String })
44
+ end
45
+ def to_hash
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,53 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PutTenantTemplateRequest < Courier::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Courier::PutTenantTemplateRequest, Courier::Internal::AnyHash)
9
+ end
10
+
11
+ # Template configuration for creating or updating a tenant notification template
12
+ sig { returns(Courier::TenantTemplateInput) }
13
+ attr_reader :template
14
+
15
+ sig { params(template: Courier::TenantTemplateInput::OrHash).void }
16
+ attr_writer :template
17
+
18
+ # Whether to publish the template immediately after saving. When true, the
19
+ # template becomes the active/published version. When false (default), the
20
+ # template is saved as a draft.
21
+ sig { returns(T.nilable(T::Boolean)) }
22
+ attr_reader :published
23
+
24
+ sig { params(published: T::Boolean).void }
25
+ attr_writer :published
26
+
27
+ # Request body for creating or updating a tenant notification template
28
+ sig do
29
+ params(
30
+ template: Courier::TenantTemplateInput::OrHash,
31
+ published: T::Boolean
32
+ ).returns(T.attached_class)
33
+ end
34
+ def self.new(
35
+ # Template configuration for creating or updating a tenant notification template
36
+ template:,
37
+ # Whether to publish the template immediately after saving. When true, the
38
+ # template becomes the active/published version. When false (default), the
39
+ # template is saved as a draft.
40
+ published: nil
41
+ )
42
+ end
43
+
44
+ sig do
45
+ override.returns(
46
+ { template: Courier::TenantTemplateInput, published: T::Boolean }
47
+ )
48
+ end
49
+ def to_hash
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,52 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PutTenantTemplateResponse < Courier::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Courier::PutTenantTemplateResponse, Courier::Internal::AnyHash)
9
+ end
10
+
11
+ # The template ID
12
+ sig { returns(String) }
13
+ attr_accessor :id
14
+
15
+ # The version of the saved template
16
+ sig { returns(String) }
17
+ attr_accessor :version
18
+
19
+ # The timestamp when the template was published. Only present if the template was
20
+ # published as part of this request.
21
+ sig { returns(T.nilable(String)) }
22
+ attr_accessor :published_at
23
+
24
+ # Response from creating or updating a tenant notification template
25
+ sig do
26
+ params(
27
+ id: String,
28
+ version: String,
29
+ published_at: T.nilable(String)
30
+ ).returns(T.attached_class)
31
+ end
32
+ def self.new(
33
+ # The template ID
34
+ id:,
35
+ # The version of the saved template
36
+ version:,
37
+ # The timestamp when the template was published. Only present if the template was
38
+ # published as part of this request.
39
+ published_at: nil
40
+ )
41
+ end
42
+
43
+ sig do
44
+ override.returns(
45
+ { id: String, version: String, published_at: T.nilable(String) }
46
+ )
47
+ end
48
+ def to_hash
49
+ end
50
+ end
51
+ end
52
+ end
@@ -194,7 +194,19 @@ module Courier
194
194
  Courier::SlackRecipient,
195
195
  Courier::MsTeamsRecipient,
196
196
  Courier::PagerdutyRecipient,
197
- Courier::WebhookRecipient
197
+ Courier::WebhookRecipient,
198
+ T::Array[
199
+ T.any(
200
+ Courier::UserRecipient,
201
+ Courier::AudienceRecipient,
202
+ Courier::ListRecipient,
203
+ Courier::ListPatternRecipient,
204
+ Courier::SlackRecipient,
205
+ Courier::MsTeamsRecipient,
206
+ Courier::PagerdutyRecipient,
207
+ Courier::WebhookRecipient
208
+ )
209
+ ]
198
210
  )
199
211
  )
200
212
  )
@@ -252,7 +264,19 @@ module Courier
252
264
  Courier::SlackRecipient::OrHash,
253
265
  Courier::MsTeamsRecipient::OrHash,
254
266
  Courier::PagerdutyRecipient::OrHash,
255
- Courier::WebhookRecipient::OrHash
267
+ Courier::WebhookRecipient::OrHash,
268
+ T::Array[
269
+ T.any(
270
+ Courier::UserRecipient::OrHash,
271
+ Courier::AudienceRecipient::OrHash,
272
+ Courier::ListRecipient::OrHash,
273
+ Courier::ListPatternRecipient::OrHash,
274
+ Courier::SlackRecipient::OrHash,
275
+ Courier::MsTeamsRecipient::OrHash,
276
+ Courier::PagerdutyRecipient::OrHash,
277
+ Courier::WebhookRecipient::OrHash
278
+ )
279
+ ]
256
280
  )
257
281
  )
258
282
  ).returns(T.attached_class)
@@ -319,7 +343,19 @@ module Courier
319
343
  Courier::SlackRecipient,
320
344
  Courier::MsTeamsRecipient,
321
345
  Courier::PagerdutyRecipient,
322
- Courier::WebhookRecipient
346
+ Courier::WebhookRecipient,
347
+ T::Array[
348
+ T.any(
349
+ Courier::UserRecipient,
350
+ Courier::AudienceRecipient,
351
+ Courier::ListRecipient,
352
+ Courier::ListPatternRecipient,
353
+ Courier::SlackRecipient,
354
+ Courier::MsTeamsRecipient,
355
+ Courier::PagerdutyRecipient,
356
+ Courier::WebhookRecipient
357
+ )
358
+ ]
323
359
  )
324
360
  )
325
361
  }
@@ -1083,9 +1119,47 @@ module Courier
1083
1119
  Courier::SlackRecipient,
1084
1120
  Courier::MsTeamsRecipient,
1085
1121
  Courier::PagerdutyRecipient,
1086
- Courier::WebhookRecipient
1122
+ Courier::WebhookRecipient,
1123
+ T::Array[
1124
+ Courier::SendMessageParams::Message::To::UnionMember8::Variants
1125
+ ]
1126
+ )
1127
+ end
1128
+
1129
+ # A single recipient of the message. Choose one of the following types based on
1130
+ # how you want to identify the recipient: - **User**: Send to a specific user by
1131
+ # user_id, email, or phone number - **Audience**: Send to all users in an
1132
+ # audience - **List**: Send to all users in a list - **List Pattern**: Send to
1133
+ # users in lists matching a pattern - **Slack**: Send via Slack (channel, email,
1134
+ # or user_id) - **MS Teams**: Send via Microsoft Teams - **PagerDuty**: Send via
1135
+ # PagerDuty - **Webhook**: Send via webhook
1136
+ module UnionMember8
1137
+ extend Courier::Internal::Type::Union
1138
+
1139
+ Variants =
1140
+ T.type_alias do
1141
+ T.any(
1142
+ Courier::UserRecipient,
1143
+ Courier::AudienceRecipient,
1144
+ Courier::ListRecipient,
1145
+ Courier::ListPatternRecipient,
1146
+ Courier::SlackRecipient,
1147
+ Courier::MsTeamsRecipient,
1148
+ Courier::PagerdutyRecipient,
1149
+ Courier::WebhookRecipient
1150
+ )
1151
+ end
1152
+
1153
+ sig do
1154
+ override.returns(
1155
+ T::Array[
1156
+ Courier::SendMessageParams::Message::To::UnionMember8::Variants
1157
+ ]
1087
1158
  )
1088
1159
  end
1160
+ def self.variants
1161
+ end
1162
+ end
1089
1163
 
1090
1164
  sig do
1091
1165
  override.returns(
@@ -1094,6 +1168,14 @@ module Courier
1094
1168
  end
1095
1169
  def self.variants
1096
1170
  end
1171
+
1172
+ UnionMember8Array =
1173
+ T.let(
1174
+ Courier::Internal::Type::ArrayOf[
1175
+ union: Courier::SendMessageParams::Message::To::UnionMember8
1176
+ ],
1177
+ Courier::Internal::Type::Converter
1178
+ )
1097
1179
  end
1098
1180
  end
1099
1181
  end