trycourier 6.5.0 → 6.6.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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +1 -1
  4. data/lib/courier/models/digest_day_of_week.rb +21 -0
  5. data/lib/courier/models/digest_frequency.rb +21 -0
  6. data/lib/courier/models/journey_conditions_field.rb +11 -1
  7. data/lib/courier/models/journey_node.rb +17 -2
  8. data/lib/courier/models/topic_digest_category.rb +71 -0
  9. data/lib/courier/models/topic_digest_release_request.rb +35 -0
  10. data/lib/courier/models/topic_digest_request.rb +63 -0
  11. data/lib/courier/models/topic_digest_response.rb +66 -0
  12. data/lib/courier/models/topic_digest_schedule_request.rb +93 -0
  13. data/lib/courier/models/topic_digest_schedule_response.rb +103 -0
  14. data/lib/courier/models/users/preference_update_or_create_topic_params.rb +13 -1
  15. data/lib/courier/models/users/topic_preference.rb +12 -1
  16. data/lib/courier/models/workspace_preference_topic_create_request.rb +15 -1
  17. data/lib/courier/models/workspace_preference_topic_get_response.rb +9 -1
  18. data/lib/courier/models/workspace_preference_topic_replace_request.rb +15 -1
  19. data/lib/courier/models/workspace_preferences/topic_delete_digest_params.rb +28 -0
  20. data/lib/courier/models/workspace_preferences/topic_release_digest_params.rb +28 -0
  21. data/lib/courier/models.rb +16 -0
  22. data/lib/courier/resources/digests/schedules.rb +1 -1
  23. data/lib/courier/resources/workspace_preferences/topics.rb +77 -4
  24. data/lib/courier/resources/workspace_preferences.rb +0 -2
  25. data/lib/courier/version.rb +1 -1
  26. data/lib/courier.rb +10 -0
  27. data/rbi/courier/models/digest_day_of_week.rbi +25 -0
  28. data/rbi/courier/models/digest_frequency.rbi +25 -0
  29. data/rbi/courier/models/journey_node.rbi +12 -1
  30. data/rbi/courier/models/topic_digest_category.rbi +116 -0
  31. data/rbi/courier/models/topic_digest_release_request.rbi +51 -0
  32. data/rbi/courier/models/topic_digest_request.rbi +95 -0
  33. data/rbi/courier/models/topic_digest_response.rbi +98 -0
  34. data/rbi/courier/models/topic_digest_schedule_request.rbi +141 -0
  35. data/rbi/courier/models/topic_digest_schedule_response.rbi +159 -0
  36. data/rbi/courier/models/users/preference_update_or_create_topic_params.rbi +16 -0
  37. data/rbi/courier/models/users/topic_preference.rbi +17 -0
  38. data/rbi/courier/models/workspace_preference_topic_create_request.rbi +25 -0
  39. data/rbi/courier/models/workspace_preference_topic_get_response.rbi +13 -0
  40. data/rbi/courier/models/workspace_preference_topic_replace_request.rbi +25 -0
  41. data/rbi/courier/models/workspace_preferences/topic_delete_digest_params.rbi +48 -0
  42. data/rbi/courier/models/workspace_preferences/topic_release_digest_params.rbi +48 -0
  43. data/rbi/courier/models.rbi +16 -0
  44. data/rbi/courier/resources/digests/schedules.rbi +5 -2
  45. data/rbi/courier/resources/workspace_preferences/topics.rbi +72 -2
  46. data/rbi/courier/resources/workspace_preferences.rbi +0 -2
  47. data/sig/courier/models/digest_day_of_week.rbs +26 -0
  48. data/sig/courier/models/digest_frequency.rbs +19 -0
  49. data/sig/courier/models/topic_digest_category.rbs +57 -0
  50. data/sig/courier/models/topic_digest_release_request.rbs +17 -0
  51. data/sig/courier/models/topic_digest_request.rbs +48 -0
  52. data/sig/courier/models/topic_digest_response.rbs +58 -0
  53. data/sig/courier/models/topic_digest_schedule_request.rbs +80 -0
  54. data/sig/courier/models/topic_digest_schedule_response.rbs +96 -0
  55. data/sig/courier/models/users/preference_update_or_create_topic_params.rbs +5 -0
  56. data/sig/courier/models/users/topic_preference.rbs +7 -0
  57. data/sig/courier/models/workspace_preference_topic_create_request.rbs +5 -0
  58. data/sig/courier/models/workspace_preference_topic_get_response.rbs +5 -0
  59. data/sig/courier/models/workspace_preference_topic_replace_request.rbs +5 -0
  60. data/sig/courier/models/workspace_preferences/topic_delete_digest_params.rbs +30 -0
  61. data/sig/courier/models/workspace_preferences/topic_release_digest_params.rbs +34 -0
  62. data/sig/courier/models.rbs +16 -0
  63. data/sig/courier/resources/workspace_preferences/topics.rbs +16 -0
  64. metadata +32 -2
