trycourier 4.21.0 → 4.23.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 (231) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/lib/courier/client.rb +43 -0
  4. data/lib/courier/models/automations/invoke_invoke_ad_hoc_params.rb +13 -1
  5. data/lib/courier/models/automations/invoke_invoke_by_template_params.rb +13 -1
  6. data/lib/courier/models/brand_create_params.rb +13 -1
  7. data/lib/courier/models/broadcast.rb +132 -0
  8. data/lib/courier/models/broadcast_archive_params.rb +20 -0
  9. data/lib/courier/models/broadcast_cancel_params.rb +20 -0
  10. data/lib/courier/models/broadcast_create_params.rb +14 -0
  11. data/lib/courier/models/broadcast_duplicate_params.rb +20 -0
  12. data/lib/courier/models/broadcast_list_params.rb +30 -0
  13. data/lib/courier/models/broadcast_list_response.rb +24 -0
  14. data/lib/courier/models/broadcast_put_content_params.rb +20 -0
  15. data/lib/courier/models/broadcast_retrieve_content_params.rb +33 -0
  16. data/lib/courier/models/broadcast_retrieve_params.rb +20 -0
  17. data/lib/courier/models/broadcast_schedule.rb +59 -0
  18. data/lib/courier/models/broadcast_schedule_params.rb +20 -0
  19. data/lib/courier/models/broadcast_send_params.rb +20 -0
  20. data/lib/courier/models/broadcast_update_params.rb +20 -0
  21. data/lib/courier/models/create_broadcast_request.rb +43 -0
  22. data/lib/courier/models/inbox/message_delete_params.rb +22 -0
  23. data/lib/courier/models/inbox/message_restore_params.rb +22 -0
  24. data/lib/courier/models/journey_cancel_params.rb +13 -1
  25. data/lib/courier/models/journey_create_params.rb +13 -1
  26. data/lib/courier/models/journey_invoke_params.rb +13 -1
  27. data/lib/courier/models/journey_publish_params.rb +13 -1
  28. data/lib/courier/models/journeys/template_create_params.rb +13 -1
  29. data/lib/courier/models/journeys/template_publish_params.rb +13 -1
  30. data/lib/courier/models/lists/subscription_add_params.rb +13 -1
  31. data/lib/courier/models/notification_create_params.rb +13 -1
  32. data/lib/courier/models/notification_publish_params.rb +13 -1
  33. data/lib/courier/models/profile_create_params.rb +13 -1
  34. data/lib/courier/models/profiles/list_subscribe_params.rb +13 -1
  35. data/lib/courier/models/provider_create_params.rb +15 -1
  36. data/lib/courier/models/routing_strategy_create_params.rb +13 -1
  37. data/lib/courier/models/schedule_broadcast_request.rb +59 -0
  38. data/lib/courier/models/send_broadcast_request.rb +39 -0
  39. data/lib/courier/models/send_message_params.rb +15 -1
  40. data/lib/courier/models/update_broadcast_request.rb +18 -0
  41. data/lib/courier/models/users/preference_bulk_update_params.rb +15 -1
  42. data/lib/courier/models/users/preference_update_or_create_topic_params.rb +14 -4
  43. data/lib/courier/models/users/topic_preference.rb +21 -7
  44. data/lib/courier/models/workspace_preference_create_params.rb +13 -1
  45. data/lib/courier/models/workspace_preference_publish_params.rb +13 -1
  46. data/lib/courier/models/workspace_preferences/topic_create_params.rb +13 -1
  47. data/lib/courier/models.rb +38 -0
  48. data/lib/courier/resources/audiences.rb +12 -5
  49. data/lib/courier/resources/audit_events.rb +5 -2
  50. data/lib/courier/resources/auth.rb +5 -1
  51. data/lib/courier/resources/automations/invoke.rb +47 -23
  52. data/lib/courier/resources/automations.rb +6 -1
  53. data/lib/courier/resources/brands.rb +38 -12
  54. data/lib/courier/resources/broadcasts.rb +290 -0
  55. data/lib/courier/resources/digests/schedules.rb +4 -3
  56. data/lib/courier/resources/digests.rb +2 -0
  57. data/lib/courier/resources/inbound.rb +3 -1
  58. data/lib/courier/resources/inbox/messages.rb +58 -0
  59. data/lib/courier/resources/inbox.rb +19 -0
  60. data/lib/courier/resources/journeys/templates.rb +43 -25
  61. data/lib/courier/resources/journeys.rb +73 -44
  62. data/lib/courier/resources/lists/subscriptions.rb +22 -8
  63. data/lib/courier/resources/lists.rb +14 -5
  64. data/lib/courier/resources/messages.rb +14 -14
  65. data/lib/courier/resources/notifications/checks.rb +8 -3
  66. data/lib/courier/resources/notifications.rb +48 -30
  67. data/lib/courier/resources/profiles/lists.rb +19 -8
  68. data/lib/courier/resources/profiles.rb +25 -14
  69. data/lib/courier/resources/providers/catalog.rb +4 -4
  70. data/lib/courier/resources/providers.rb +27 -18
  71. data/lib/courier/resources/requests.rb +4 -1
  72. data/lib/courier/resources/routing_strategies.rb +24 -12
  73. data/lib/courier/resources/send.rb +14 -4
  74. data/lib/courier/resources/tenants/preferences/items.rb +6 -2
  75. data/lib/courier/resources/tenants/preferences.rb +2 -0
  76. data/lib/courier/resources/tenants/templates/versions.rb +4 -7
  77. data/lib/courier/resources/tenants/templates.rb +14 -19
  78. data/lib/courier/resources/tenants.rb +14 -5
  79. data/lib/courier/resources/translations.rb +6 -2
  80. data/lib/courier/resources/users/preferences.rb +23 -42
  81. data/lib/courier/resources/users/tenants.rb +12 -10
  82. data/lib/courier/resources/users/tokens.rb +14 -6
  83. data/lib/courier/resources/users.rb +6 -0
  84. data/lib/courier/resources/workspace_preferences/topics.rb +27 -19
  85. data/lib/courier/resources/workspace_preferences.rb +40 -20
  86. data/lib/courier/version.rb +1 -1
  87. data/lib/courier.rb +24 -1
  88. data/rbi/courier/client.rbi +41 -0
  89. data/rbi/courier/models/automations/invoke_invoke_ad_hoc_params.rbi +18 -0
  90. data/rbi/courier/models/automations/invoke_invoke_by_template_params.rbi +18 -0
  91. data/rbi/courier/models/brand_create_params.rbi +18 -0
  92. data/rbi/courier/models/broadcast.rbi +164 -0
  93. data/rbi/courier/models/broadcast_archive_params.rbi +35 -0
  94. data/rbi/courier/models/broadcast_cancel_params.rbi +35 -0
  95. data/rbi/courier/models/broadcast_create_params.rbi +27 -0
  96. data/rbi/courier/models/broadcast_duplicate_params.rbi +35 -0
  97. data/rbi/courier/models/broadcast_list_params.rbi +54 -0
  98. data/rbi/courier/models/broadcast_list_response.rbi +39 -0
  99. data/rbi/courier/models/broadcast_put_content_params.rbi +35 -0
  100. data/rbi/courier/models/broadcast_retrieve_content_params.rbi +57 -0
  101. data/rbi/courier/models/broadcast_retrieve_params.rbi +35 -0
  102. data/rbi/courier/models/broadcast_schedule.rbi +92 -0
  103. data/rbi/courier/models/broadcast_schedule_params.rbi +35 -0
  104. data/rbi/courier/models/broadcast_send_params.rbi +35 -0
  105. data/rbi/courier/models/broadcast_update_params.rbi +35 -0
  106. data/rbi/courier/models/create_broadcast_request.rbi +81 -0
  107. data/rbi/courier/models/inbox/message_delete_params.rbi +40 -0
  108. data/rbi/courier/models/inbox/message_restore_params.rbi +40 -0
  109. data/rbi/courier/models/journey_cancel_params.rbi +31 -5
  110. data/rbi/courier/models/journey_create_params.rbi +31 -5
  111. data/rbi/courier/models/journey_invoke_params.rbi +26 -2
  112. data/rbi/courier/models/journey_publish_params.rbi +26 -2
  113. data/rbi/courier/models/journeys/template_create_params.rbi +26 -2
  114. data/rbi/courier/models/journeys/template_publish_params.rbi +23 -1
  115. data/rbi/courier/models/lists/subscription_add_params.rbi +23 -1
  116. data/rbi/courier/models/notification_create_params.rbi +31 -5
  117. data/rbi/courier/models/notification_publish_params.rbi +26 -2
  118. data/rbi/courier/models/profile_create_params.rbi +23 -1
  119. data/rbi/courier/models/profiles/list_subscribe_params.rbi +23 -1
  120. data/rbi/courier/models/provider_create_params.rbi +18 -0
  121. data/rbi/courier/models/routing_strategy_create_params.rbi +31 -5
  122. data/rbi/courier/models/schedule_broadcast_request.rbi +103 -0
  123. data/rbi/courier/models/send_broadcast_request.rbi +77 -0
  124. data/rbi/courier/models/send_message_params.rbi +18 -0
  125. data/rbi/courier/models/update_broadcast_request.rbi +28 -0
  126. data/rbi/courier/models/users/preference_bulk_update_params.rbi +18 -0
  127. data/rbi/courier/models/users/preference_update_or_create_topic_params.rbi +14 -2
  128. data/rbi/courier/models/users/topic_preference.rbi +24 -2
  129. data/rbi/courier/models/workspace_preference_create_params.rbi +31 -5
  130. data/rbi/courier/models/workspace_preference_publish_params.rbi +31 -5
  131. data/rbi/courier/models/workspace_preferences/topic_create_params.rbi +26 -2
  132. data/rbi/courier/models.rbi +39 -0
  133. data/rbi/courier/resources/audiences.rbi +12 -5
  134. data/rbi/courier/resources/audit_events.rbi +5 -2
  135. data/rbi/courier/resources/auth.rbi +5 -1
  136. data/rbi/courier/resources/automations/invoke.rbi +48 -7
  137. data/rbi/courier/resources/automations.rbi +6 -1
  138. data/rbi/courier/resources/brands.rbi +37 -7
  139. data/rbi/courier/resources/broadcasts.rbi +199 -0
  140. data/rbi/courier/resources/digests/schedules.rbi +4 -3
  141. data/rbi/courier/resources/digests.rbi +2 -0
  142. data/rbi/courier/resources/inbound.rbi +3 -1
  143. data/rbi/courier/resources/inbox/messages.rbi +44 -0
  144. data/rbi/courier/resources/inbox.rbi +16 -0
  145. data/rbi/courier/resources/journeys/templates.rbi +47 -17
  146. data/rbi/courier/resources/journeys.rbi +93 -39
  147. data/rbi/courier/resources/lists/subscriptions.rbi +24 -5
  148. data/rbi/courier/resources/lists.rbi +14 -5
  149. data/rbi/courier/resources/messages.rbi +14 -14
  150. data/rbi/courier/resources/notifications/checks.rbi +8 -3
  151. data/rbi/courier/resources/notifications.rbi +58 -28
  152. data/rbi/courier/resources/profiles/lists.rbi +25 -6
  153. data/rbi/courier/resources/profiles.rbi +31 -11
  154. data/rbi/courier/resources/providers/catalog.rbi +4 -4
  155. data/rbi/courier/resources/providers.rbi +35 -19
  156. data/rbi/courier/resources/requests.rbi +4 -1
  157. data/rbi/courier/resources/routing_strategies.rbi +26 -10
  158. data/rbi/courier/resources/send.rbi +20 -3
  159. data/rbi/courier/resources/tenants/preferences/items.rbi +6 -2
  160. data/rbi/courier/resources/tenants/preferences.rbi +2 -0
  161. data/rbi/courier/resources/tenants/templates/versions.rbi +4 -7
  162. data/rbi/courier/resources/tenants/templates.rbi +14 -19
  163. data/rbi/courier/resources/tenants.rbi +14 -5
  164. data/rbi/courier/resources/translations.rbi +6 -2
  165. data/rbi/courier/resources/users/preferences.rbi +28 -40
  166. data/rbi/courier/resources/users/tenants.rbi +12 -10
  167. data/rbi/courier/resources/users/tokens.rbi +14 -6
  168. data/rbi/courier/resources/users.rbi +6 -0
  169. data/rbi/courier/resources/workspace_preferences/topics.rbi +37 -18
  170. data/rbi/courier/resources/workspace_preferences.rbi +51 -17
  171. data/sig/courier/client.rbs +4 -0
  172. data/sig/courier/models/automations/invoke_invoke_ad_hoc_params.rbs +15 -1
  173. data/sig/courier/models/automations/invoke_invoke_by_template_params.rbs +15 -1
  174. data/sig/courier/models/brand_create_params.rbs +15 -1
  175. data/sig/courier/models/broadcast.rbs +98 -0
  176. data/sig/courier/models/broadcast_archive_params.rbs +23 -0
  177. data/sig/courier/models/broadcast_cancel_params.rbs +23 -0
  178. data/sig/courier/models/broadcast_create_params.rbs +15 -0
  179. data/sig/courier/models/broadcast_duplicate_params.rbs +23 -0
  180. data/sig/courier/models/broadcast_list_params.rbs +30 -0
  181. data/sig/courier/models/broadcast_list_response.rbs +22 -0
  182. data/sig/courier/models/broadcast_put_content_params.rbs +25 -0
  183. data/sig/courier/models/broadcast_retrieve_content_params.rbs +30 -0
  184. data/sig/courier/models/broadcast_retrieve_params.rbs +23 -0
  185. data/sig/courier/models/broadcast_schedule.rbs +46 -0
  186. data/sig/courier/models/broadcast_schedule_params.rbs +25 -0
  187. data/sig/courier/models/broadcast_send_params.rbs +25 -0
  188. data/sig/courier/models/broadcast_update_params.rbs +25 -0
  189. data/sig/courier/models/create_broadcast_request.rbs +40 -0
  190. data/sig/courier/models/inbox/message_delete_params.rbs +25 -0
  191. data/sig/courier/models/inbox/message_restore_params.rbs +25 -0
  192. data/sig/courier/models/journey_cancel_params.rbs +20 -3
  193. data/sig/courier/models/journey_create_params.rbs +20 -3
  194. data/sig/courier/models/journey_invoke_params.rbs +18 -1
  195. data/sig/courier/models/journey_publish_params.rbs +18 -1
  196. data/sig/courier/models/journeys/template_create_params.rbs +18 -1
  197. data/sig/courier/models/journeys/template_publish_params.rbs +18 -1
  198. data/sig/courier/models/lists/subscription_add_params.rbs +15 -1
  199. data/sig/courier/models/notification_create_params.rbs +20 -3
  200. data/sig/courier/models/notification_publish_params.rbs +18 -2
  201. data/sig/courier/models/profile_create_params.rbs +18 -1
  202. data/sig/courier/models/profiles/list_subscribe_params.rbs +15 -1
  203. data/sig/courier/models/provider_create_params.rbs +15 -1
  204. data/sig/courier/models/routing_strategy_create_params.rbs +20 -3
  205. data/sig/courier/models/schedule_broadcast_request.rbs +48 -0
  206. data/sig/courier/models/send_broadcast_request.rbs +36 -0
  207. data/sig/courier/models/send_message_params.rbs +17 -1
  208. data/sig/courier/models/update_broadcast_request.rbs +13 -0
  209. data/sig/courier/models/users/preference_bulk_update_params.rbs +15 -1
  210. data/sig/courier/models/workspace_preference_create_params.rbs +20 -3
  211. data/sig/courier/models/workspace_preference_publish_params.rbs +20 -3
  212. data/sig/courier/models/workspace_preferences/topic_create_params.rbs +18 -1
  213. data/sig/courier/models.rbs +38 -0
  214. data/sig/courier/resources/automations/invoke.rbs +4 -0
  215. data/sig/courier/resources/brands.rbs +2 -0
  216. data/sig/courier/resources/broadcasts.rbs +74 -0
  217. data/sig/courier/resources/inbox/messages.rbs +19 -0
  218. data/sig/courier/resources/inbox.rbs +9 -0
  219. data/sig/courier/resources/journeys/templates.rbs +4 -0
  220. data/sig/courier/resources/journeys.rbs +8 -0
  221. data/sig/courier/resources/lists/subscriptions.rbs +2 -0
  222. data/sig/courier/resources/notifications.rbs +4 -0
  223. data/sig/courier/resources/profiles/lists.rbs +2 -0
  224. data/sig/courier/resources/profiles.rbs +2 -0
  225. data/sig/courier/resources/providers.rbs +2 -0
  226. data/sig/courier/resources/routing_strategies.rbs +2 -0
  227. data/sig/courier/resources/send.rbs +2 -0
  228. data/sig/courier/resources/users/preferences.rbs +2 -0
  229. data/sig/courier/resources/workspace_preferences/topics.rbs +2 -0
  230. data/sig/courier/resources/workspace_preferences.rbs +4 -0
  231. metadata +71 -2
