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
@@ -133,6 +133,8 @@ module Courier
133
133
 
134
134
  Check = Courier::Models::Check
135
135
 
136
+ CreateJourneyRequest = Courier::Models::CreateJourneyRequest
137
+
136
138
  DefaultPreferences = Courier::Models::DefaultPreferences
137
139
 
138
140
  DeviceType = Courier::Models::DeviceType
@@ -191,16 +193,87 @@ module Courier
191
193
 
192
194
  Journey = Courier::Models::Journey
193
195
 
196
+ JourneyAINode = Courier::Models::JourneyAINode
197
+
198
+ JourneyAPIInvokeTriggerNode = Courier::Models::JourneyAPIInvokeTriggerNode
199
+
200
+ JourneyArchiveParams = Courier::Models::JourneyArchiveParams
201
+
202
+ # @type [Courier::Internal::Type::Converter]
203
+ JourneyConditionAtom = Courier::Models::JourneyConditionAtom
204
+
205
+ JourneyConditionGroup = Courier::Models::JourneyConditionGroup
206
+
207
+ JourneyConditionNestedGroup = Courier::Models::JourneyConditionNestedGroup
208
+
209
+ JourneyConditionsField = Courier::Models::JourneyConditionsField
210
+
211
+ JourneyCreateParams = Courier::Models::JourneyCreateParams
212
+
213
+ JourneyDelayDurationNode = Courier::Models::JourneyDelayDurationNode
214
+
215
+ JourneyDelayUntilNode = Courier::Models::JourneyDelayUntilNode
216
+
217
+ JourneyExitNode = Courier::Models::JourneyExitNode
218
+
219
+ JourneyFetchGetDeleteNode = Courier::Models::JourneyFetchGetDeleteNode
220
+
221
+ JourneyFetchPostPutNode = Courier::Models::JourneyFetchPostPutNode
222
+
194
223
  JourneyInvokeParams = Courier::Models::JourneyInvokeParams
195
224
 
196
225
  JourneyListParams = Courier::Models::JourneyListParams
197
226
 
227
+ JourneyListVersionsParams = Courier::Models::JourneyListVersionsParams
228
+
229
+ JourneyMergeStrategy = Courier::Models::JourneyMergeStrategy
230
+
231
+ JourneyNode = Courier::Models::JourneyNode
232
+
233
+ JourneyPublishParams = Courier::Models::JourneyPublishParams
234
+
235
+ JourneyPublishRequest = Courier::Models::JourneyPublishRequest
236
+
237
+ JourneyReplaceParams = Courier::Models::JourneyReplaceParams
238
+
239
+ JourneyResponse = Courier::Models::JourneyResponse
240
+
241
+ JourneyRetrieveParams = Courier::Models::JourneyRetrieveParams
242
+
243
+ Journeys = Courier::Models::Journeys
244
+
245
+ JourneySegmentTriggerNode = Courier::Models::JourneySegmentTriggerNode
246
+
247
+ JourneySendNode = Courier::Models::JourneySendNode
248
+
198
249
  JourneysInvokeRequest = Courier::Models::JourneysInvokeRequest
199
250
 
200
251
  JourneysInvokeResponse = Courier::Models::JourneysInvokeResponse
201
252
 
202
253
  JourneysListResponse = Courier::Models::JourneysListResponse
203
254
 
255
+ JourneyState = Courier::Models::JourneyState
256
+
257
+ JourneyTemplateCreateRequest = Courier::Models::JourneyTemplateCreateRequest
258
+
259
+ JourneyTemplateGetResponse = Courier::Models::JourneyTemplateGetResponse
260
+
261
+ JourneyTemplateListResponse = Courier::Models::JourneyTemplateListResponse
262
+
263
+ JourneyTemplatePublishRequest = Courier::Models::JourneyTemplatePublishRequest
264
+
265
+ JourneyTemplateReplaceRequest = Courier::Models::JourneyTemplateReplaceRequest
266
+
267
+ JourneyTemplateSummary = Courier::Models::JourneyTemplateSummary
268
+
269
+ JourneyThrottleDynamicNode = Courier::Models::JourneyThrottleDynamicNode
270
+
271
+ JourneyThrottleStaticNode = Courier::Models::JourneyThrottleStaticNode
272
+
273
+ JourneyVersionItem = Courier::Models::JourneyVersionItem
274
+
275
+ JourneyVersionsListResponse = Courier::Models::JourneyVersionsListResponse
276
+
204
277
  ListDeleteParams = Courier::Models::ListDeleteParams