@@ -32,6 +32,18 @@ module Courier
32
32
  # @return [String, nil]
33
33
  optional :description, String, nil?: true
34
34
 
35
+ # @!attribute digest
36
+ # A topic's digest configuration: the template that renders it, the cadences it
37
+ # delivers on, and how collected events are retained.
38
+ #
39
+ # Send `null` for the whole object to turn a digest off, which unlinks the
40
+ # template and removes its schedules. There is no `enabled` flag, and
41
+ # `schedules: []` is rejected, because both states are un-deliverable rather than
42
+ # merely off.
43
+ #
44
+ # @return [Courier::Models::TopicDigestRequest, nil]
45
+ optional :digest, -> { Courier::TopicDigestRequest }, nil?: true
46
+
35
47
  # @!attribute include_unsubscribe_header
36
48
  # Whether to include a list-unsubscribe header on emails for this topic.
37
49
  #
@@ -52,7 +64,7 @@ module Courier
52
64
  # @return [Hash{Symbol=>Object}, nil]
53
65
  optional :topic_data, Courier::Internal::Type::HashOf[Courier::Internal::Type::Unknown], nil?: true
54
66
 
55
- # @!method initialize(default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil)
67
+ # @!method initialize(default_status:, name:, allowed_preferences: nil, description: nil, digest: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil)
56
68
  # Some parameter documentations has been truncated, see
57
69
  # {Courier::Models::WorkspacePreferenceTopicCreateRequest} for more details.
58
70
  #
@@ -66,6 +78,8 @@ module Courier
66
78
  #
67
79
  # @param description [String, nil] Optional description shown under the topic on the hosted preferences page.
68
80
  #
81
+ # @param digest [Courier::Models::TopicDigestRequest, nil] A topic's digest configuration: the template that renders it, the cadences it de
82
+ #
69
83
  # @param include_unsubscribe_header [Boolean, nil] Whether to include a list-unsubscribe header on emails for this topic.
70
84
  #
71
85
  # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels delivered for this topic. Defaults to empty if omitted.
@@ -70,13 +70,19 @@ module Courier
70
70
  # @return [String, nil]
71
71
  optional :description, String, nil?: true
72
72
 
73
+ # @!attribute digest
74
+ # A topic's digest configuration.
75
+ #
76
+ # @return [Courier::Models::TopicDigestResponse, nil]
77
+ optional :digest, -> { Courier::TopicDigestResponse }, nil?: true
78
+
73
79
  # @!attribute updater
74
80
  # Id of the last updater.
75
81
  #
76
82
  # @return [String, nil]
77
83
  optional :updater, String, nil?: true
78
84
 
79
- # @!method initialize(id:, allowed_preferences:, created:, default_status:, include_unsubscribe_header:, name:, routing_options:, topic_data:, updated:, creator: nil, description: nil, updater: nil)
85
+ # @!method initialize(id:, allowed_preferences:, created:, default_status:, include_unsubscribe_header:, name:, routing_options:, topic_data:, updated:, creator: nil, description: nil, digest: nil, updater: nil)
80
86
  # A subscription preference topic in your workspace.
81
87
  #
82
88
  # @param id [String] The preference topic id.
@@ -101,6 +107,8 @@ module Courier
101
107
  #
102
108
  # @param description [String, nil] Optional description shown under the topic on the hosted preferences page.