@@ -3,11 +3,14 @@
3
3
  module Courier
4
4
  module Resources
5
5
  class Users
6
+ # Read and write a single user's notification preferences, per topic and per
7
+ # channel.
6
8
  class Preferences
7
9
  # Some parameter documentations has been truncated, see
8
10
  # {Courier::Models::Users::PreferenceRetrieveParams} for more details.
9
11
  #
10
- # Fetch all user preferences.
12
+ # Returns a user's preference overrides with paging, one entry per subscription
13
+ # topic they have set a choice for.
11
14
  #
12
15
  # @overload retrieve(user_id, tenant_id: nil, request_options: {})
13
16
  #
@@ -35,23 +38,8 @@ module Courier
35
38
  # Some parameter documentations has been truncated, see
36
39
  # {Courier::Models::Users::PreferenceBulkReplaceParams} for more details.
37
40
  #
38
- # Replace a user's complete set of preference overrides in a single request. The
39
- # topics in the request body become the recipient's entire set of overrides:
40
- # listed topics are created or updated, and every existing override that is not
41
- # included in the body is reset to its topic default. Submitting an empty `topics`
42
- # array is a valid clear-all that resets every existing override.
43
- #
44
- # This operation is validation-atomic (all-or-nothing): structural validation
45
- # fails fast with a single `400`, and if any topic is semantically invalid (an
46
- # unknown topic, a `REQUIRED` topic that cannot be opted out, or a custom routing
47
- # request that is not available on the workspace's plan) the request returns a
48
- # single `400` aggregating every failure in `errors` and writes nothing. On
49
- # success it returns `200` with `items` (the complete resulting override set) and
50
- # `deleted` (the ids of the overrides that were reset to default).
51
- #
52
- # Every `topic_id` in the response — in `items`, `deleted`, and any `errors` — is
53
- # returned in Courier's canonical topic id form, regardless of the form supplied
54
- # in the request.
41
+ # Replaces a user's entire set of preference overrides. Any topic you leave out is
42
+ # reset to its default, so send the full set rather than a subset.
55
43
  #