205
278
 
206
279
  ListFilter = Courier::Models::ListFilter
@@ -297,12 +370,12 @@ module Courier
297
370
 
298
371
  NotificationTemplateCreateRequest = Courier::Models::NotificationTemplateCreateRequest
299
372
 
300
- NotificationTemplateGetResponse = Courier::Models::NotificationTemplateGetResponse
301
-
302
373
  NotificationTemplatePayload = Courier::Models::NotificationTemplatePayload
303
374
 
304
375
  NotificationTemplatePublishRequest = Courier::Models::NotificationTemplatePublishRequest
305
376
 
377
+ NotificationTemplateResponse = Courier::Models::NotificationTemplateResponse
378
+
306
379
  NotificationTemplateState = Courier::Models::NotificationTemplateState
307
380
 
308
381
  NotificationTemplateSummary = Courier::Models::NotificationTemplateSummary
@@ -0,0 +1,224 @@
1
+ # frozen_string_literal: true
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
+ #
10
+ # @overload create(template_id, channel:, notification:, provider_key: nil, state: nil, request_options: {})
11
+ #
12
+ # @param template_id [String] Journey id
13
+ #
14
+ # @param channel [String]
15
+ #
16
+ # @param notification [Courier::Models::JourneyTemplateCreateRequest::Notification]
17
+ #
18
+ # @param provider_key [String]
19
+ #
20
+ # @param state [String]
21
+ #
22
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
23
+ #
24
+ # @return [Courier::Models::JourneyTemplateGetResponse]
25
+ #
26
+ # @see Courier::Models::Journeys::TemplateCreateParams
27
+ def create(template_id, params)
28
+ parsed, options = Courier::Journeys::TemplateCreateParams.dump_request(params)
29
+ @client.request(
30
+ method: :post,
31
+ path: ["journeys/%1$s/templates", template_id],
32
+ body: parsed,
33
+ model: Courier::JourneyTemplateGetResponse,
34
+ options: options
35
+ )
36
+ end
37
+
38
+ # Fetch a journey-scoped notification template by id. Pass `?version=draft`
39
+ # (default `published`) to retrieve the working draft, or `?version=vN` for a
40
+ # historical version.
41
+ #
42
+ # @overload retrieve(notification_id, template_id:, request_options: {})
43
+ #
44
+ # @param notification_id [String] Notification template id
45
+ #
46
+ # @param template_id [String] Journey id
47
+ #
48
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
49
+ #
50
+ # @return [Courier::Models::JourneyTemplateGetResponse]
51
+ #
52
+ # @see Courier::Models::Journeys::TemplateRetrieveParams
53
+ def retrieve(notification_id, params)
54
+ parsed, options = Courier::Journeys::TemplateRetrieveParams.dump_request(params)
55
+ template_id =
56
+ parsed.delete(:template_id) do
57
+ raise ArgumentError.new("missing required path argument #{_1}")
58
+ end
59
+ @client.request(
60
+ method: :get,
61
+ path: ["journeys/%1$s/templates/%2$s", template_id, notification_id],
62
+ model: Courier::JourneyTemplateGetResponse,
63
+ options: options
64
+ )
65
+ end
66
+
67
+ # List notification templates scoped to this journey. Journey-scoped notification
68
+ # templates can only be referenced from `send` nodes within the same journey.
69
+ #
70
+ # @overload list(template_id, cursor: nil, limit: nil, request_options: {})
71
+ #
72
+ # @param template_id [String] Journey id
73
+ #
74
+ # @param cursor [String] Pagination cursor from a prior response.
75
+ #
76
+ # @param limit [Integer] Page size. Minimum 1, maximum 100.
77
+ #
78
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
79
+ #
80
+ # @return [Courier::Models::JourneyTemplateListResponse]
81
+ #
82
+ # @see Courier::Models::Journeys::TemplateListParams
83
+ def list(template_id, params = {})
84
+ parsed, options = Courier::Journeys::TemplateListParams.dump_request(params)
85
+ query = Courier::Internal::Util.encode_query_params(parsed)
86
+ @client.request(
87
+ method: :get,
88
+ path: ["journeys/%1$s/templates", template_id],
89
+ query: query,
90
+ model: Courier::JourneyTemplateListResponse,
91
+ options: options
92
+ )
93
+ end
94
+
95
+ # Archive the journey-scoped notification template. Archived templates cannot be
96
+ # sent.
97
+ #
98
+ # @overload archive(notification_id, template_id:, request_options: {})
99
+ #
100
+ # @param notification_id [String] Notification template id
101
+ #
102
+ # @param template_id [String] Journey id
103
+ #
104
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
105
+ #
106
+ # @return [nil]
107
+ #
108
+ # @see Courier::Models::Journeys::TemplateArchiveParams
109
+ def archive(notification_id, params)
110
+ parsed, options = Courier::Journeys::TemplateArchiveParams.dump_request(params)
111
+ template_id =
112
+ parsed.delete(:template_id) do
113
+ raise ArgumentError.new("missing required path argument #{_1}")
114
+ end
115
+ @client.request(
116
+ method: :delete,
117
+ path: ["journeys/%1$s/templates/%2$s", template_id, notification_id],
118
+ model: NilClass,
119
+ options: options
120
+ )
121
+ end
122
+
123
+ # List published versions of the journey-scoped notification template, ordered
124
+ # most recent first.
125
+ #
126
+ # @overload list_versions(notification_id, template_id:, request_options: {})
127
+ #
128
+ # @param notification_id [String] Notification template id
129
+ #
130
+ # @param template_id [String] Journey id
131
+ #
132
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
133
+ #
134
+ # @return [Courier::Models::NotificationTemplateVersionListResponse]
135
+ #
136
+ # @see Courier::Models::Journeys::TemplateListVersionsParams
137
+ def list_versions(notification_id, params)
138
+ parsed, options = Courier::Journeys::TemplateListVersionsParams.dump_request(params)
139
+ template_id =
140
+ parsed.delete(:template_id) do
141
+ raise ArgumentError.new("missing required path argument #{_1}")
142
+ end
143
+ @client.request(
144
+ method: :get,
145
+ path: ["journeys/%1$s/templates/%2$s/versions", template_id, notification_id],
146
+ model: Courier::NotificationTemplateVersionListResponse,
147
+ options: options
148
+ )
149
+ end
150
+
151
+ # Publish the current draft of the journey-scoped notification template as a new
152
+ # version. Optionally roll back to a prior version by passing
153
+ # `{ "version": "vN" }`.
154
+ #
155
+ # @overload publish(notification_id, template_id:, version: nil, request_options: {})
156
+ #
157
+ # @param notification_id [String] Path param: Notification template id
158
+ #
159
+ # @param template_id [String] Path param: Journey id
160
+ #
161
+ # @param version [String] Body param
162
+ #
163
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
164
+ #
165
+ # @return [nil]
166
+ #
167
+ # @see Courier::Models::Journeys::TemplatePublishParams
168
+ def publish(notification_id, params)
169
+ parsed, options = Courier::Journeys::TemplatePublishParams.dump_request(params)
170
+ template_id =
171
+ parsed.delete(:template_id) do
172
+ raise ArgumentError.new("missing required path argument #{_1}")
173
+ end
174
+ @client.request(
175
+ method: :post,
176
+ path: ["journeys/%1$s/templates/%2$s/publish", template_id, notification_id],
177
+ body: parsed,
178
+ model: NilClass,
179
+ options: options
180
+ )
181
+ end
182
+
183
+ # Replace the journey-scoped notification template draft.
184
+ #
185
+ # @overload replace(notification_id, template_id:, notification:, state: nil, request_options: {})
186
+ #
187
+ # @param notification_id [String] Path param: Notification template id
188
+ #
189
+ # @param template_id [String] Path param: Journey id
190
+ #
191
+ # @param notification [Courier::Models::JourneyTemplateReplaceRequest::Notification] Body param
192
+ #
193
+ # @param state [String] Body param
194
+ #
195
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
196
+ #
197
+ # @return [Courier::Models::JourneyTemplateGetResponse]
198
+ #
199
+ # @see Courier::Models::Journeys::TemplateReplaceParams
200
+ def replace(notification_id, params)
201
+ parsed, options = Courier::Journeys::TemplateReplaceParams.dump_request(params)
202
+ template_id =
203
+ parsed.delete(:template_id) do
204
+ raise ArgumentError.new("missing required path argument #{_1}")
205
+ end
206
+ @client.request(
207
+ method: :put,
208
+ path: ["journeys/%1$s/templates/%2$s", template_id, notification_id],
209
+ body: parsed,
210
+ model: Courier::JourneyTemplateGetResponse,
211
+ options: options
212
+ )
213
+ end
214
+
215
+ # @api private
216
+ #
217
+ # @param client [Courier::Client]
218
+ def initialize(client:)
219
+ @client = client
220
+ end
221
+ end
222
+ end
223
+ end
224
+ end
@@ -3,6 +3,68 @@
3
3
  module Courier