103
109
  #
110
+ # @param digest [Courier::Models::TopicDigestResponse, nil] A topic's digest configuration.
111
+ #
104
112
  # @param updater [String, nil] Id of the last updater.
105
113
 
106
114
  # A preference control a recipient may customize for a topic.
@@ -32,6 +32,18 @@ module Courier
32
32
  # @return [String, nil]
33
33
  optional :description, String, nil?: true
34
34
 
35
+ # @!attribute digest
36
+ # A topic's digest configuration: the template that renders it, the cadences it
37
+ # delivers on, and how collected events are retained.
38
+ #
39
+ # Send `null` for the whole object to turn a digest off, which unlinks the
40
+ # template and removes its schedules. There is no `enabled` flag, and
41
+ # `schedules: []` is rejected, because both states are un-deliverable rather than
42
+ # merely off.
43
+ #
44
+ # @return [Courier::Models::TopicDigestRequest, nil]
45
+ optional :digest, -> { Courier::TopicDigestRequest }, nil?: true
46
+
35
47
  # @!attribute include_unsubscribe_header
36
48
  # Whether to include a list-unsubscribe header on emails for this topic.
37
49
  #
@@ -52,7 +64,7 @@ module Courier
52
64
  # @return [Hash{Symbol=>Object}, nil]
53
65
  optional :topic_data, Courier::Internal::Type::HashOf[Courier::Internal::Type::Unknown], nil?: true
54
66
 
55
- # @!method initialize(default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil)
67
+ # @!method initialize(default_status:, name:, allowed_preferences: nil, description: nil, digest: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil)
56
68
  # Some parameter documentations has been truncated, see
57
69
  # {Courier::Models::WorkspacePreferenceTopicReplaceRequest} for more details.
58
70
  #
@@ -67,6 +79,8 @@ module Courier
67
79
  #
68
80
  # @param description [String, nil] Optional description shown under the topic on the hosted preferences page. Omit
69
81
  #
82
+ # @param digest [Courier::Models::TopicDigestRequest, nil] A topic's digest configuration: the template that renders it, the cadences it de
83
+ #
70
84
  # @param include_unsubscribe_header [Boolean, nil] Whether to include a list-unsubscribe header on emails for this topic.
71
85
  #
72
86
  # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels delivered for this topic. Omit to clear.
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ module WorkspacePreferences
6
+ # @see Courier::Resources::WorkspacePreferences::Topics#delete_digest
7
+ class TopicDeleteDigestParams < Courier::Internal::Type::BaseModel
8
+ extend Courier::Internal::Type::RequestParameters::Converter
9
+ include Courier::Internal::Type::RequestParameters
10
+
11
+ # @!attribute section_id
12
+ #
13
+ # @return [String]
14
+ required :section_id, String
15
+
16
+ # @!attribute topic_id
17
+ #
18
+ # @return [String]
19
+ required :topic_id, String
20
+
21
+ # @!method initialize(section_id:, topic_id:, request_options: {})
22
+ # @param section_id [String]
23
+ # @param topic_id [String]
24
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ module WorkspacePreferences
6
+ # @see Courier::Resources::WorkspacePreferences::Topics#release_digest
7
+ class TopicReleaseDigestParams < Courier::Models::TopicDigestReleaseRequest
8
+ extend Courier::Internal::Type::RequestParameters::Converter
9
+ include Courier::Internal::Type::RequestParameters
10
+
11
+ # @!attribute section_id
12
+ #
13
+ # @return [String]
14
+ required :section_id, String
15
+
16
+ # @!attribute topic_id
17
+ #
18
+ # @return [String]
19
+ required :topic_id, String
20
+
21
+ # @!method initialize(section_id:, topic_id:, request_options: {})
22
+ # @param section_id [String]
23
+ # @param topic_id [String]
24
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
25
+ end
26
+ end
27
+ end
28
+ end
@@ -187,6 +187,10 @@ module Courier
187
187
 
188
188
  DigestCategory = Courier::Models::DigestCategory
189
189
 