56
44
  # @overload bulk_replace(user_id, topics:, tenant_id: nil, request_options: {})
57
45
  #
@@ -83,25 +71,10 @@ module Courier
83
71
  # Some parameter documentations has been truncated, see
84
72
  # {Courier::Models::Users::PreferenceBulkUpdateParams} for more details.
85
73
  #
86
- # Additively create or update a user's preferences for one or more subscription
87
- # topics in a single request. Only the topics included in the request body are
88
- # created or updated; any existing overrides for topics not listed are left
89
- # untouched.
90
- #
91
- # Structural validation of the request body fails fast with a single `400`. Beyond
92
- # that, each topic is processed independently (partial-success, not
93
- # all-or-nothing): valid topics are written and returned in `items`, while topics
94
- # that cannot be applied are collected in `errors` with a per-topic `reason` (for
95
- # example an unknown topic, a `REQUIRED` topic that cannot be opted out, a custom
96
- # routing request that is not available on the workspace's plan, or a write
97
- # failure). The request therefore returns `200` with both lists whenever the body
98
- # is structurally valid.
99
- #
100
- # Every `topic_id` in the response — in both `items` and `errors` — is returned in
101
- # Courier's canonical topic id form, regardless of the form supplied in the
102
- # request.
74
+ # Adds or updates a user's preferences for several subscription topics at once.
75
+ # Topics you leave out keep whatever they were set to before.
103
76
  #