4
4
  module Resources
5
5
  class Journeys
6
+ # @return [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
+ #
16
+ # @overload create(name:, nodes:, enabled: nil, state: nil, request_options: {})
17
+ #
18
+ # @param name [String]
19
+ #
20
+ # @param nodes [Array<Courier::Models::JourneyAPIInvokeTriggerNode, Courier::Models::JourneySegmentTriggerNode, Courier::Models::JourneySendNode, Courier::Models::JourneyDelayDurationNode, Courier::Models::JourneyDelayUntilNode, Courier::Models::JourneyFetchGetDeleteNode, Courier::Models::JourneyFetchPostPutNode, Courier::Models::JourneyAINode, Courier::Models::JourneyThrottleStaticNode, Courier::Models::JourneyThrottleDynamicNode, Courier::Models::JourneyExitNode, Courier::Models::JourneyNode::JourneyBranchNode>]
21
+ #
22
+ # @param enabled [Boolean]
23
+ #
24
+ # @param state [Symbol, Courier::Models::JourneyState] Lifecycle state of a journey.
25
+ #
26
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
27
+ #
28
+ # @return [Courier::Models::JourneyResponse]
29
+ #
30
+ # @see Courier::Models::JourneyCreateParams
31
+ def create(params)
32
+ parsed, options = Courier::JourneyCreateParams.dump_request(params)
33
+ @client.request(
34
+ method: :post,
35
+ path: "journeys",
36
+ body: parsed,
37
+ model: Courier::JourneyResponse,
38
+ options: options
39
+ )
40
+ end
41
+
42
+ # Fetch a journey by id. Pass `?version=draft` (default `published`) to retrieve
43
+ # the working draft, or `?version=vN` to retrieve a historical version.
44
+ #
45
+ # @overload retrieve(template_id, version: nil, request_options: {})
46
+ #
47
+ # @param template_id [String] Journey id
48
+ #
49
+ # @param version [String] Version selector: `draft`, `published` (default), or `vN`.
50
+ #
51
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
52
+ #
53
+ # @return [Courier::Models::JourneyResponse]
54
+ #
55
+ # @see Courier::Models::JourneyRetrieveParams
56
+ def retrieve(template_id, params = {})
57
+ parsed, options = Courier::JourneyRetrieveParams.dump_request(params)
58
+ query = Courier::Internal::Util.encode_query_params(parsed)
59
+ @client.request(
60
+ method: :get,
61
+ path: ["journeys/%1$s", template_id],
62
+ query: query,
63
+ model: Courier::JourneyResponse,
64
+ options: options
65
+ )
66
+ end
67
+
6
68
  # Some parameter documentations has been truncated, see