190
+ DigestDayOfWeek = Courier::Models::DigestDayOfWeek
191
+
192
+ DigestFrequency = Courier::Models::DigestFrequency
193
+
190
194
  DigestInstance = Courier::Models::DigestInstance
191
195
 
192
196
  DigestInstanceListResponse = Courier::Models::DigestInstanceListResponse
@@ -643,6 +647,18 @@ module Courier
643
647
 
644
648
  Token = Courier::Models::Token
645
649
 
650
+ TopicDigestCategory = Courier::Models::TopicDigestCategory
651
+
652
+ TopicDigestReleaseRequest = Courier::Models::TopicDigestReleaseRequest
653
+
654
+ TopicDigestRequest = Courier::Models::TopicDigestRequest
655
+
656
+ TopicDigestResponse = Courier::Models::TopicDigestResponse
657
+
658
+ TopicDigestScheduleRequest = Courier::Models::TopicDigestScheduleRequest
659
+
660
+ TopicDigestScheduleResponse = Courier::Models::TopicDigestScheduleResponse
661
+
646
662
  TranslationRetrieveParams = Courier::Models::TranslationRetrieveParams
647
663
 
648
664
  TranslationUpdateParams = Courier::Models::TranslationUpdateParams
@@ -45,7 +45,7 @@ module Courier
45
45
  #
46
46
  # @overload release(schedule_id, request_options: {})
47
47
  #
48
- # @param schedule_id [String] The ID of the digest schedule to release, in the form `sch/{uuid}`. The value mu
48
+ # @param schedule_id [String] The ID of the digest schedule to release. Newer schedules are `sch_01m26xfcn3end
49
49
  #
50
50
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
51
51
  #
@@ -3,8 +3,6 @@
3
3
  module Courier
4
4
  module Resources
5
5
  class WorkspacePreferences
6
- # Manage the workspace catalog of subscription topics, the sections that group
7
- # them, and publishing the preference page.
8
6
  class Topics
9
7
  # Some parameter documentations has been truncated, see
10
8
  # {Courier::Models::WorkspacePreferences::TopicCreateParams} for more details.
@@ -12,7 +10,7 @@ module Courier
12
10
  # Creates a subscription topic inside a workspace preference. The default status
13
11
  # sets whether users start opted in, opted out, or required.
14
12
  #
15
- # @overload create(section_id, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {})
13
+ # @overload create(section_id, default_status:, name:, allowed_preferences: nil, description: nil, digest: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {})
16
14
  #
17
15
  # @param section_id [String] Path param: Id of the workspace preference to create the topic in.
18
16
  #
@@ -24,6 +22,8 @@ module Courier
24
22
  #
25
23
  # @param description [String, nil] Body param: Optional description shown under the topic on the hosted preferences
26
24
  #
25
+ # @param digest [Courier::Models::TopicDigestRequest, nil] Body param: A topic's digest configuration: the template that renders it, the ca
26
+ #
27
27
  # @param include_unsubscribe_header [Boolean, nil] Body param: Whether to include a list-unsubscribe header on emails for this topi
28
28
  #
29
29
  # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Body param: Default channels delivered for this topic. Defaults to empty if omit
@@ -130,13 +130,84 @@ module Courier
130
130
  )
131
131
  end
132
132
 