104
- # @overload bulk_update(user_id, topics:, tenant_id: nil, request_options: {})
77
+ # @overload bulk_update(user_id, topics:, tenant_id: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {})
105
78
  #
106
79
  # @param user_id [String] Path param: A unique identifier associated with the user whose preferences you w
107
80
  #
@@ -109,6 +82,10 @@ module Courier
109
82
  #
110
83
  # @param tenant_id [String, nil] Query param: Update the preferences of a user for this specific tenant context.
111
84
  #
85
+ # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv
86
+ #
87
+ # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest
88
+ #
112
89
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
113
90
  #
114
91
  # @return [Courier::Models::Users::PreferenceBulkUpdateResponse]
@@ -116,13 +93,16 @@ module Courier
116
93
  # @see Courier::Models::Users::PreferenceBulkUpdateParams
117
94
  def bulk_update(user_id, params)
118
95
  query_params = [:tenant_id]
96
+ header_params =
97
+ {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"}
119
98
  parsed, options = Courier::Users::PreferenceBulkUpdateParams.dump_request(params)
120
99
  query = Courier::Internal::Util.encode_query_params(parsed.slice(*query_params))
121
100
  @client.request(
122
101
  method: :post,
123
102
  path: ["users/%1$s/preferences", user_id],
124
103
  query: query,
125
- body: parsed.except(*query_params),
104
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
105
+ body: parsed.except(*query_params, *header_params.keys),
126
106
  model: Courier::Models::Users::PreferenceBulkUpdateResponse,
127
107
  options: options
128
108
  )
@@ -131,9 +111,8 @@ module Courier
131
111
  # Some parameter documentations has been truncated, see
132
112
  # {Courier::Models::Users::PreferenceDeleteTopicParams} for more details.
133
113
  #
134
- # Remove a user's preferences for a specific subscription topic, resetting the
135
- # topic to its effective default. This operation is idempotent: deleting a
136
- # preference that does not exist succeeds with no error.
114
+ # Removes a user's override for one subscription topic, resetting it to the
115
+ # effective default from the tenant or workspace.
137
116
  #
138
117
  # @overload delete_topic(topic_id, user_id:, tenant_id: nil, request_options: {})
139
118
  #
@@ -167,7 +146,8 @@ module Courier
167
146
  # Some parameter documentations has been truncated, see
168
147
  # {Courier::Models::Users::PreferenceRetrieveTopicParams} for more details.
169
148
  #
170
- # Fetch user preferences for a specific subscription topic.
149
+ # Returns a user's opt-in status and channel choices for one subscription topic,
150
+ # or the effective default if they have set no override.
171
151
  #
172
152
  # @overload retrieve_topic(topic_id, user_id:, tenant_id: nil, request_options: {})
173
153
  #
@@ -201,7 +181,8 @@ module Courier
201
181
  # Some parameter documentations has been truncated, see
202
182
  # {Courier::Models::Users::PreferenceUpdateOrCreateTopicParams} for more details.
203
183
  #
204
- # Update or Create user preferences for a specific subscription topic.
184
+ # Sets a user's opt-in status and channel choices for one subscription topic,
185
+ # overriding the tenant default for that topic only.
205
186
  #
206
187
  # @overload update_or_create_topic(topic_id, user_id:, topic:, tenant_id: nil, request_options: {})
207
188
  #
@@ -3,11 +3,14 @@
3
3
  module Courier
4
4
  module Resources
5
5
  class Users
6
+ # Associate a user with one or more tenants, and read or remove those
7
+ # associations.
6
8
  class Tenants
7
9
  # Some parameter documentations has been truncated, see
8
10
  # {Courier::Models::Users::TenantListParams} for more details.
9
11
  #
10
- # Returns a paginated list of user tenant associations.
12
+ # Returns the tenants a user belongs to, with cursor paging. A user can belong to
13
+ # many tenants, each with its own profile and preferences.
11
14
  #
12
15
  # @overload list(user_id, cursor: nil, limit: nil, request_options: {})
13
16
  #
@@ -34,9 +37,8 @@ module Courier
34
37
  )