7
69
  # {Courier::Models::JourneyListParams} for more details.
8
70
  #
@@ -31,14 +93,36 @@ module Courier
31
93
  )
32
94
  end
33
95
 
96
+ # Archive a journey. Archived journeys cannot be invoked. Existing journey runs
97
+ # continue to completion.
98
+ #
99
+ # @overload archive(template_id, request_options: {})
100
+ #
101
+ # @param template_id [String] Journey id
102
+ #
103
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
104
+ #
105
+ # @return [nil]
106
+ #
107
+ # @see Courier::Models::JourneyArchiveParams
108
+ def archive(template_id, params = {})
109
+ @client.request(
110
+ method: :delete,
111
+ path: ["journeys/%1$s", template_id],
112
+ model: NilClass,
113
+ options: params[:request_options]
114
+ )
115
+ end
116
+
34
117
  # Some parameter documentations has been truncated, see
35
118
  # {Courier::Models::JourneyInvokeParams} for more details.
36
119
  #
37
- # Invoke a journey run from a journey template.
120
+ # Invoke a journey by id or alias to start a new run. The response includes a
121
+ # `runId` identifying the run.
38
122
  #
39
123
  # @overload invoke(template_id, data: nil, profile: nil, user_id: nil, request_options: {})
40
124
  #