133
+ # Turn off a topic's digest, leaving the topic itself in place. The template is
134
+ # unlinked and the digest's schedules are removed along with their delivery rules.
135
+ # Equivalent to sending `digest: null` on a topic replace.
136
+ #
137
+ # @overload delete_digest(topic_id, section_id:, request_options: {})
138
+ #
139
+ # @param topic_id [String] The preference topic whose digest to turn off.
140
+ #
141
+ # @param section_id [String] The preference section containing the topic.
142
+ #
143
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
144
+ #
145
+ # @return [nil]
146
+ #
147
+ # @see Courier::Models::WorkspacePreferences::TopicDeleteDigestParams
148
+ def delete_digest(topic_id, params)
149
+ parsed, options = Courier::WorkspacePreferences::TopicDeleteDigestParams.dump_request(params)
150
+ section_id =
151
+ parsed.delete(:section_id) do
152
+ raise ArgumentError.new("missing required path argument #{_1}")
153
+ end
154
+ @client.request(
155
+ method: :delete,
156
+ path: ["preferences/sections/%1$s/topics/%2$s/digest", section_id, topic_id],
157
+ model: NilClass,
158
+ options: options
159
+ )
160
+ end
161
+
162
+ # Some parameter documentations has been truncated, see
163
+ # {Courier::Models::WorkspacePreferences::TopicReleaseDigestParams} for more
164
+ # details.
165
+ #
166
+ # Send one recipient's held digest now, instead of waiting for its schedule. Use
167
+ # it to preview what a digest will look like, or to let someone flush their own.
168
+ #
169
+ # Keyed on the topic because that is how a held digest is stored: one per
170
+ # recipient per topic, with the schedule recorded on it rather than part of its
171
+ # identity. To flush every recipient on a schedule instead, use
172
+ # `POST /digests/schedules/{schedule_id}/trigger`.
173
+ #
174
+ # @overload release_digest(topic_id, section_id:, user_id:, tenant_id: nil, request_options: {})
175
+ #
176
+ # @param topic_id [String] Path param: The preference topic whose digest to release.
177
+ #
178
+ # @param section_id [String] Path param: The preference section containing the topic.
179
+ #
180
+ # @param user_id [String] Body param: The recipient whose digest to release. Required: there is no "releas
181
+ #
182
+ # @param tenant_id [String] Body param: The recipient's tenant, when they were sent to as part of one -- the
183
+ #
184
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
185
+ #
186
+ # @return [nil]
187
+ #
188
+ # @see Courier::Models::WorkspacePreferences::TopicReleaseDigestParams
189
+ def release_digest(topic_id, params)
190
+ parsed, options = Courier::WorkspacePreferences::TopicReleaseDigestParams.dump_request(params)
191
+ section_id =
192
+ parsed.delete(:section_id) do
193
+ raise ArgumentError.new("missing required path argument #{_1}")
194
+ end
195
+ @client.request(
196
+ method: :post,
197
+ path: ["preferences/sections/%1$s/topics/%2$s/digest/release", section_id, topic_id],
198
+ body: parsed,
199
+ model: NilClass,
200
+ options: options
201
+ )
202
+ end
203
+
133
204
  # Some parameter documentations has been truncated, see
134
205
  # {Courier::Models::WorkspacePreferences::TopicReplaceParams} for more details.
135
206
  #
136
207
  # Replace a topic within a workspace preference. Full document replacement;
137
208
  # missing optional fields are cleared. Same 404 rules as GET.
138
209
  #
139
- # @overload replace(topic_id, section_id:, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {})
210
+ # @overload replace(topic_id, section_id:, default_status:, name:, allowed_preferences: nil, description: nil, digest: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {})
140
211
  #
141
212
  # @param topic_id [String] Path param: Id of the subscription preference topic.
142
213
  #
@@ -150,6 +221,8 @@ module Courier
150
221
  #
151
222
  # @param description [String, nil] Body param: Optional description shown under the topic on the hosted preferences
152
223
  #
224
+ # @param digest [Courier::Models::TopicDigestRequest, nil] Body param: A topic's digest configuration: the template that renders it, the ca
225
+ #
153
226
  # @param include_unsubscribe_header [Boolean, nil] Body param: Whether to include a list-unsubscribe header on emails for this topi
154
227
  #
155
228
  # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Body param: Default channels delivered for this topic. Omit to clear.
@@ -5,8 +5,6 @@ module Courier
5
5
  # Manage the workspace catalog of subscription topics, the sections that group
6
6
  # them, and publishing the preference page.
7
7
  class WorkspacePreferences
8
- # Manage the workspace catalog of subscription topics, the sections that group
9
- # them, and publishing the preference page.
10
8
  # @return [Courier::Resources::WorkspacePreferences::Topics]
11
9
  attr_reader :topics
12
10
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Courier
4
- VERSION = "6.5.0"
4
+ VERSION = "6.6.0"
5
5
  end
data/lib/courier.rb CHANGED
@@ -94,6 +94,7 @@ require_relative "courier/models/workspace_preference_create_request"
94
94
  require_relative "courier/models/publish_preferences_request"
