trycourier 4.10.1 → 4.11.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 (168) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/lib/courier/client.rb +15 -1
  4. data/lib/courier/internal/transport/base_client.rb +2 -0
  5. data/lib/courier/models/create_journey_request.rb +39 -0
  6. data/lib/courier/models/journey_ai_node.rb +77 -0
  7. data/lib/courier/models/journey_api_invoke_trigger_node.rb +73 -0
  8. data/lib/courier/models/journey_archive_params.rb +20 -0
  9. data/lib/courier/models/journey_condition_atom.rb +8 -0
  10. data/lib/courier/models/journey_condition_group.rb +26 -0
  11. data/lib/courier/models/journey_condition_nested_group.rb +24 -0
  12. data/lib/courier/models/journey_conditions_field.rb +37 -0
  13. data/lib/courier/models/journey_create_params.rb +14 -0
  14. data/lib/courier/models/journey_delay_duration_node.rb +71 -0
  15. data/lib/courier/models/journey_delay_until_node.rb +71 -0
  16. data/lib/courier/models/journey_exit_node.rb +33 -0
  17. data/lib/courier/models/journey_fetch_get_delete_node.rb +103 -0
  18. data/lib/courier/models/journey_fetch_post_put_node.rb +110 -0
  19. data/lib/courier/models/journey_list_versions_params.rb +20 -0
  20. data/lib/courier/models/journey_merge_strategy.rb +18 -0
  21. data/lib/courier/models/journey_node.rb +139 -0
  22. data/lib/courier/models/journey_publish_params.rb +20 -0
  23. data/lib/courier/models/journey_publish_request.rb +18 -0
  24. data/lib/courier/models/journey_replace_params.rb +20 -0
  25. data/lib/courier/models/journey_response.rb +82 -0
  26. data/lib/courier/models/journey_retrieve_params.rb +29 -0
  27. data/lib/courier/models/journey_segment_trigger_node.rb +90 -0
  28. data/lib/courier/models/journey_send_node.rb +124 -0
  29. data/lib/courier/models/journey_state.rb +16 -0
  30. data/lib/courier/models/journey_template_create_request.rb +138 -0
  31. data/lib/courier/models/journey_template_get_response.rb +154 -0
  32. data/lib/courier/models/journey_template_list_response.rb +23 -0
  33. data/lib/courier/models/journey_template_publish_request.rb +18 -0
  34. data/lib/courier/models/journey_template_replace_request.rb +126 -0
  35. data/lib/courier/models/journey_template_summary.rb +60 -0
  36. data/lib/courier/models/journey_throttle_dynamic_node.rb +86 -0
  37. data/lib/courier/models/journey_throttle_static_node.rb +80 -0
  38. data/lib/courier/models/journey_version_item.rb +41 -0
  39. data/lib/courier/models/journey_versions_list_response.rb +24 -0
  40. data/lib/courier/models/journeys/template_archive_params.rb +28 -0
  41. data/lib/courier/models/journeys/template_create_params.rb +22 -0
  42. data/lib/courier/models/journeys/template_list_params.rb +39 -0
  43. data/lib/courier/models/journeys/template_list_versions_params.rb +28 -0
  44. data/lib/courier/models/journeys/template_publish_params.rb +28 -0
  45. data/lib/courier/models/journeys/template_replace_params.rb +28 -0
  46. data/lib/courier/models/journeys/template_retrieve_params.rb +28 -0
  47. data/lib/courier/models/notification_list_response.rb +8 -8
  48. data/lib/courier/models/notification_template_create_request.rb +3 -3
  49. data/lib/courier/models/notification_template_payload.rb +2 -2
  50. data/lib/courier/models/notification_template_response.rb +71 -0
  51. data/lib/courier/models/notification_template_update_request.rb +3 -3
  52. data/lib/courier/models/tenants/template_delete_params.rb +28 -0
  53. data/lib/courier/models.rb +75 -2
  54. data/lib/courier/resources/journeys/templates.rb +224 -0
  55. data/lib/courier/resources/journeys.rb +167 -2
  56. data/lib/courier/resources/notifications/checks.rb +16 -6
  57. data/lib/courier/resources/notifications.rb +8 -8
  58. data/lib/courier/resources/tenants/templates.rb +32 -0
  59. data/lib/courier/version.rb +1 -1
  60. data/lib/courier.rb +45 -1
  61. data/rbi/courier/models/create_journey_request.rbi +113 -0
  62. data/rbi/courier/models/journey_ai_node.rbi +141 -0
  63. data/rbi/courier/models/journey_api_invoke_trigger_node.rbi +164 -0
  64. data/rbi/courier/models/journey_archive_params.rbi +35 -0
  65. data/rbi/courier/models/journey_condition_atom.rbi +11 -0
  66. data/rbi/courier/models/journey_condition_group.rbi +43 -0
  67. data/rbi/courier/models/journey_condition_nested_group.rbi +51 -0
  68. data/rbi/courier/models/journey_conditions_field.rbi +27 -0
  69. data/rbi/courier/models/journey_create_params.rbi +27 -0
  70. data/rbi/courier/models/journey_delay_duration_node.rbi +146 -0
  71. data/rbi/courier/models/journey_delay_until_node.rbi +139 -0
  72. data/rbi/courier/models/journey_exit_node.rbi +57 -0
  73. data/rbi/courier/models/journey_fetch_get_delete_node.rbi +186 -0
  74. data/rbi/courier/models/journey_fetch_post_put_node.rbi +190 -0
  75. data/rbi/courier/models/journey_list_versions_params.rbi +35 -0
  76. data/rbi/courier/models/journey_merge_strategy.rbi +26 -0
  77. data/rbi/courier/models/journey_node.rbi +227 -0
  78. data/rbi/courier/models/journey_publish_params.rbi +35 -0
  79. data/rbi/courier/models/journey_publish_request.rbi +28 -0
  80. data/rbi/courier/models/journey_replace_params.rbi +35 -0
  81. data/rbi/courier/models/journey_response.rbi +108 -0
  82. data/rbi/courier/models/journey_retrieve_params.rbi +52 -0
  83. data/rbi/courier/models/journey_segment_trigger_node.rbi +200 -0
  84. data/rbi/courier/models/journey_send_node.rbi +254 -0
  85. data/rbi/courier/models/journey_state.rbi +20 -0
  86. data/rbi/courier/models/journey_template_create_request.rbi +381 -0
  87. data/rbi/courier/models/journey_template_get_response.rbi +334 -0
  88. data/rbi/courier/models/journey_template_list_response.rbi +45 -0
  89. data/rbi/courier/models/journey_template_publish_request.rbi +31 -0
  90. data/rbi/courier/models/journey_template_replace_request.rbi +368 -0
  91. data/rbi/courier/models/journey_template_summary.rbi +85 -0
  92. data/rbi/courier/models/journey_throttle_dynamic_node.rbi +162 -0
  93. data/rbi/courier/models/journey_throttle_static_node.rbi +158 -0
  94. data/rbi/courier/models/journey_version_item.rbi +54 -0
  95. data/rbi/courier/models/journey_versions_list_response.rbi +45 -0
  96. data/rbi/courier/models/journeys/template_archive_params.rbi +48 -0
  97. data/rbi/courier/models/journeys/template_create_params.rbi +40 -0
  98. data/rbi/courier/models/journeys/template_list_params.rbi +68 -0
  99. data/rbi/courier/models/journeys/template_list_versions_params.rbi +48 -0
  100. data/rbi/courier/models/journeys/template_publish_params.rbi +48 -0
  101. data/rbi/courier/models/journeys/template_replace_params.rbi +48 -0
  102. data/rbi/courier/models/journeys/template_retrieve_params.rbi +48 -0
  103. data/rbi/courier/models/notification_list_response.rbi +9 -6
  104. data/rbi/courier/models/notification_template_create_request.rbi +4 -4
  105. data/rbi/courier/models/notification_template_payload.rbi +2 -2
  106. data/rbi/courier/models/notification_template_response.rbi +120 -0
  107. data/rbi/courier/models/notification_template_update_request.rbi +4 -4
  108. data/rbi/courier/models/tenants/template_delete_params.rbi +48 -0
  109. data/rbi/courier/models.rbi +78 -3
  110. data/rbi/courier/resources/journeys/templates.rbi +160 -0
  111. data/rbi/courier/resources/journeys.rbi +156 -3
  112. data/rbi/courier/resources/notifications/checks.rbi +19 -4
  113. data/rbi/courier/resources/notifications.rbi +7 -7
  114. data/rbi/courier/resources/tenants/templates.rbi +22 -0
  115. data/sig/courier/models/create_journey_request.rbs +41 -0
  116. data/sig/courier/models/journey_ai_node.rbs +72 -0
  117. data/sig/courier/models/journey_api_invoke_trigger_node.rbs +68 -0
  118. data/sig/courier/models/journey_archive_params.rbs +23 -0
  119. data/sig/courier/models/journey_condition_atom.rbs +7 -0
  120. data/sig/courier/models/journey_condition_group.rbs +33 -0
  121. data/sig/courier/models/journey_condition_nested_group.rbs +33 -0
  122. data/sig/courier/models/journey_conditions_field.rbs +14 -0
  123. data/sig/courier/models/journey_create_params.rbs +15 -0
  124. data/sig/courier/models/journey_delay_duration_node.rbs +66 -0
  125. data/sig/courier/models/journey_delay_until_node.rbs +66 -0
  126. data/sig/courier/models/journey_exit_node.rbs +34 -0
  127. data/sig/courier/models/journey_fetch_get_delete_node.rbs +93 -0
  128. data/sig/courier/models/journey_fetch_post_put_node.rbs +100 -0
  129. data/sig/courier/models/journey_list_versions_params.rbs +23 -0
  130. data/sig/courier/models/journey_merge_strategy.rbs +16 -0
  131. data/sig/courier/models/journey_node.rbs +117 -0
  132. data/sig/courier/models/journey_publish_params.rbs +25 -0
  133. data/sig/courier/models/journey_publish_request.rbs +15 -0
  134. data/sig/courier/models/journey_replace_params.rbs +25 -0
  135. data/sig/courier/models/journey_response.rbs +65 -0
  136. data/sig/courier/models/journey_retrieve_params.rbs +30 -0
  137. data/sig/courier/models/journey_segment_trigger_node.rbs +85 -0
  138. data/sig/courier/models/journey_send_node.rbs +140 -0
  139. data/sig/courier/models/journey_state.rbs +14 -0
  140. data/sig/courier/models/journey_template_create_request.rbs +148 -0
  141. data/sig/courier/models/journey_template_get_response.rbs +157 -0
  142. data/sig/courier/models/journey_template_list_response.rbs +25 -0
  143. data/sig/courier/models/journey_template_publish_request.rbs +15 -0
  144. data/sig/courier/models/journey_template_replace_request.rbs +136 -0
  145. data/sig/courier/models/journey_template_summary.rbs +59 -0
  146. data/sig/courier/models/journey_throttle_dynamic_node.rbs +76 -0
  147. data/sig/courier/models/journey_throttle_static_node.rbs +72 -0
  148. data/sig/courier/models/journey_version_item.rbs +40 -0
  149. data/sig/courier/models/journey_versions_list_response.rbs +22 -0
  150. data/sig/courier/models/journeys/template_archive_params.rbs +30 -0
  151. data/sig/courier/models/journeys/template_create_params.rbs +27 -0
  152. data/sig/courier/models/journeys/template_list_params.rbs +38 -0
  153. data/sig/courier/models/journeys/template_list_versions_params.rbs +30 -0
  154. data/sig/courier/models/journeys/template_publish_params.rbs +34 -0
  155. data/sig/courier/models/journeys/template_replace_params.rbs +34 -0
  156. data/sig/courier/models/journeys/template_retrieve_params.rbs +30 -0
  157. data/sig/courier/models/notification_list_response.rbs +7 -5
  158. data/sig/courier/models/notification_template_response.rbs +70 -0
  159. data/sig/courier/models/tenants/template_delete_params.rbs +30 -0
  160. data/sig/courier/models.rbs +74 -2
  161. data/sig/courier/resources/journeys/templates.rbs +58 -0
  162. data/sig/courier/resources/journeys.rbs +41 -0
  163. data/sig/courier/resources/notifications.rbs +3 -3
  164. data/sig/courier/resources/tenants/templates.rbs +6 -0
  165. metadata +137 -5
  166. data/lib/courier/models/notification_template_get_response.rb +0 -92
  167. data/rbi/courier/models/notification_template_get_response.rbi +0 -162
  168. data/sig/courier/models/notification_template_get_response.rbs +0 -72