41
- # @param template_id [String] A unique identifier representing the journey template to be invoked. This could
125
+ # @param template_id [String] A unique identifier representing the journey to be invoked. Accepts a Journey ID
42
126
  #
43
127
  # @param data [Hash{Symbol=>Object}] Data payload passed to the journey. The expected shape can be predefined using t
44
128
  #
@@ -62,11 +146,92 @@ module Courier
62
146
  )
63
147
  end
64
148
 
149
+ # List published versions of a journey, ordered most recent first.
150
+ #
151
+ # @overload list_versions(template_id, request_options: {})
152
+ #
153
+ # @param template_id [String] Journey id
154
+ #
155
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
156
+ #
157
+ # @return [Courier::Models::JourneyVersionsListResponse]
158
+ #
159
+ # @see Courier::Models::JourneyListVersionsParams
160
+ def list_versions(template_id, params = {})
161
+ @client.request(
162
+ method: :get,
163
+ path: ["journeys/%1$s/versions", template_id],
164
+ model: Courier::JourneyVersionsListResponse,
165
+ options: params[:request_options]
166
+ )
167
+ end
168
+
169
+ # Publish the current draft as a new version. Body is optional; pass
170
+ # `{ "version": "vN" }` to roll back to a prior version instead. Returns 404 if
171
+ # the journey has no draft to publish.
172
+ #
173
+ # @overload publish(template_id, version: nil, request_options: {})
174
+ #
175
+ # @param template_id [String] Journey id
176
+ #
177
+ # @param version [String]
178
+ #
179
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
180
+ #
181
+ # @return [Courier::Models::JourneyResponse]
182
+ #
183
+ # @see Courier::Models::JourneyPublishParams
184
+ def publish(template_id, params = {})
185
+ parsed, options = Courier::JourneyPublishParams.dump_request(params)
186
+ @client.request(
187
+ method: :post,
188
+ path: ["journeys/%1$s/publish", template_id],
189
+ body: parsed,
190
+ model: Courier::JourneyResponse,
191
+ options: options
192
+ )
193
+ end
194
+
195
+ # Replace the journey draft. Updates the working draft only; call
196
+ # `POST /journeys/{templateId}/publish` to make it live, or pass
197
+ # `state: "PUBLISHED"` in this request to publish immediately. Send-node
198
+ # `template` ids must already exist and be scoped to this journey, and node ids
199
+ # must not be claimed by another journey.
200
+ #
201
+ # @overload replace(template_id, name:, nodes:, enabled: nil, state: nil, request_options: {})
202
+ #
203
+ # @param template_id [String] Journey id
204
+ #
205
+ # @param name [String]
206
+ #
207
+ # @param nodes [Array<Courier::Models::JourneyAPIInvokeTriggerNode, Courier::Models::JourneySegmentTriggerNode, Courier::Models::JourneySendNode, Courier::Models::JourneyDelayDurationNode, Courier::Models::JourneyDelayUntilNode, Courier::Models::JourneyFetchGetDeleteNode, Courier::Models::JourneyFetchPostPutNode, Courier::Models::JourneyAINode, Courier::Models::JourneyThrottleStaticNode, Courier::Models::JourneyThrottleDynamicNode, Courier::Models::JourneyExitNode, Courier::Models::JourneyNode::JourneyBranchNode>]
208
+ #
209
+ # @param enabled [Boolean]
210
+ #
211
+ # @param state [Symbol, Courier::Models::JourneyState] Lifecycle state of a journey.
212
+ #
213
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
214
+ #
215
+ # @return [Courier::Models::JourneyResponse]
216
+ #
217
+ # @see Courier::Models::JourneyReplaceParams
218
+ def replace(template_id, params)
219
+ parsed, options = Courier::JourneyReplaceParams.dump_request(params)
220
+ @client.request(
221
+ method: :put,
222
+ path: ["journeys/%1$s", template_id],
223
+ body: parsed,
224
+ model: Courier::JourneyResponse,
225
+ options: options
226
+ )
227
+ end
228
+
65
229
  # @api private