95
95
  require_relative "courier/models/workspace_preference_replace_request"
96
96
  require_relative "courier/models/workspace_preference_topic_create_request"
97
+ require_relative "courier/models/topic_digest_release_request"
97
98
  require_relative "courier/models/workspace_preference_topic_replace_request"
98
99
  require_relative "courier/models/airship_profile"
99
100
  require_relative "courier/models/airship_profile_audience"
@@ -175,6 +176,8 @@ require_relative "courier/models/check"
175
176
  require_relative "courier/models/default_preferences"
176
177
  require_relative "courier/models/device_type"
177
178
  require_relative "courier/models/digest_category"
179
+ require_relative "courier/models/digest_day_of_week"
180
+ require_relative "courier/models/digest_frequency"
178
181
  require_relative "courier/models/digest_instance"
179
182
  require_relative "courier/models/digest_instance_list_response"
180
183
  require_relative "courier/models/digests/schedule_list_instances_params"
@@ -421,6 +424,11 @@ require_relative "courier/models/tenant_update_params"
421
424
  require_relative "courier/models/text_style"
422
425
  require_relative "courier/models/timeouts"
423
426
  require_relative "courier/models/token"
427
+ require_relative "courier/models/topic_digest_category"
428
+ require_relative "courier/models/topic_digest_request"
429
+ require_relative "courier/models/topic_digest_response"
430
+ require_relative "courier/models/topic_digest_schedule_request"
431
+ require_relative "courier/models/topic_digest_schedule_response"
424
432
  require_relative "courier/models/translation_retrieve_params"
425
433
  require_relative "courier/models/translation_retrieve_response"
426
434
  require_relative "courier/models/translation_update_params"
@@ -473,7 +481,9 @@ require_relative "courier/models/workspace_preference_replace_params"
473
481
  require_relative "courier/models/workspace_preference_retrieve_params"
474
482
  require_relative "courier/models/workspace_preferences/topic_archive_params"
475
483
  require_relative "courier/models/workspace_preferences/topic_create_params"
484
+ require_relative "courier/models/workspace_preferences/topic_delete_digest_params"
476
485
  require_relative "courier/models/workspace_preferences/topic_list_params"
486
+ require_relative "courier/models/workspace_preferences/topic_release_digest_params"
477
487
  require_relative "courier/models/workspace_preferences/topic_replace_params"
478
488
  require_relative "courier/models/workspace_preferences/topic_retrieve_params"
479
489
  require_relative "courier/models/workspace_preference_topic_get_response"
@@ -0,0 +1,25 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ # A day of the week. Accepted case-insensitively, returned lowercase.
6
+ module DigestDayOfWeek
7
+ extend Courier::Internal::Type::Enum
8
+
9
+ TaggedSymbol = T.type_alias { T.all(Symbol, Courier::DigestDayOfWeek) }
10
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
11
+
12
+ SUNDAY = T.let(:sunday, Courier::DigestDayOfWeek::TaggedSymbol)
13
+ MONDAY = T.let(:monday, Courier::DigestDayOfWeek::TaggedSymbol)
14
+ TUESDAY = T.let(:tuesday, Courier::DigestDayOfWeek::TaggedSymbol)
15
+ WEDNESDAY = T.let(:wednesday, Courier::DigestDayOfWeek::TaggedSymbol)
16
+ THURSDAY = T.let(:thursday, Courier::DigestDayOfWeek::TaggedSymbol)
17
+ FRIDAY = T.let(:friday, Courier::DigestDayOfWeek::TaggedSymbol)
18
+ SATURDAY = T.let(:saturday, Courier::DigestDayOfWeek::TaggedSymbol)
19
+
20
+ sig { override.returns(T::Array[Courier::DigestDayOfWeek::TaggedSymbol]) }
21
+ def self.values
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ # How often a digest is delivered. `instant` delivers immediately without
6
+ # batching, and is the one value that takes no `time`.
7
+ module DigestFrequency
8
+ extend Courier::Internal::Type::Enum
9
+
10
+ TaggedSymbol = T.type_alias { T.all(Symbol, Courier::DigestFrequency) }
11
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
12
+
13
+ INSTANT = T.let(:instant, Courier::DigestFrequency::TaggedSymbol)
14
+ DAILY = T.let(:daily, Courier::DigestFrequency::TaggedSymbol)
15
+ WEEKDAYS = T.let(:weekdays, Courier::DigestFrequency::TaggedSymbol)
16
+ WEEKLY = T.let(:weekly, Courier::DigestFrequency::TaggedSymbol)
17
+ CUSTOM_DAYS = T.let(:custom_days, Courier::DigestFrequency::TaggedSymbol)
18
+ MONTHLY = T.let(:monthly, Courier::DigestFrequency::TaggedSymbol)
19
+
20
+ sig { override.returns(T::Array[Courier::DigestFrequency::TaggedSymbol]) }
21
+ def self.values
22
+ end
23
+ end
24
+ end
25
+ end
@@ -398,7 +398,18 @@ module Courier
398
398
 