@@ -0,0 +1,120 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class NotificationTemplateResponse < Courier::Models::NotificationTemplatePayload
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Courier::NotificationTemplateResponse,
10
+ Courier::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # The template ID.
15
+ sig { returns(String) }
16
+ attr_accessor :id
17
+
18
+ # Epoch milliseconds when the template was created.
19
+ sig { returns(Integer) }
20
+ attr_accessor :created
21
+
22
+ # User ID of the creator.
23
+ sig { returns(String) }
24
+ attr_accessor :creator
25
+
26
+ # The template state. Always uppercase.
27
+ sig do
28
+ returns(Courier::NotificationTemplateResponse::State::TaggedSymbol)
29
+ end
30
+ attr_accessor :state
31
+
32
+ # Epoch milliseconds of last update.
33
+ sig { returns(T.nilable(Integer)) }
34
+ attr_reader :updated
35
+
36
+ sig { params(updated: Integer).void }
37
+ attr_writer :updated
38
+
39
+ # User ID of the last updater.
40
+ sig { returns(T.nilable(String)) }
41
+ attr_reader :updater
42
+
43
+ sig { params(updater: String).void }
44
+ attr_writer :updater
45
+
46
+ # Response for GET /notifications/{id}, POST /notifications, and PUT
47
+ # /notifications/{id}. Returns all template fields at the top level.
48
+ sig do
49
+ params(
50
+ id: String,
51
+ created: Integer,
52
+ creator: String,
53
+ state: Courier::NotificationTemplateResponse::State::OrSymbol,
54
+ updated: Integer,
55
+ updater: String
56
+ ).returns(T.attached_class)
57
+ end
58
+ def self.new(
59
+ # The template ID.
60
+ id:,
61
+ # Epoch milliseconds when the template was created.
62
+ created:,
63
+ # User ID of the creator.
64
+ creator:,
65
+ # The template state. Always uppercase.
66
+ state:,
67
+ # Epoch milliseconds of last update.
68
+ updated: nil,
69
+ # User ID of the last updater.
70
+ updater: nil
71
+ )
72
+ end
73
+
74
+ sig do
75
+ override.returns(
76
+ {
77
+ id: String,
78
+ created: Integer,
79
+ creator: String,
80
+ state: Courier::NotificationTemplateResponse::State::TaggedSymbol,
81
+ updated: Integer,
82
+ updater: String
83
+ }
84
+ )
85
+ end
86
+ def to_hash
87
+ end
88
+
89
+ # The template state. Always uppercase.
90
+ module State
91
+ extend Courier::Internal::Type::Enum
92
+
93
+ TaggedSymbol =
94
+ T.type_alias do
95
+ T.all(Symbol, Courier::NotificationTemplateResponse::State)
96
+ end
97
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
98
+
99
+ DRAFT =
100
+ T.let(
101
+ :DRAFT,
102
+ Courier::NotificationTemplateResponse::State::TaggedSymbol
103
+ )
104
+ PUBLISHED =
105
+ T.let(
106
+ :PUBLISHED,
107
+ Courier::NotificationTemplateResponse::State::TaggedSymbol
108
+ )
109
+
110
+ sig do
111
+ override.returns(
112
+ T::Array[Courier::NotificationTemplateResponse::State::TaggedSymbol]
113
+ )
114
+ end
115
+ def self.values
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
@@ -11,8 +11,8 @@ module Courier
11
11
  )