35
38
  end
36
39
 
37
- # This endpoint is used to add a user to multiple tenants in one call. A custom
38
- # profile can also be supplied for each tenant. This profile will be merged with
39
- # the user's main profile when sending to the user with that tenant.
40
+ # Adds a user to several tenants in one call, each optionally with a per-tenant
41
+ # profile that overrides their workspace profile.
40
42
  #
41
43
  # @overload add_multiple(user_id, tenants:, request_options: {})
42
44
  #
@@ -60,10 +62,8 @@ module Courier
60
62
  )
61
63
  end
62
64
 
63
- # This endpoint is used to add a single tenant.
64
- #
65
- # A custom profile can also be supplied with the tenant. This profile will be
66
- # merged with the user's main profile when sending to the user with that tenant.
65
+ # Adds a user to one tenant, optionally with a tenant-specific profile that
66
+ # overrides their workspace profile for sends in that tenant.
67
67
  #
68
68
  # @overload add_single(tenant_id, user_id:, profile: nil, request_options: {})
69
69
  #
@@ -93,7 +93,8 @@ module Courier
93
93
  )
94
94
  end
95
95
 
96
- # Removes a user from any tenants they may have been associated with.
96
+ # Removes a user from every tenant they belong to in one call. Their
97
+ # workspace-level profile is a separate resource.
97
98
  #
98
99
  # @overload remove_all(user_id, request_options: {})
99
100
  #
@@ -113,7 +114,8 @@ module Courier
113
114
  )
114
115
  end
115
116
 
116
- # Removes a user from the supplied tenant.
117
+ # Removes a user from one tenant. Their other tenant memberships and workspace
118
+ # profile are managed through separate endpoints.
117
119
  #
118
120
  # @overload remove_single(tenant_id, user_id:, request_options: {})
119
121
  #
@@ -3,8 +3,11 @@
3
3
  module Courier
4
4
  module Resources
5
5
  class Users
6
+ # Register and manage the APNS and FCM device tokens Courier delivers push
7
+ # notifications to.
6
8
  class Tokens
7
- # Get single token available for a `:token`
9
+ # Returns one device token with its provider key, status and status reason, expiry
10
+ # date, and any properties stored alongside it.
8
11
  #
9
12
  # @overload retrieve(token, user_id:, request_options: {})
10
13
  #
@@ -31,7 +34,8 @@ module Courier
31
34
  )
32
35
  end
33
36
 
34
- # Apply a JSON Patch (RFC 6902) to the specified token.
37
+ # Applies a JSON Patch to a device token, changing its status, expiry, or
38
+ # properties without re-registering it.
35
39
  #