66
230
  #
67
231
  # @param client [Courier::Client]
68
232
  def initialize(client:)
69
233
  @client = client
234
+ @templates = Courier::Resources::Journeys::Templates.new(client: client)
70
235
  end
71
236
  end
72
237
  end
@@ -4,11 +4,13 @@ module Courier
4
4
  module Resources
5
5
  class Notifications
6
6
  class Checks
7
+ # Replace the checks for a notification template submission.
8
+ #
7
9
  # @overload update(submission_id, id:, checks:, request_options: {})
8
10
  #
9
- # @param submission_id [String] Path param
11
+ # @param submission_id [String] Path param: Submission ID.
10
12
  #
11
- # @param id [String] Path param
13
+ # @param id [String] Path param: Notification template ID.
12
14
  #
13
15
  # @param checks [Array<Courier::Models::BaseCheck>] Body param
14
16
  #
@@ -32,10 +34,14 @@ module Courier
32
34
  )
33
35
  end
34
36
 
37
+ # Retrieve the checks for a notification template submission.
38
+ #
35
39
  # @overload list(submission_id, id:, request_options: {})
36
40
  #
37
- # @param submission_id [String]
38
- # @param id [String]
41
+ # @param submission_id [String] Submission ID.
42
+ #
43
+ # @param id [String] Notification template ID.
44
+ #
39
45
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
40
46
  #
41
47
  # @return [Courier::Models::Notifications::CheckListResponse]
@@ -55,10 +61,14 @@ module Courier
55
61
  )
56
62
  end
57
63
 
64
+ # Cancel a notification template submission.
65
+ #
58
66
  # @overload delete(submission_id, id:, request_options: {})
59
67
  #
60
- # @param submission_id [String]
61
- # @param id [String]
68
+ # @param submission_id [String] Submission ID.
69
+ #
70
+ # @param id [String] Notification template ID.
71
+ #
62
72
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
63
73
  #
64
74
  # @return [nil]
@@ -14,13 +14,13 @@ module Courier
14
14
  #
15
15
  # @overload create(notification:, state: nil, request_options: {})
16
16
  #
17
- # @param notification [Courier::Models::NotificationTemplatePayload] Full document shape used in POST and PUT request bodies, and returned inside the
17
+ # @param notification [Courier::Models::NotificationTemplatePayload] Core template fields used in POST and PUT request bodies (nested under a `notifi
18
18
  #
19
19
  # @param state [Symbol, Courier::Models::NotificationTemplateCreateRequest::State] Template state after creation. Case-insensitive input, normalized to uppercase i
20
20
  #
21
21
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
22
22
  #