12
12
  end
13
13
 
14
- # Full document shape used in POST and PUT request bodies, and returned inside the
15
- # GET response envelope.
14
+ # Core template fields used in POST and PUT request bodies (nested under a
15
+ # `notification` key) and returned at the top level in responses.
16
16
  sig { returns(Courier::NotificationTemplatePayload) }
17
17
  attr_reader :notification
18
18
 
@@ -46,8 +46,8 @@ module Courier
46
46
  ).returns(T.attached_class)
47
47
  end
48
48
  def self.new(
49
- # Full document shape used in POST and PUT request bodies, and returned inside the
50
- # GET response envelope.
49
+ # Core template fields used in POST and PUT request bodies (nested under a
50
+ # `notification` key) and returned at the top level in responses.
51
51
  notification:,
52
52
  # Template state after update. Case-insensitive input, normalized to uppercase in
53
53
  # the response. Defaults to "DRAFT".
@@ -0,0 +1,48 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ module Tenants
6
+ class TemplateDeleteParams < Courier::Internal::Type::BaseModel
7
+ extend Courier::Internal::Type::RequestParameters::Converter
8
+ include Courier::Internal::Type::RequestParameters
9
+
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Courier::Tenants::TemplateDeleteParams,
14
+ Courier::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig { returns(String) }
19
+ attr_accessor :tenant_id
20
+
21
+ sig { returns(String) }
22
+ attr_accessor :template_id
23
+
24
+ sig do
25
+ params(
26
+ tenant_id: String,
27
+ template_id: String,
28
+ request_options: Courier::RequestOptions::OrHash
29
+ ).returns(T.attached_class)
30
+ end
31
+ def self.new(tenant_id:, template_id:, request_options: {})
32
+ end
33
+
34
+ sig do
35
+ override.returns(
36
+ {
37
+ tenant_id: String,
38
+ template_id: String,
39
+ request_options: Courier::RequestOptions
40
+ }
41
+ )
42
+ end
43
+ def to_hash
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -97,6 +97,8 @@ module Courier
97
97
 
98
98
  Check = Courier::Models::Check
99
99
 
100
+ CreateJourneyRequest = Courier::Models::CreateJourneyRequest
101
+
100
102
  DefaultPreferences = Courier::Models::DefaultPreferences
101
103
 
102
104
  DeviceType = Courier::Models::DeviceType
@@ -155,16 +157,90 @@ module Courier
155
157
 
156
158
  Journey = Courier::Models::Journey
157
159
 
160
+ JourneyAINode = Courier::Models::JourneyAINode
161
+
162
+ JourneyAPIInvokeTriggerNode = Courier::Models::JourneyAPIInvokeTriggerNode
163
+
164
+ JourneyArchiveParams = Courier::Models::JourneyArchiveParams
165
+
166
+ JourneyConditionAtom =
167
+ T.let(
168
+ Courier::Models::JourneyConditionAtom,
169
+ Courier::Internal::Type::Converter
170
+ )
171
+
172
+ JourneyConditionGroup = Courier::Models::JourneyConditionGroup
173
+
174
+ JourneyConditionNestedGroup = Courier::Models::JourneyConditionNestedGroup
175
+
176
+ JourneyConditionsField = Courier::Models::JourneyConditionsField
177
+
178
+ JourneyCreateParams = Courier::Models::JourneyCreateParams
179
+
180
+ JourneyDelayDurationNode = Courier::Models::JourneyDelayDurationNode
181
+
182
+ JourneyDelayUntilNode = Courier::Models::JourneyDelayUntilNode
183
+
184
+ JourneyExitNode = Courier::Models::JourneyExitNode
185
+
186
+ JourneyFetchGetDeleteNode = Courier::Models::JourneyFetchGetDeleteNode
187
+
188
+ JourneyFetchPostPutNode = Courier::Models::JourneyFetchPostPutNode
189
+
158
190
  JourneyInvokeParams = Courier::Models::JourneyInvokeParams
159
191
 
160
192
  JourneyListParams = Courier::Models::JourneyListParams
161
193
 
194
+ JourneyListVersionsParams = Courier::Models::JourneyListVersionsParams
195
+
196
+ JourneyMergeStrategy = Courier::Models::JourneyMergeStrategy
197
+
198
+ JourneyNode = Courier::Models::JourneyNode
199
+
200
+ JourneyPublishParams = Courier::Models::JourneyPublishParams
201
+
202
+ JourneyPublishRequest = Courier::Models::JourneyPublishRequest
203
+
204
+ JourneyReplaceParams = Courier::Models::JourneyReplaceParams
205
+
206
+ JourneyResponse = Courier::Models::JourneyResponse
207
+
208
+ JourneyRetrieveParams = Courier::Models::JourneyRetrieveParams
209
+
210
+ Journeys = Courier::Models::Journeys
211
+
212
+ JourneySegmentTriggerNode = Courier::Models::JourneySegmentTriggerNode
213
+
214
+ JourneySendNode = Courier::Models::JourneySendNode
215
+
162
216
  JourneysInvokeRequest = Courier::Models::JourneysInvokeRequest
163
217
 
164
218
  JourneysInvokeResponse = Courier::Models::JourneysInvokeResponse
165
219
 
166
220
  JourneysListResponse = Courier::Models::JourneysListResponse
167
221
 
222
+ JourneyState = Courier::Models::JourneyState
223
+
224
+ JourneyTemplateCreateRequest = Courier::Models::JourneyTemplateCreateRequest
225
+
226
+ JourneyTemplateGetResponse = Courier::Models::JourneyTemplateGetResponse
227
+
228
+ JourneyTemplateListResponse = Courier::Models::JourneyTemplateListResponse
229
+
230
+ JourneyTemplatePublishRequest = Courier::Models::JourneyTemplatePublishRequest
231
+
232
+ JourneyTemplateReplaceRequest = Courier::Models::JourneyTemplateReplaceRequest
233
+
234
+ JourneyTemplateSummary = Courier::Models::JourneyTemplateSummary
235
+
236
+ JourneyThrottleDynamicNode = Courier::Models::JourneyThrottleDynamicNode
237
+
238
+ JourneyThrottleStaticNode = Courier::Models::JourneyThrottleStaticNode
239
+
240
+ JourneyVersionItem = Courier::Models::JourneyVersionItem
241
+
242
+ JourneyVersionsListResponse = Courier::Models::JourneyVersionsListResponse
243
+
168
244
  ListDeleteParams = Courier::Models::ListDeleteParams
169
245
 
170
246
  ListFilter = Courier::Models::ListFilter
@@ -266,14 +342,13 @@ module Courier
266
342
  NotificationTemplateCreateRequest =
267
343
  Courier::Models::NotificationTemplateCreateRequest
268
344
 
269
- NotificationTemplateGetResponse =
270
- Courier::Models::NotificationTemplateGetResponse
271
-
272
345
  NotificationTemplatePayload = Courier::Models::NotificationTemplatePayload
273
346
 
274
347
  NotificationTemplatePublishRequest =
275
348
  Courier::Models::NotificationTemplatePublishRequest
276
349
 
350
+ NotificationTemplateResponse = Courier::Models::NotificationTemplateResponse
351
+
277
352
  NotificationTemplateState = Courier::Models::NotificationTemplateState
278
353
 
279
354
  NotificationTemplateSummary = Courier::Models::NotificationTemplateSummary
@@ -0,0 +1,160 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Resources
5
+ class Journeys
6
+ class Templates
7
+ # Create a notification template scoped to this journey. Defaults to `DRAFT`
8
+ # state; pass `state: "PUBLISHED"` to publish on create.
9
+ sig do
10
+ params(
11
+ template_id: String,
12
+ channel: String,
13
+ notification:
14
+ Courier::JourneyTemplateCreateRequest::Notification::OrHash,
15
+ provider_key: String,
16
+ state: String,
17
+ request_options: Courier::RequestOptions::OrHash
18
+ ).returns(Courier::JourneyTemplateGetResponse)
19
+ end
20
+ def create(
21
+ # Journey id
22
+ template_id,
23
+ channel:,
24
+ notification:,
25
+ provider_key: nil,
26
+ state: nil,
27
+ request_options: {}
28
+ )
29
+ end
30
+
31
+ # Fetch a journey-scoped notification template by id. Pass `?version=draft`
32
+ # (default `published`) to retrieve the working draft, or `?version=vN` for a
33
+ # historical version.
34
+ sig do
35
+ params(
36
+ notification_id: String,
37
+ template_id: String,
38
+ request_options: Courier::RequestOptions::OrHash
39
+ ).returns(Courier::JourneyTemplateGetResponse)
40
+ end
41
+ def retrieve(
42
+ # Notification template id
43
+ notification_id,
44
+ # Journey id
45
+ template_id:,
46
+ request_options: {}
47
+ )
48
+ end
49
+
50
+ # List notification templates scoped to this journey. Journey-scoped notification
51
+ # templates can only be referenced from `send` nodes within the same journey.
52
+ sig do
53
+ params(
54
+ template_id: String,
55
+ cursor: String,
56
+ limit: Integer,
57
+ request_options: Courier::RequestOptions::OrHash
58
+ ).returns(Courier::JourneyTemplateListResponse)
59
+ end
60
+ def list(
61
+ # Journey id
62
+ template_id,
63
+ # Pagination cursor from a prior response.
64
+ cursor: nil,
65
+ # Page size. Minimum 1, maximum 100.
66
+ limit: nil,
67
+ request_options: {}
68
+ )
69
+ end
70
+
71
+ # Archive the journey-scoped notification template. Archived templates cannot be
72
+ # sent.
73
+ sig do
74
+ params(
75
+ notification_id: String,
76
+ template_id: String,
77
+ request_options: Courier::RequestOptions::OrHash
78
+ ).void
79
+ end
80
+ def archive(
81
+ # Notification template id
82
+ notification_id,
83
+ # Journey id
84
+ template_id:,
85
+ request_options: {}
86
+ )
87
+ end
88
+
89
+ # List published versions of the journey-scoped notification template, ordered
90
+ # most recent first.
91
+ sig do
92
+ params(
93
+ notification_id: String,
94
+ template_id: String,
95
+ request_options: Courier::RequestOptions::OrHash
96
+ ).returns(Courier::NotificationTemplateVersionListResponse)
97
+ end
98
+ def list_versions(
99
+ # Notification template id
100
+ notification_id,
101
+ # Journey id
102
+ template_id:,
103
+ request_options: {}
104
+ )
105
+ end
106
+
107
+ # Publish the current draft of the journey-scoped notification template as a new
108
+ # version. Optionally roll back to a prior version by passing
109
+ # `{ "version": "vN" }`.
110
+ sig do
111
+ params(
112
+ notification_id: String,
113
+ template_id: String,
114
+ version: String,
115
+ request_options: Courier::RequestOptions::OrHash
116
+ ).void
117
+ end
118
+ def publish(
119
+ # Path param: Notification template id
120
+ notification_id,
121
+ # Path param: Journey id
122
+ template_id:,
123
+ # Body param
124
+ version: nil,
125
+ request_options: {}
126
+ )
127
+ end
128
+
129
+ # Replace the journey-scoped notification template draft.
130
+ sig do
131
+ params(
132
+ notification_id: String,
133
+ template_id: String,
134
+ notification:
135
+ Courier::JourneyTemplateReplaceRequest::Notification::OrHash,
136
+ state: String,
137
+ request_options: Courier::RequestOptions::OrHash
138
+ ).returns(Courier::JourneyTemplateGetResponse)
139
+ end
140
+ def replace(
141
+ # Path param: Notification template id
142
+ notification_id,
143
+ # Path param: Journey id
144
+ template_id:,
145
+ # Body param
146
+ notification:,
147
+ # Body param
148
+ state: nil,
149
+ request_options: {}
150
+ )
151
+ end
152
+
153
+ # @api private
154
+ sig { params(client: Courier::Client).returns(T.attached_class) }
155
+ def self.new(client:)
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end
@@ -3,6 +3,68 @@
3
3
  module Courier
4
4
  module Resources
5
5
  class Journeys
6
+ sig { returns(Courier::Resources::Journeys::Templates) }
7
+ attr_reader :templates
8
+
9
+ # Create a journey. Defaults to `DRAFT` state; pass `state: "PUBLISHED"` to
10
+ # publish on create. Send nodes are not allowed on `POST`. The standard flow is:
11
+ # create the journey shell here, add notification templates with
12
+ # `POST /journeys/{templateId}/templates`, then wire them into the journey with
13
+ # `PUT /journeys/{templateId}`. Call `POST /journeys/{templateId}/publish` to
14
+ # publish a draft after the fact.
15
+ sig do
16
+ params(
17
+ name: String,
18
+ nodes:
19
+ T::Array[
20
+ T.any(
21
+ Courier::JourneyAPIInvokeTriggerNode::OrHash,
22
+ Courier::JourneySegmentTriggerNode::OrHash,
23
+ Courier::JourneySendNode::OrHash,
24
+ Courier::JourneyDelayDurationNode::OrHash,
25
+ Courier::JourneyDelayUntilNode::OrHash,
26
+ Courier::JourneyFetchGetDeleteNode::OrHash,
27
+ Courier::JourneyFetchPostPutNode::OrHash,
28
+ Courier::JourneyAINode::OrHash,
29
+ Courier::JourneyThrottleStaticNode::OrHash,
30
+ Courier::JourneyThrottleDynamicNode::OrHash,
31
+ Courier::JourneyExitNode::OrHash,
32
+ Courier::JourneyNode::JourneyBranchNode::OrHash
33
+ )
34
+ ],
35
+ enabled: T::Boolean,
36
+ state: Courier::JourneyState::OrSymbol,
37
+ request_options: Courier::RequestOptions::OrHash
38
+ ).returns(Courier::JourneyResponse)
39
+ end
40
+ def create(
41
+ name:,
42
+ nodes:,
43
+ enabled: nil,
44
+ # Lifecycle state of a journey.
45
+ state: nil,
46
+ request_options: {}
47
+ )
48
+ end
49
+
50
+ # Fetch a journey by id. Pass `?version=draft` (default `published`) to retrieve
51
+ # the working draft, or `?version=vN` to retrieve a historical version.
52
+ sig do
53
+ params(
54
+ template_id: String,
55
+ version: String,
56
+ request_options: Courier::RequestOptions::OrHash
57
+ ).returns(Courier::JourneyResponse)
58
+ end
59
+ def retrieve(
60
+ # Journey id
61
+ template_id,
62
+ # Version selector: `draft`, `published` (default), or `vN`.
63
+ version: nil,
64
+ request_options: {}
65
+ )
66
+ end
67
+
6
68
  # Get the list of journeys.
7
69
  sig do
8
70
  params(
@@ -22,7 +84,23 @@ module Courier
22
84
  )
23
85
  end
24
86
 
25
- # Invoke a journey run from a journey template.
87
+ # Archive a journey. Archived journeys cannot be invoked. Existing journey runs
88
+ # continue to completion.
89
+ sig do
90
+ params(
91
+ template_id: String,
92
+ request_options: Courier::RequestOptions::OrHash
93
+ ).void
94
+ end
95
+ def archive(
96
+ # Journey id
97
+ template_id,
98
+ request_options: {}
99
+ )
100
+ end
101
+
102
+ # Invoke a journey by id or alias to start a new run. The response includes a
103
+ # `runId` identifying the run.
26
104
  sig do
27
105
  params(
28
106
  template_id: String,
@@ -33,8 +111,8 @@ module Courier
33
111
  ).returns(Courier::JourneysInvokeResponse)
34
112
  end
35
113
  def invoke(
36
- # A unique identifier representing the journey template to be invoked. This could
37
- # be the Journey Template ID or the Journey Template Alias.
114
+ # A unique identifier representing the journey to be invoked. Accepts a Journey ID
115
+ # or Journey Alias.
38
116
  template_id,
39
117
  # Data payload passed to the journey. The expected shape can be predefined using
40
118
  # the schema builder in the journey editor. This data is available in journey
@@ -55,6 +133,81 @@ module Courier
55
133
  )
56
134
  end
57
135
 
136
+ # List published versions of a journey, ordered most recent first.
137
+ sig do
138
+ params(
139
+ template_id: String,
140
+ request_options: Courier::RequestOptions::OrHash
141
+ ).returns(Courier::JourneyVersionsListResponse)
142
+ end
143
+ def list_versions(
144
+ # Journey id
145
+ template_id,
146
+ request_options: {}
147
+ )
148
+ end
149
+
150
+ # Publish the current draft as a new version. Body is optional; pass
151
+ # `{ "version": "vN" }` to roll back to a prior version instead. Returns 404 if
152
+ # the journey has no draft to publish.
153
+ sig do
154
+ params(
155
+ template_id: String,
156
+ version: String,
157
+ request_options: Courier::RequestOptions::OrHash
158
+ ).returns(Courier::JourneyResponse)
159
+ end
160
+ def publish(
161
+ # Journey id
162
+ template_id,
163
+ version: nil,
164
+ request_options: {}
165
+ )
166
+ end
167
+
168
+ # Replace the journey draft. Updates the working draft only; call
169
+ # `POST /journeys/{templateId}/publish` to make it live, or pass
170
+ # `state: "PUBLISHED"` in this request to publish immediately. Send-node
171
+ # `template` ids must already exist and be scoped to this journey, and node ids
172
+ # must not be claimed by another journey.
173
+ sig do
174
+ params(
175
+ template_id: String,
176
+ name: String,
177
+ nodes:
178
+ T::Array[
179
+ T.any(
180
+ Courier::JourneyAPIInvokeTriggerNode::OrHash,
181
+ Courier::JourneySegmentTriggerNode::OrHash,
182
+ Courier::JourneySendNode::OrHash,
183
+ Courier::JourneyDelayDurationNode::OrHash,
184
+ Courier::JourneyDelayUntilNode::OrHash,
185
+ Courier::JourneyFetchGetDeleteNode::OrHash,
186
+ Courier::JourneyFetchPostPutNode::OrHash,
187
+ Courier::JourneyAINode::OrHash,
188
+ Courier::JourneyThrottleStaticNode::OrHash,
189
+ Courier::JourneyThrottleDynamicNode::OrHash,
190
+ Courier::JourneyExitNode::OrHash,
191
+ Courier::JourneyNode::JourneyBranchNode::OrHash
192
+ )
193
+ ],
194
+ enabled: T::Boolean,
195
+ state: Courier::JourneyState::OrSymbol,
196
+ request_options: Courier::RequestOptions::OrHash
197
+ ).returns(Courier::JourneyResponse)
198
+ end
199
+ def replace(
200
+ # Journey id
201
+ template_id,
202
+ name:,
203
+ nodes:,
204
+ enabled: nil,
205
+ # Lifecycle state of a journey.
206
+ state: nil,
207
+ request_options: {}
208
+ )
209
+ end
210
+
58
211
  # @api private
59
212
  sig { params(client: Courier::Client).returns(T.attached_class) }
60
213
  def self.new(client:)