36
40
  # @overload update(token, user_id:, patch:, request_options: {})
37
41
  #
@@ -61,7 +65,8 @@ module Courier
61
65
  )
62
66
  end
63
67
 
64
- # Gets all tokens available for a :user_id
68
+ # Returns every device token registered for a user, each with its provider key,
69
+ # status, and expiry date.
65
70
  #
66
71
  # @overload list(user_id, request_options: {})
67
72
  #
@@ -81,7 +86,8 @@ module Courier
81
86
  )
82
87
  end
83
88
 
84
- # Delete User Token
89
+ # Deletes one device token for a user, addressed by the token value, so push sends
90
+ # no longer target that device.
85
91
  #
86
92
  # @overload delete(token, user_id:, request_options: {})
87
93
  #
@@ -108,7 +114,8 @@ module Courier
108
114
  )
109
115
  end
110
116
 
111
- # Adds multiple tokens to a user and overwrites matching existing tokens.
117
+ # Registers several device tokens for a user in one call, overwriting any stored
118
+ # token with a matching value.
112
119
  #
113
120
  # @overload add_multiple(user_id, request_options: {})
114
121
  #
@@ -131,7 +138,8 @@ module Courier
131
138
  # Some parameter documentations has been truncated, see
132
139
  # {Courier::Models::Users::TokenAddSingleParams} for more details.
133
140
  #
134
- # Adds a single token to a user and overwrites a matching existing token.
141
+ # Registers one device token for a user against a provider key, overwriting the
142
+ # token if it already exists. Push sends resolve tokens per user.
135
143
  #
136
144
  # @overload add_single(token, user_id:, provider_key:, device: nil, expiry_date: nil, properties: nil, tracking: nil, request_options: {})
137
145
  #
@@ -3,12 +3,18 @@
3
3
  module Courier
4
4
  module Resources
5
5
  class Users
6
+ # Read and write a single user's notification preferences, per topic and per
7
+ # channel.
6
8
  # @return [Courier::Resources::Users::Preferences]
7
9
  attr_reader :preferences
8
10
 
11
+ # Associate a user with one or more tenants, and read or remove those
12
+ # associations.
9
13
  # @return [Courier::Resources::Users::Tenants]
10
14
  attr_reader :tenants
11
15
 
16
+ # Register and manage the APNS and FCM device tokens Courier delivers push
17
+ # notifications to.
12
18
  # @return [Courier::Resources::Users::Tokens]
13
19
  attr_reader :tokens
14
20
 
@@ -3,31 +3,36 @@
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.
6
8
  class Topics
7
9
  # Some parameter documentations has been truncated, see
8
10
  # {Courier::Models::WorkspacePreferences::TopicCreateParams} for more details.
9
11
  #
10
- # Create a subscription preference topic inside a workspace preference. Fails with
11
- # 404 if the workspace preference does not exist. The topic id is generated and
12
- # returned.
12
+ # Creates a subscription topic inside a workspace preference. The default status
13
+ # sets whether users start opted in, opted out, or required.
13
14
  #
14
- # @overload create(section_id, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {})
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: {})
15
16
  #
16
- # @param section_id [String] Id of the workspace preference to create the topic in.
17
+ # @param section_id [String] Path param: Id of the workspace preference to create the topic in.
17
18
  #
18
- # @param default_status [Symbol, Courier::Models::WorkspacePreferenceTopicCreateRequest::DefaultStatus] The default subscription status applied when a recipient has not set their own.
19
+ # @param default_status [Symbol, Courier::Models::WorkspacePreferenceTopicCreateRequest::DefaultStatus] Body param: The default subscription status applied when a recipient has not set
19
20
  #
20
- # @param name [String] Human-readable name for the preference topic.
21
+ # @param name [String] Body param: Human-readable name for the preference topic.
22
+ #
23
+ # @param allowed_preferences [Array<Symbol, Courier::Models::WorkspacePreferenceTopicCreateRequest::AllowedPreference>, nil] Body param: Preference controls a recipient may customize for this topic. Defaul
24
+ #
25
+ # @param description [String, nil] Body param: Optional description shown under the topic on the hosted preferences
21
26
  #
22
- # @param allowed_preferences [Array<Symbol, Courier::Models::WorkspacePreferenceTopicCreateRequest::AllowedPreference>, nil] Preference controls a recipient may customize for this topic. Defaults to empty
27
+ # @param include_unsubscribe_header [Boolean, nil] Body param: Whether to include a list-unsubscribe header on emails for this topi
23
28
  #
24
- # @param description [String, nil] Optional description shown under the topic on the hosted preferences page.
29
+ # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Body param: Default channels delivered for this topic. Defaults to empty if omit
25
30
  #
26
- # @param include_unsubscribe_header [Boolean, nil] Whether to include a list-unsubscribe header on emails for this topic.
31
+ # @param topic_data [Hash{Symbol=>Object}, nil] Body param: Arbitrary metadata associated with the topic.
27
32
  #
28
- # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels delivered for this topic. Defaults to empty if omitted.
33
+ # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv
29
34
  #
30
- # @param topic_data [Hash{Symbol=>Object}, nil] Arbitrary metadata associated with the topic.
35
+ # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest
31
36
  #
32
37
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
33
38
  #
@@ -36,18 +41,20 @@ module Courier
36
41
  # @see Courier::Models::WorkspacePreferences::TopicCreateParams
37
42
  def create(section_id, params)
38
43
  parsed, options = Courier::WorkspacePreferences::TopicCreateParams.dump_request(params)