23
- # @return [Courier::Models::NotificationTemplateGetResponse]
23
+ # @return [Courier::Models::NotificationTemplateResponse]
24
24
  #
25
25
  # @see Courier::Models::NotificationCreateParams
26
26
  def create(params)
@@ -29,7 +29,7 @@ module Courier
29
29
  method: :post,
30
30
  path: "notifications",
31
31
  body: parsed,
32
- model: Courier::NotificationTemplateGetResponse,
32
+ model: Courier::NotificationTemplateResponse,
33
33
  options: options
34
34
  )
35
35
  end
@@ -48,7 +48,7 @@ module Courier
48
48
  #
49
49
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
50
50
  #
51
- # @return [Courier::Models::NotificationTemplateGetResponse]
51
+ # @return [Courier::Models::NotificationTemplateResponse]
52
52
  #
53
53
  # @see Courier::Models::NotificationRetrieveParams
54
54
  def retrieve(id, params = {})
@@ -58,7 +58,7 @@ module Courier
58
58
  method: :get,
59
59
  path: ["notifications/%1$s", id],
60
60
  query: query,
61
- model: Courier::NotificationTemplateGetResponse,
61
+ model: Courier::NotificationTemplateResponse,
62
62
  options: options
63
63
  )
64
64
  end
@@ -276,13 +276,13 @@ module Courier
276
276
  #
277
277
  # @param id [String] Template ID (nt\_ prefix).
278
278
  #
279
- # @param notification [Courier::Models::NotificationTemplatePayload] Full document shape used in POST and PUT request bodies, and returned inside the
279
+ # @param notification [Courier::Models::NotificationTemplatePayload] Core template fields used in POST and PUT request bodies (nested under a `notifi
280
280
  #
281
281
  # @param state [Symbol, Courier::Models::NotificationTemplateUpdateRequest::State] Template state after update. Case-insensitive input, normalized to uppercase in
282
282
  #
283
283
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
284
284
  #
285
- # @return [Courier::Models::NotificationTemplateGetResponse]
285
+ # @return [Courier::Models::NotificationTemplateResponse]
286
286
  #
287
287
  # @see Courier::Models::NotificationReplaceParams
288
288
  def replace(id, params)
@@ -291,7 +291,7 @@ module Courier
291
291
  method: :put,
292
292
  path: ["notifications/%1$s", id],
293
293
  body: parsed,
294
- model: Courier::NotificationTemplateGetResponse,
294
+ model: Courier::NotificationTemplateResponse,
295
295
  options: options
296
296
  )
297
297
  end
@@ -61,6 +61,38 @@ module Courier
61
61
  )
62
62
  end
63
63
 
64
+ # Deletes the tenant's notification template with the given `template_id`.
65
+ #
66
+ # Returns **204 No Content** with an empty body on success.
67
+ #
68
+ # Returns **404** if there is no template with this ID for the tenant, including a
69
+ # second `DELETE` after a successful removal.
70
+ #
71
+ # @overload delete(template_id, tenant_id:, request_options: {})
72
+ #
73
+ # @param template_id [String] Id of the template to remove from the tenant.
74
+ #
75
+ # @param tenant_id [String] Id of the tenant that owns the template.
76
+ #
77
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
78
+ #
79
+ # @return [nil]
80
+ #
81
+ # @see Courier::Models::Tenants::TemplateDeleteParams
82
+ def delete(template_id, params)
83
+ parsed, options = Courier::Tenants::TemplateDeleteParams.dump_request(params)
84
+ tenant_id =
85
+ parsed.delete(:tenant_id) do
86
+ raise ArgumentError.new("missing required path argument #{_1}")
87
+ end
88
+ @client.request(
89
+ method: :delete,
90
+ path: ["tenants/%1$s/templates/%2$s", tenant_id, template_id],
91
+ model: NilClass,
92
+ options: options
93
+ )
94
+ end
95
+
64
96
  # Some parameter documentations has been truncated, see
65
97
  # {Courier::Models::Tenants::TemplatePublishParams} for more details.
66
98
  #