399
399
  # Add the current event to a digest keyed by the given subscription topic. The
400
400
  # digest accumulates events and releases them on the schedule configured for the
401
- # topic.
401
+ # topic, using the notification template configured on that topic. This node's
402
+ # `type` value is `add-to-digest`.
403
+ #
404
+ # **The topic must have a template configured.** If the topic has no template when
405
+ # the first event reaches this node, the journey run fails immediately: the run is
406
+ # marked `ERROR`, no digest instance is created, and the journey does not continue
407
+ # past this node. Configure the topic's template before using the topic in a
408
+ # journey.
409
+ #
410
+ # If the journey run is scoped to a tenant, digests are kept separate per tenant:
411
+ # two runs for the same user under different tenants accumulate and release as
412
+ # separate digests, even on the same topic.
402
413
  sig do
403
414
  params(
404
415
  subscription_topic_id: String,
@@ -0,0 +1,116 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class TopicDigestCategory < Courier::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Courier::TopicDigestCategory, Courier::Internal::AnyHash)
9
+ end
10
+
11
+ # The key that identifies the category within the digest.
12
+ sig { returns(String) }
13
+ attr_accessor :category_key
14
+
15
+ # How many collected events are carried into the rendered digest. Defaults to 10.
16
+ #
17
+ # Events beyond the limit are discarded, not held back for the next digest: the
18
+ # release consumes everything collected so far and only `limit` of them appear.
19
+ # `retain` decides which ones those are.
20
+ sig { returns(T.nilable(Integer)) }
21
+ attr_reader :limit
22
+
23
+ sig { params(limit: Integer).void }
24
+ attr_writer :limit
25
+
26
+ # Which collected events survive the `limit`. `FIRST` and `LOWEST` keep the
27
+ # earliest or smallest; `LAST` and `HIGHEST` keep the latest or largest. Accepted
28
+ # case-insensitively, returned uppercase.
29
+ sig { returns(T.nilable(Courier::TopicDigestCategory::Retain::OrSymbol)) }
30
+ attr_reader :retain
31
+
32
+ sig do
33
+ params(retain: Courier::TopicDigestCategory::Retain::OrSymbol).void
34
+ end
35
+ attr_writer :retain
36
+
37
+ # The data key used to rank events. Required when `retain` is `HIGHEST` or
38
+ # `LOWEST`.
39
+ sig { returns(T.nilable(String)) }
40
+ attr_reader :sort_key
41
+
42
+ sig { params(sort_key: String).void }
43
+ attr_writer :sort_key
44
+
45
+ # How events collected under a category key are retained when a digest holds more
46
+ # than it will render.
47
+ sig do
48
+ params(
49
+ category_key: String,
50
+ limit: Integer,
51
+ retain: Courier::TopicDigestCategory::Retain::OrSymbol,
52
+ sort_key: String
53
+ ).returns(T.attached_class)
54
+ end
55
+ def self.new(
56
+ # The key that identifies the category within the digest.
57
+ category_key:,
58
+ # How many collected events are carried into the rendered digest. Defaults to 10.
59
+ #
60
+ # Events beyond the limit are discarded, not held back for the next digest: the
61
+ # release consumes everything collected so far and only `limit` of them appear.
62
+ # `retain` decides which ones those are.
63
+ limit: nil,
64
+ # Which collected events survive the `limit`. `FIRST` and `LOWEST` keep the
65
+ # earliest or smallest; `LAST` and `HIGHEST` keep the latest or largest. Accepted
66
+ # case-insensitively, returned uppercase.
67
+ retain: nil,
68
+ # The data key used to rank events. Required when `retain` is `HIGHEST` or
69
+ # `LOWEST`.
70
+ sort_key: nil
71
+ )
72
+ end
73
+
74
+ sig do
75
+ override.returns(
76
+ {
77
+ category_key: String,
78
+ limit: Integer,
79
+ retain: Courier::TopicDigestCategory::Retain::OrSymbol,
80
+ sort_key: String
81
+ }
82
+ )
83
+ end
84
+ def to_hash
85
+ end
86
+
87
+ # Which collected events survive the `limit`. `FIRST` and `LOWEST` keep the
88
+ # earliest or smallest; `LAST` and `HIGHEST` keep the latest or largest. Accepted
89
+ # case-insensitively, returned uppercase.
90
+ module Retain
91
+ extend Courier::Internal::Type::Enum
92
+
93
+ TaggedSymbol =
94
+ T.type_alias { T.all(Symbol, Courier::TopicDigestCategory::Retain) }
95
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
96
+
97
+ FIRST =
98
+ T.let(:FIRST, Courier::TopicDigestCategory::Retain::TaggedSymbol)
99
+ LAST = T.let(:LAST, Courier::TopicDigestCategory::Retain::TaggedSymbol)
100
+ HIGHEST =
101
+ T.let(:HIGHEST, Courier::TopicDigestCategory::Retain::TaggedSymbol)
102
+ LOWEST =
103
+ T.let(:LOWEST, Courier::TopicDigestCategory::Retain::TaggedSymbol)
104
+ NONE = T.let(:NONE, Courier::TopicDigestCategory::Retain::TaggedSymbol)
105
+
106
+ sig do
107
+ override.returns(
108
+ T::Array[Courier::TopicDigestCategory::Retain::TaggedSymbol]
109
+ )
110
+ end
111
+ def self.values
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,51 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class TopicDigestReleaseRequest < Courier::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Courier::TopicDigestReleaseRequest, Courier::Internal::AnyHash)
9
+ end
10
+
11
+ # The recipient whose digest to release. Required: there is no "release everyone
12
+ # on this topic" form, because a whole-schedule flush already has its own endpoint
13
+ # and a body-shaped difference between one recipient and all of them is too easy
14
+ # to get wrong.
15
+ sig { returns(String) }
16
+ attr_accessor :user_id
17
+
18
+ # The recipient's tenant, when they were sent to as part of one -- the same value
19
+ # returned as `tenant_id` on a digest instance and sent as
20
+ # `message.context.tenant_id`. It is part of the held digest's key, so a tenanted
21
+ # recipient cannot be found without it. Omit for an ordinary recipient.
22
+ sig { returns(T.nilable(String)) }
23
+ attr_reader :tenant_id
24
+
25
+ sig { params(tenant_id: String).void }
26
+ attr_writer :tenant_id
27
+
28
+ # Which recipient's held digest to release.
29
+ sig do
30
+ params(user_id: String, tenant_id: String).returns(T.attached_class)
31
+ end
32
+ def self.new(
33
+ # The recipient whose digest to release. Required: there is no "release everyone
34
+ # on this topic" form, because a whole-schedule flush already has its own endpoint
35
+ # and a body-shaped difference between one recipient and all of them is too easy
36
+ # to get wrong.
37
+ user_id:,
38
+ # The recipient's tenant, when they were sent to as part of one -- the same value
39
+ # returned as `tenant_id` on a digest instance and sent as
40
+ # `message.context.tenant_id`. It is part of the held digest's key, so a tenanted
41
+ # recipient cannot be found without it. Omit for an ordinary recipient.
42
+ tenant_id: nil
43
+ )
44
+ end
45
+
46
+ sig { override.returns({ user_id: String, tenant_id: String }) }
47
+ def to_hash
48
+ end
49
+ end
50
+ end
51
+ end