44
+ header_params =
45
+ {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"}
39
46
  @client.request(
40
47
  method: :post,
41
48
  path: ["preferences/sections/%1$s/topics", section_id],
42
- body: parsed,
49
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
50
+ body: parsed.except(*header_params.keys),
43
51
  model: Courier::WorkspacePreferenceTopicGetResponse,
44
52
  options: options
45
53
  )
46
54
  end
47
55
 
48
- # Retrieve a topic within a workspace preference. Returns 404 if the workspace
49
- # preference does not exist, the topic does not exist, or the topic belongs to a
50
- # different workspace preference.
56
+ # Returns one subscription topic with its default status, routing options, allowed
57
+ # preferences, and unsubscribe header setting.
51
58
  #
52
59
  # @overload retrieve(topic_id, section_id:, request_options: {})
53
60
  #
@@ -74,7 +81,8 @@ module Courier
74
81
  )
75
82
  end
76
83
 
77
- # List the topics in a workspace preference.
84
+ # Returns the subscription topics inside a workspace preference, each with its
85
+ # default status and routing options.
78
86
  #
79
87
  # @overload list(section_id, request_options: {})
80
88
  #
@@ -94,8 +102,8 @@ module Courier
94
102
  )
95
103
  end
96
104
 
97
- # Archive a topic and remove it from its workspace preference. Same 404 rules as
98
- # GET.
105
+ # Archives a subscription topic and removes it from its workspace preference,
106
+ # addressed by section id and topic id.
99
107
  #
100
108
  # @overload archive(topic_id, section_id:, request_options: {})
101
109
  #
@@ -2,23 +2,33 @@
2
2
 
3
3
  module Courier
4
4
  module Resources
5
+ # Manage the workspace catalog of subscription topics, the sections that group
6
+ # them, and publishing the preference page.
5
7
  class WorkspacePreferences
8
+ # Manage the workspace catalog of subscription topics, the sections that group
9
+ # them, and publishing the preference page.
6
10
  # @return [Courier::Resources::WorkspacePreferences::Topics]
7
11
  attr_reader :topics
8
12
 
9
- # Create a workspace preference. The workspace preference id is generated and
10
- # returned. Topics are created inside a workspace preference via POST
11
- # /preferences/sections/{section_id}/topics.
13
+ # Some parameter documentations has been truncated, see
14
+ # {Courier::Models::WorkspacePreferenceCreateParams} for more details.
12
15
  #
13
- # @overload create(name:, description: nil, has_custom_routing: nil, routing_options: nil, request_options: {})
16
+ # Creates a workspace preference and returns its generated id. Add subscription
17
+ # topics to it afterwards with the topics endpoint.
14
18
  #
15
- # @param name [String] Human-readable name for the workspace preference.
19
+ # @overload create(name:, description: nil, has_custom_routing: nil, routing_options: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {})
16
20
  #
17
- # @param description [String, nil] Optional description shown under the section on the hosted preferences page.
21
+ # @param name [String] Body param: Human-readable name for the workspace preference.
18
22
  #
19
- # @param has_custom_routing [Boolean, nil] Whether the workspace preference defines custom routing for its topics.
23
+ # @param description [String, nil] Body param: Optional description shown under the section on the hosted preferenc
24
+ #
25
+ # @param has_custom_routing [Boolean, nil] Body param: Whether the workspace preference defines custom routing for its topi
26
+ #
27
+ # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Body param: Default channels for the workspace preference. Defaults to empty if
20
28
  #
21
- # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels for the workspace preference. Defaults to empty if omitted.
29
+ # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv
30
+ #
31
+ # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest
22
32
  #
23
33
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
24
34
  #
@@ -27,16 +37,20 @@ module Courier
27
37
  # @see Courier::Models::WorkspacePreferenceCreateParams
28
38
  def create(params)
29
39
  parsed, options = Courier::WorkspacePreferenceCreateParams.dump_request(params)
40
+ header_params =
41
+ {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"}
30
42
  @client.request(
31
43
  method: :post,
32
44
  path: "preferences/sections",
33
- body: parsed,
45
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
46
+ body: parsed.except(*header_params.keys),
34
47
  model: Courier::WorkspacePreferenceGetResponse,
35
48
  options: options
36
49
  )
37
50
  end
38
51
 
39
- # Retrieve a workspace preference by id, including its topics.
52
+ # Returns one workspace preference by id, including its subscription topics,
53
+ # routing options, and custom routing flag.
40
54
  #
41
55
  # @overload retrieve(section_id, request_options: {})
42
56
  #
@@ -56,8 +70,8 @@ module Courier
56
70
  )
57
71
  end
58
72
 
59
- # List the workspace's preferences. Each workspace preference embeds its topics.
60
- # Scoped to the workspace of the API key.
73
+ # Returns the workspace's preferences, each embedding its subscription topics,
74
+ # routing options, and whether custom routing is allowed.
61
75
  #
62
76
  # @overload list(request_options: {})
63
77
  #
@@ -99,17 +113,20 @@ module Courier
99
113
  # Some parameter documentations has been truncated, see
100
114
  # {Courier::Models::WorkspacePreferencePublishParams} for more details.
101
115
  #
102
- # Publish the workspace's preferences page. Takes a snapshot of every workspace
103
- # preference with its topics under a new published version, making the current
104
- # state visible on the hosted preferences page (non-draft).
116
+ # Publishes the workspace preference page, snapshotting every preference and
117
+ # topic, and returns the page id and a preview URL.
118
+ #
119
+ # @overload publish(brand_id: nil, description: nil, heading: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {})
105
120
  #
106
- # @overload publish(brand_id: nil, description: nil, heading: nil, request_options: {})
121
+ # @param brand_id [String, nil] Body param: Brand for the hosted page - "default" (workspace default brand), "no
107
122
  #
108
- # @param brand_id [String, nil] Brand for the hosted page - "default" (workspace default brand), "none" (no bran
123
+ # @param description [String, nil] Body param: Description shown under the heading on the hosted preferences page.
109
124
  #
110
- # @param description [String, nil] Description shown under the heading on the hosted preferences page.
125
+ # @param heading [String, nil] Body param: Heading shown at the top of the hosted preferences page.
111
126
  #
112
- # @param heading [String, nil] Heading shown at the top of the hosted preferences page.
127
+ # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv
128
+ #
129
+ # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest
113
130
  #
114
131
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
115
132
  #
@@ -118,10 +135,13 @@ module Courier
118
135
  # @see Courier::Models::WorkspacePreferencePublishParams
119
136
  def publish(params = {})
120
137
  parsed, options = Courier::WorkspacePreferencePublishParams.dump_request(params)
138
+ header_params =
139
+ {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"}
121
140
  @client.request(
122
141
  method: :post,
123
142
  path: "preferences/publish",
124
- body: parsed,
143
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
144
+ body: parsed.except(*header_params.keys),
125
145
  model: Courier::PublishPreferencesResponse,
126
146
  options: options
127
147
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Courier
4
- VERSION = "4.21.0"
4
+ VERSION = "4.23.0"
5
5
  end
data/lib/courier.rb CHANGED
@@ -54,6 +54,11 @@ require_relative "courier/internal/transport/pooled_net_requester"
54
54
  require_relative "courier/client"
55
55
  require_relative "courier/models/elemental_base_node"
56
56
  require_relative "courier/models/brand_template"
57
+ require_relative "courier/models/create_broadcast_request"
58
+ require_relative "courier/models/notification_content_put_request"
59
+ require_relative "courier/models/schedule_broadcast_request"
60
+ require_relative "courier/models/send_broadcast_request"
61
+ require_relative "courier/models/update_broadcast_request"
57
62
  require_relative "courier/models/base_check"
58
63
  require_relative "courier/models/subscription_topic_new"
59
64
  require_relative "courier/models/elemental_channel_node"
@@ -63,7 +68,6 @@ require_relative "courier/models/journeys_invoke_request"
63
68
  require_relative "courier/models/journey_publish_request"
64
69
  require_relative "courier/models/journey_template_create_request"
65
70
  require_relative "courier/models/journey_template_publish_request"
66
- require_relative "courier/models/notification_content_put_request"
67
71
  require_relative "courier/models/notification_locale_put_request"
68
72
  require_relative "courier/models/journey_template_replace_request"
69
73
  require_relative "courier/models/message_details"
@@ -124,6 +128,20 @@ require_relative "courier/models/brand_settings_in_app"
124
128
  require_relative "courier/models/brand_snippet"
125
129
  require_relative "courier/models/brand_snippets"
126
130
  require_relative "courier/models/brand_update_params"
131
+ require_relative "courier/models/broadcast"
132
+ require_relative "courier/models/broadcast_archive_params"
133
+ require_relative "courier/models/broadcast_cancel_params"
134
+ require_relative "courier/models/broadcast_create_params"
135
+ require_relative "courier/models/broadcast_duplicate_params"
136
+ require_relative "courier/models/broadcast_list_params"
137
+ require_relative "courier/models/broadcast_list_response"
138
+ require_relative "courier/models/broadcast_put_content_params"
139
+ require_relative "courier/models/broadcast_retrieve_content_params"
140
+ require_relative "courier/models/broadcast_retrieve_params"
141
+ require_relative "courier/models/broadcast_schedule"
142
+ require_relative "courier/models/broadcast_schedule_params"
143
+ require_relative "courier/models/broadcast_send_params"
144
+ require_relative "courier/models/broadcast_update_params"
127
145
  require_relative "courier/models/cancel_journey_response"
128
146
  require_relative "courier/models/channel"
129
147
  require_relative "courier/models/channel_classification"
@@ -158,6 +176,8 @@ require_relative "courier/models/filter_config"
158
176
  require_relative "courier/models/icons"
159
177
  require_relative "courier/models/inbound_track_event_params"
160
178
  require_relative "courier/models/inbound_track_event_response"
179
+ require_relative "courier/models/inbox/message_delete_params"
180
+ require_relative "courier/models/inbox/message_restore_params"
161
181
  require_relative "courier/models/intercom"
162
182
  require_relative "courier/models/intercom_recipient"
163
183
  require_relative "courier/models/journey"
@@ -421,9 +441,12 @@ require_relative "courier/resources/auth"
421
441
  require_relative "courier/resources/automations"
422
442
  require_relative "courier/resources/automations/invoke"
423
443
  require_relative "courier/resources/brands"
444
+ require_relative "courier/resources/broadcasts"
424
445
  require_relative "courier/resources/digests"
425
446
  require_relative "courier/resources/digests/schedules"
426
447
  require_relative "courier/resources/inbound"
448
+ require_relative "courier/resources/inbox"
449
+ require_relative "courier/resources/inbox/messages"
427
450
  require_relative "courier/resources/journeys"
428
451
  require_relative "courier/resources/journeys/templates"
429
452
  require_relative "courier/resources/lists"