notiflows 0.0.1

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 +7 -0
  2. data/README.md +305 -0
  3. data/SECURITY.md +27 -0
  4. data/lib/notiflows/client.rb +117 -0
  5. data/lib/notiflows/errors.rb +228 -0
  6. data/lib/notiflows/file_part.rb +58 -0
  7. data/lib/notiflows/internal/cursor_page.rb +100 -0
  8. data/lib/notiflows/internal/transport/base_client.rb +573 -0
  9. data/lib/notiflows/internal/transport/pooled_net_requester.rb +210 -0
  10. data/lib/notiflows/internal/type/array_of.rb +168 -0
  11. data/lib/notiflows/internal/type/base_model.rb +531 -0
  12. data/lib/notiflows/internal/type/base_page.rb +55 -0
  13. data/lib/notiflows/internal/type/boolean.rb +77 -0
  14. data/lib/notiflows/internal/type/converter.rb +327 -0
  15. data/lib/notiflows/internal/type/enum.rb +131 -0
  16. data/lib/notiflows/internal/type/file_input.rb +111 -0
  17. data/lib/notiflows/internal/type/hash_of.rb +188 -0
  18. data/lib/notiflows/internal/type/request_parameters.rb +42 -0
  19. data/lib/notiflows/internal/type/union.rb +237 -0
  20. data/lib/notiflows/internal/type/unknown.rb +81 -0
  21. data/lib/notiflows/internal/util.rb +920 -0
  22. data/lib/notiflows/internal.rb +20 -0
  23. data/lib/notiflows/models/delivery.rb +189 -0
  24. data/lib/notiflows/models/delivery_list_params.rb +78 -0
  25. data/lib/notiflows/models/delivery_retrieve_params.rb +14 -0
  26. data/lib/notiflows/models/notification.rb +151 -0
  27. data/lib/notiflows/models/notification_list_deliveries_params.rb +78 -0
  28. data/lib/notiflows/models/notification_list_params.rb +70 -0
  29. data/lib/notiflows/models/notification_retrieve_params.rb +14 -0
  30. data/lib/notiflows/models/notiflow_run_params.rb +197 -0
  31. data/lib/notiflows/models/notiflow_run_response.rb +19 -0
  32. data/lib/notiflows/models/topic.rb +27 -0
  33. data/lib/notiflows/models/topic_delete_params.rb +14 -0
  34. data/lib/notiflows/models/topic_list_params.rb +38 -0
  35. data/lib/notiflows/models/topic_retrieve_params.rb +14 -0
  36. data/lib/notiflows/models/topics/bulk_operation_response.rb +51 -0
  37. data/lib/notiflows/models/topics/bulk_subscribe_request.rb +20 -0
  38. data/lib/notiflows/models/topics/subscription_list_params.rb +56 -0
  39. data/lib/notiflows/models/topics/subscription_subscribe_bulk_params.rb +16 -0
  40. data/lib/notiflows/models/topics/subscription_unsubscribe_bulk_params.rb +16 -0
  41. data/lib/notiflows/models/user.rb +111 -0
  42. data/lib/notiflows/models/user_delete_params.rb +14 -0
  43. data/lib/notiflows/models/user_list_params.rb +54 -0
  44. data/lib/notiflows/models/user_retrieve_params.rb +14 -0
  45. data/lib/notiflows/models/user_upsert_params.rb +122 -0
  46. data/lib/notiflows/models/users/channel_setting_delete_params.rb +22 -0
  47. data/lib/notiflows/models/users/channel_setting_retrieve_params.rb +22 -0
  48. data/lib/notiflows/models/users/channel_setting_update_params.rb +45 -0
  49. data/lib/notiflows/models/users/channel_settings.rb +91 -0
  50. data/lib/notiflows/models/users/delivery_list_params.rb +80 -0
  51. data/lib/notiflows/models/users/delivery_retrieve_params.rb +22 -0
  52. data/lib/notiflows/models/users/mobile_push_settings.rb +20 -0
  53. data/lib/notiflows/models/users/notification_list_params.rb +72 -0
  54. data/lib/notiflows/models/users/notification_retrieve_params.rb +22 -0
  55. data/lib/notiflows/models/users/preference_retrieve_params.rb +16 -0
  56. data/lib/notiflows/models/users/preference_update_params.rb +16 -0
  57. data/lib/notiflows/models/users/preferences.rb +116 -0
  58. data/lib/notiflows/models/users/slack_settings.rb +29 -0
  59. data/lib/notiflows/models/users/subscription.rb +45 -0
  60. data/lib/notiflows/models/users/subscription_list_params.rb +56 -0
  61. data/lib/notiflows/models/users/subscription_retrieve_params.rb +22 -0
  62. data/lib/notiflows/models/users/subscription_subscribe_params.rb +28 -0
  63. data/lib/notiflows/models/users/subscription_unsubscribe_params.rb +22 -0
  64. data/lib/notiflows/models/users/update_preferences_request.rb +45 -0
  65. data/lib/notiflows/models.rb +79 -0
  66. data/lib/notiflows/request_options.rb +77 -0
  67. data/lib/notiflows/resources/deliveries.rb +77 -0
  68. data/lib/notiflows/resources/notifications.rb +112 -0
  69. data/lib/notiflows/resources/notiflows.rb +60 -0
  70. data/lib/notiflows/resources/topics/subscriptions.rb +106 -0
  71. data/lib/notiflows/resources/topics.rb +91 -0
  72. data/lib/notiflows/resources/users/channel_settings.rb +132 -0
  73. data/lib/notiflows/resources/users/deliveries.rb +82 -0
  74. data/lib/notiflows/resources/users/notifications.rb +80 -0
  75. data/lib/notiflows/resources/users/preferences.rb +86 -0
  76. data/lib/notiflows/resources/users/subscriptions.rb +135 -0
  77. data/lib/notiflows/resources/users.rb +167 -0
  78. data/lib/notiflows/version.rb +5 -0
  79. data/lib/notiflows.rb +109 -0
  80. data/manifest.yaml +17 -0
  81. data/rbi/notiflows/client.rbi +82 -0
  82. data/rbi/notiflows/errors.rbi +205 -0
  83. data/rbi/notiflows/file_part.rbi +37 -0
  84. data/rbi/notiflows/internal/cursor_page.rbi +37 -0
  85. data/rbi/notiflows/internal/transport/base_client.rbi +298 -0
  86. data/rbi/notiflows/internal/transport/pooled_net_requester.rbi +83 -0
  87. data/rbi/notiflows/internal/type/array_of.rbi +104 -0
  88. data/rbi/notiflows/internal/type/base_model.rbi +308 -0
  89. data/rbi/notiflows/internal/type/base_page.rbi +42 -0
  90. data/rbi/notiflows/internal/type/boolean.rbi +58 -0
  91. data/rbi/notiflows/internal/type/converter.rbi +216 -0
  92. data/rbi/notiflows/internal/type/enum.rbi +82 -0
  93. data/rbi/notiflows/internal/type/file_input.rbi +59 -0
  94. data/rbi/notiflows/internal/type/hash_of.rbi +104 -0
  95. data/rbi/notiflows/internal/type/request_parameters.rbi +29 -0
  96. data/rbi/notiflows/internal/type/union.rbi +128 -0
  97. data/rbi/notiflows/internal/type/unknown.rbi +58 -0
  98. data/rbi/notiflows/internal/util.rbi +487 -0
  99. data/rbi/notiflows/internal.rbi +18 -0
  100. data/rbi/notiflows/models/delivery.rbi +226 -0
  101. data/rbi/notiflows/models/delivery_list_params.rbi +123 -0
  102. data/rbi/notiflows/models/delivery_retrieve_params.rbi +27 -0
  103. data/rbi/notiflows/models/notification.rbi +190 -0
  104. data/rbi/notiflows/models/notification_list_deliveries_params.rbi +126 -0
  105. data/rbi/notiflows/models/notification_list_params.rbi +112 -0
  106. data/rbi/notiflows/models/notification_retrieve_params.rbi +30 -0
  107. data/rbi/notiflows/models/notiflow_run_params.rbi +320 -0
  108. data/rbi/notiflows/models/notiflow_run_response.rbi +31 -0
  109. data/rbi/notiflows/models/topic.rbi +32 -0
  110. data/rbi/notiflows/models/topic_delete_params.rbi +27 -0
  111. data/rbi/notiflows/models/topic_list_params.rbi +68 -0
  112. data/rbi/notiflows/models/topic_retrieve_params.rbi +27 -0
  113. data/rbi/notiflows/models/topics/bulk_operation_response.rbi +93 -0
  114. data/rbi/notiflows/models/topics/bulk_subscribe_request.rbi +35 -0
  115. data/rbi/notiflows/models/topics/subscription_list_params.rbi +95 -0
  116. data/rbi/notiflows/models/topics/subscription_subscribe_bulk_params.rbi +32 -0
  117. data/rbi/notiflows/models/topics/subscription_unsubscribe_bulk_params.rbi +32 -0
  118. data/rbi/notiflows/models/user.rbi +126 -0
  119. data/rbi/notiflows/models/user_delete_params.rbi +27 -0
  120. data/rbi/notiflows/models/user_list_params.rbi +90 -0
  121. data/rbi/notiflows/models/user_retrieve_params.rbi +27 -0
  122. data/rbi/notiflows/models/user_upsert_params.rbi +203 -0
  123. data/rbi/notiflows/models/users/channel_setting_delete_params.rbi +43 -0
  124. data/rbi/notiflows/models/users/channel_setting_retrieve_params.rbi +43 -0
  125. data/rbi/notiflows/models/users/channel_setting_update_params.rbi +92 -0
  126. data/rbi/notiflows/models/users/channel_settings.rbi +156 -0
  127. data/rbi/notiflows/models/users/delivery_list_params.rbi +128 -0
  128. data/rbi/notiflows/models/users/delivery_retrieve_params.rbi +43 -0
  129. data/rbi/notiflows/models/users/mobile_push_settings.rbi +35 -0
  130. data/rbi/notiflows/models/users/notification_list_params.rbi +117 -0
  131. data/rbi/notiflows/models/users/notification_retrieve_params.rbi +43 -0
  132. data/rbi/notiflows/models/users/preference_retrieve_params.rbi +32 -0
  133. data/rbi/notiflows/models/users/preference_update_params.rbi +34 -0
  134. data/rbi/notiflows/models/users/preferences.rbi +241 -0
  135. data/rbi/notiflows/models/users/slack_settings.rbi +49 -0
  136. data/rbi/notiflows/models/users/subscription.rbi +64 -0
  137. data/rbi/notiflows/models/users/subscription_list_params.rbi +95 -0
  138. data/rbi/notiflows/models/users/subscription_retrieve_params.rbi +43 -0
  139. data/rbi/notiflows/models/users/subscription_subscribe_params.rbi +47 -0
  140. data/rbi/notiflows/models/users/subscription_unsubscribe_params.rbi +43 -0
  141. data/rbi/notiflows/models/users/update_preferences_request.rbi +124 -0
  142. data/rbi/notiflows/models.rbi +42 -0
  143. data/rbi/notiflows/request_options.rbi +59 -0
  144. data/rbi/notiflows/resources/deliveries.rbi +67 -0
  145. data/rbi/notiflows/resources/notifications.rbi +100 -0
  146. data/rbi/notiflows/resources/notiflows.rbi +52 -0
  147. data/rbi/notiflows/resources/topics/subscriptions.rbi +88 -0
  148. data/rbi/notiflows/resources/topics.rbi +69 -0
  149. data/rbi/notiflows/resources/users/channel_settings.rbi +104 -0
  150. data/rbi/notiflows/resources/users/deliveries.rbi +69 -0
  151. data/rbi/notiflows/resources/users/notifications.rbi +66 -0
  152. data/rbi/notiflows/resources/users/preferences.rbi +76 -0
  153. data/rbi/notiflows/resources/users/subscriptions.rbi +102 -0
  154. data/rbi/notiflows/resources/users.rbi +147 -0
  155. data/rbi/notiflows/version.rbi +5 -0
  156. data/sig/notiflows/client.rbs +41 -0
  157. data/sig/notiflows/errors.rbs +117 -0
  158. data/sig/notiflows/file_part.rbs +21 -0
  159. data/sig/notiflows/internal/cursor_page.rbs +22 -0
  160. data/sig/notiflows/internal/transport/base_client.rbs +133 -0
  161. data/sig/notiflows/internal/transport/pooled_net_requester.rbs +48 -0
  162. data/sig/notiflows/internal/type/array_of.rbs +48 -0
  163. data/sig/notiflows/internal/type/base_model.rbs +102 -0
  164. data/sig/notiflows/internal/type/base_page.rbs +24 -0
  165. data/sig/notiflows/internal/type/boolean.rbs +26 -0
  166. data/sig/notiflows/internal/type/converter.rbs +79 -0
  167. data/sig/notiflows/internal/type/enum.rbs +32 -0
  168. data/sig/notiflows/internal/type/file_input.rbs +25 -0
  169. data/sig/notiflows/internal/type/hash_of.rbs +48 -0
  170. data/sig/notiflows/internal/type/request_parameters.rbs +19 -0
  171. data/sig/notiflows/internal/type/union.rbs +52 -0
  172. data/sig/notiflows/internal/type/unknown.rbs +26 -0
  173. data/sig/notiflows/internal/util.rbs +185 -0
  174. data/sig/notiflows/internal.rbs +9 -0
  175. data/sig/notiflows/models/delivery.rbs +130 -0
  176. data/sig/notiflows/models/delivery_list_params.rbs +77 -0
  177. data/sig/notiflows/models/delivery_retrieve_params.rbs +15 -0
  178. data/sig/notiflows/models/notification.rbs +104 -0
  179. data/sig/notiflows/models/notification_list_deliveries_params.rbs +77 -0
  180. data/sig/notiflows/models/notification_list_params.rbs +70 -0
  181. data/sig/notiflows/models/notification_retrieve_params.rbs +15 -0
  182. data/sig/notiflows/models/notiflow_run_params.rbs +199 -0
  183. data/sig/notiflows/models/notiflow_run_response.rbs +13 -0
  184. data/sig/notiflows/models/topic.rbs +15 -0
  185. data/sig/notiflows/models/topic_delete_params.rbs +15 -0
  186. data/sig/notiflows/models/topic_list_params.rbs +38 -0
  187. data/sig/notiflows/models/topic_retrieve_params.rbs +15 -0
  188. data/sig/notiflows/models/topics/bulk_operation_response.rbs +39 -0
  189. data/sig/notiflows/models/topics/bulk_subscribe_request.rbs +15 -0
  190. data/sig/notiflows/models/topics/subscription_list_params.rbs +58 -0
  191. data/sig/notiflows/models/topics/subscription_subscribe_bulk_params.rbs +17 -0
  192. data/sig/notiflows/models/topics/subscription_unsubscribe_bulk_params.rbs +17 -0
  193. data/sig/notiflows/models/user.rbs +75 -0
  194. data/sig/notiflows/models/user_delete_params.rbs +15 -0
  195. data/sig/notiflows/models/user_list_params.rbs +56 -0
  196. data/sig/notiflows/models/user_retrieve_params.rbs +15 -0
  197. data/sig/notiflows/models/user_upsert_params.rbs +112 -0
  198. data/sig/notiflows/models/users/channel_setting_delete_params.rbs +26 -0
  199. data/sig/notiflows/models/users/channel_setting_retrieve_params.rbs +26 -0
  200. data/sig/notiflows/models/users/channel_setting_update_params.rbs +42 -0
  201. data/sig/notiflows/models/users/channel_settings.rbs +68 -0
  202. data/sig/notiflows/models/users/delivery_list_params.rbs +79 -0
  203. data/sig/notiflows/models/users/delivery_retrieve_params.rbs +26 -0
  204. data/sig/notiflows/models/users/mobile_push_settings.rbs +15 -0
  205. data/sig/notiflows/models/users/notification_list_params.rbs +72 -0
  206. data/sig/notiflows/models/users/notification_retrieve_params.rbs +26 -0
  207. data/sig/notiflows/models/users/preference_retrieve_params.rbs +17 -0
  208. data/sig/notiflows/models/users/preference_update_params.rbs +17 -0
  209. data/sig/notiflows/models/users/preferences.rbs +118 -0
  210. data/sig/notiflows/models/users/slack_settings.rbs +24 -0
  211. data/sig/notiflows/models/users/subscription.rbs +32 -0
  212. data/sig/notiflows/models/users/subscription_list_params.rbs +58 -0
  213. data/sig/notiflows/models/users/subscription_retrieve_params.rbs +26 -0
  214. data/sig/notiflows/models/users/subscription_subscribe_params.rbs +25 -0
  215. data/sig/notiflows/models/users/subscription_unsubscribe_params.rbs +26 -0
  216. data/sig/notiflows/models/users/update_preferences_request.rbs +52 -0
  217. data/sig/notiflows/models.rbs +39 -0
  218. data/sig/notiflows/request_options.rbs +34 -0
  219. data/sig/notiflows/resources/deliveries.rbs +24 -0
  220. data/sig/notiflows/resources/notifications.rbs +36 -0
  221. data/sig/notiflows/resources/notiflows.rbs +16 -0
  222. data/sig/notiflows/resources/topics/subscriptions.rbs +31 -0
  223. data/sig/notiflows/resources/topics.rbs +23 -0
  224. data/sig/notiflows/resources/users/channel_settings.rbs +28 -0
  225. data/sig/notiflows/resources/users/deliveries.rbs +28 -0
  226. data/sig/notiflows/resources/users/notifications.rbs +27 -0
  227. data/sig/notiflows/resources/users/preferences.rbs +21 -0
  228. data/sig/notiflows/resources/users/subscriptions.rbs +37 -0
  229. data/sig/notiflows/resources/users.rbs +52 -0
  230. data/sig/notiflows/version.rbs +3 -0
  231. metadata +302 -0
@@ -0,0 +1,135 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notiflows
4
+ module Resources
5
+ class Users
6
+ class Subscriptions
7
+ # Check if a user is subscribed to a specific topic.
8
+ #
9
+ # @overload retrieve(topic_name, user_external_id:, request_options: {})
10
+ #
11
+ # @param topic_name [String] Topic name
12
+ #
13
+ # @param user_external_id [String] User external ID
14
+ #
15
+ # @param request_options [Notiflows::RequestOptions, Hash{Symbol=>Object}, nil]
16
+ #
17
+ # @return [Notiflows::Models::Users::Subscription]
18
+ #
19
+ # @see Notiflows::Models::Users::SubscriptionRetrieveParams
20
+ def retrieve(topic_name, params)
21
+ parsed, options = ::Notiflows::Users::SubscriptionRetrieveParams.dump_request(params)
22
+ user_external_id =
23
+ parsed.delete(:user_external_id) do
24
+ raise ArgumentError.new("missing required path argument #{_1}")
25
+ end
26
+ @client.request(
27
+ method: :get,
28
+ path: ["users/%1$s/subscriptions/%2$s", user_external_id, topic_name],
29
+ model: ::Notiflows::Users::Subscription,
30
+ options: options
31
+ )
32
+ end
33
+
34
+ # Retrieve all topic subscriptions for a user.
35
+ #
36
+ # @overload list(user_external_id, after: nil, before: nil, created_after: nil, created_before: nil, limit: nil, request_options: {})
37
+ #
38
+ # @param user_external_id [String] User external ID
39
+ #
40
+ # @param after [String] Cursor for fetching the next page
41
+ #
42
+ # @param before [String] Cursor for fetching the previous page
43
+ #
44
+ # @param created_after [String] Filter by created after (ISO 8601 datetime)
45
+ #
46
+ # @param created_before [String] Filter by created before (ISO 8601 datetime)
47
+ #
48
+ # @param limit [Integer] Number of items per page (default: 25, max: 1000)
49
+ #
50
+ # @param request_options [Notiflows::RequestOptions, Hash{Symbol=>Object}, nil]
51
+ #
52
+ # @return [Notiflows::Internal::CursorPage<Notiflows::Models::Users::Subscription>]
53
+ #
54
+ # @see Notiflows::Models::Users::SubscriptionListParams
55
+ def list(user_external_id, params = {})
56
+ parsed, options = ::Notiflows::Users::SubscriptionListParams.dump_request(params)
57
+ @client.request(
58
+ method: :get,
59
+ path: ["users/%1$s/subscriptions", user_external_id],
60
+ query: parsed,
61
+ page: ::Notiflows::Internal::CursorPage,
62
+ model: ::Notiflows::Users::Subscription,
63
+ options: options
64
+ )
65
+ end
66
+
67
+ # Some parameter documentations has been truncated, see
68
+ # {Notiflows::Models::Users::SubscriptionSubscribeParams} for more details.
69
+ #
70
+ # Subscribe a user to a topic. Topics are created automatically if they don't
71
+ # exist.
72
+ #
73
+ # **Idempotent:** If the user is already subscribed, returns the existing
74
+ # subscription with `200 OK`.
75
+ #
76
+ # @overload subscribe(user_external_id, topic_name:, request_options: {})
77
+ #
78
+ # @param user_external_id [String] User external ID
79
+ #
80
+ # @param topic_name [String] Name of the topic to subscribe to. Topics are created automatically if they don'
81
+ #
82
+ # @param request_options [Notiflows::RequestOptions, Hash{Symbol=>Object}, nil]
83
+ #
84
+ # @return [Notiflows::Models::Users::Subscription]
85
+ #
86
+ # @see Notiflows::Models::Users::SubscriptionSubscribeParams
87
+ def subscribe(user_external_id, params)
88
+ parsed, options = ::Notiflows::Users::SubscriptionSubscribeParams.dump_request(params)
89
+ @client.request(
90
+ method: :post,
91
+ path: ["users/%1$s/subscriptions", user_external_id],
92
+ body: parsed,
93
+ model: ::Notiflows::Users::Subscription,
94
+ options: options
95
+ )
96
+ end
97
+
98
+ # Remove a user's subscription from a topic. The user will no longer receive
99
+ # notifications triggered for this topic.
100
+ #
101
+ # @overload unsubscribe(topic_name, user_external_id:, request_options: {})
102
+ #
103
+ # @param topic_name [String] Topic name
104
+ #
105
+ # @param user_external_id [String] User external ID
106
+ #
107
+ # @param request_options [Notiflows::RequestOptions, Hash{Symbol=>Object}, nil]
108
+ #
109
+ # @return [nil]
110
+ #
111
+ # @see Notiflows::Models::Users::SubscriptionUnsubscribeParams
112
+ def unsubscribe(topic_name, params)
113
+ parsed, options = ::Notiflows::Users::SubscriptionUnsubscribeParams.dump_request(params)
114
+ user_external_id =
115
+ parsed.delete(:user_external_id) do
116
+ raise ArgumentError.new("missing required path argument #{_1}")
117
+ end
118
+ @client.request(
119
+ method: :delete,
120
+ path: ["users/%1$s/subscriptions/%2$s", user_external_id, topic_name],
121
+ model: NilClass,
122
+ options: options
123
+ )
124
+ end
125
+
126
+ # @api private
127
+ #
128
+ # @param client [Notiflows::Client]
129
+ def initialize(client:)
130
+ @client = client
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,167 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notiflows
4
+ module Resources
5
+ class Users
6
+ # @return [Notiflows::Resources::Users::ChannelSettings]
7
+ attr_reader :channel_settings
8
+
9
+ # @return [Notiflows::Resources::Users::Deliveries]
10
+ attr_reader :deliveries
11
+
12
+ # @return [Notiflows::Resources::Users::Notifications]
13
+ attr_reader :notifications
14
+
15
+ # @return [Notiflows::Resources::Users::Preferences]
16
+ attr_reader :preferences
17
+
18
+ # @return [Notiflows::Resources::Users::Subscriptions]
19
+ attr_reader :subscriptions
20
+
21
+ # Retrieve a single user by their external ID. The external ID is the identifier
22
+ # you assigned when creating the user.
23
+ #
24
+ # @overload retrieve(user_external_id, request_options: {})
25
+ #
26
+ # @param user_external_id [String] User external ID (your system's user identifier)
27
+ #
28
+ # @param request_options [Notiflows::RequestOptions, Hash{Symbol=>Object}, nil]
29
+ #
30
+ # @return [Notiflows::Models::User]
31
+ #
32
+ # @see Notiflows::Models::UserRetrieveParams
33
+ def retrieve(user_external_id, params = {})
34
+ @client.request(
35
+ method: :get,
36
+ path: ["users/%1$s", user_external_id],
37
+ model: ::Notiflows::User,
38
+ options: params[:request_options]
39
+ )
40
+ end
41
+
42
+ # Retrieve a paginated list of users in your project. Users are sorted by creation
43
+ # date (newest first).
44
+ #
45
+ # @overload list(after: nil, before: nil, created_after: nil, created_before: nil, limit: nil, request_options: {})
46
+ #
47
+ # @param after [String] Cursor for fetching the next page
48
+ #
49
+ # @param before [String] Cursor for fetching the previous page
50
+ #
51
+ # @param created_after [String] Filter users created after this datetime (ISO 8601)
52
+ #
53
+ # @param created_before [String] Filter users created before this datetime (ISO 8601)
54
+ #
55
+ # @param limit [Integer] Number of items per page (default: 25, max: 1000)
56
+ #
57
+ # @param request_options [Notiflows::RequestOptions, Hash{Symbol=>Object}, nil]
58
+ #
59
+ # @return [Notiflows::Internal::CursorPage<Notiflows::Models::User>]
60
+ #
61
+ # @see Notiflows::Models::UserListParams
62
+ def list(params = {})
63
+ parsed, options = ::Notiflows::UserListParams.dump_request(params)
64
+ @client.request(
65
+ method: :get,
66
+ path: "users",
67
+ query: parsed,
68
+ page: ::Notiflows::Internal::CursorPage,
69
+ model: ::Notiflows::User,
70
+ options: options
71
+ )
72
+ end
73
+
74
+ # Permanently delete a user and all their associated data including:
75
+ #
76
+ # - Subscriptions
77
+ # - Preferences
78
+ # - Channel settings
79
+ # - Notifications and deliveries
80
+ #
81
+ # **This action cannot be undone.**
82
+ #
83
+ # @overload delete(user_external_id, request_options: {})
84
+ #
85
+ # @param user_external_id [String] User external ID
86
+ #
87
+ # @param request_options [Notiflows::RequestOptions, Hash{Symbol=>Object}, nil]
88
+ #
89
+ # @return [nil]
90
+ #
91
+ # @see Notiflows::Models::UserDeleteParams
92
+ def delete(user_external_id, params = {})
93
+ @client.request(
94
+ method: :delete,
95
+ path: ["users/%1$s", user_external_id],
96
+ model: NilClass,
97
+ options: params[:request_options]
98
+ )
99
+ end
100
+
101
+ # Create a new user or update an existing user by external ID (upsert operation).
102
+ #
103
+ # - If the user doesn't exist, they will be created with the provided attributes.
104
+ # - If the user exists, their attributes will be updated (merge behavior).
105
+ # - `custom_fields` are deep-merged with existing values.
106
+ #
107
+ # **Returns:**
108
+ #
109
+ # - `201 Created` when a new user is created
110
+ # - `200 OK` when an existing user is updated
111
+ #
112
+ # @overload upsert(user_external_id, external_id:, avatar: nil, channel_settings: nil, custom_fields: nil, email: nil, first_name: nil, last_name: nil, locale: nil, phone: nil, preferences: nil, timezone: nil, request_options: {})
113
+ #
114
+ # @param user_external_id [String] User external ID
115
+ #
116
+ # @param external_id [String] Your system's unique identifier for this user. Required for creating new users.
117
+ #
118
+ # @param avatar [String] URL to user's avatar image (must start with http:// or https://)
119
+ #
120
+ # @param channel_settings [Array<Notiflows::Models::UserUpsertParams::ChannelSetting>] Initial channel settings (e.g., device tokens for push)
121
+ #
122
+ # @param custom_fields [Object] Custom attributes. Deep-merged with existing values on update.
123
+ #
124
+ # @param email [String] User's email address
125
+ #
126
+ # @param first_name [String] User's first name
127
+ #
128
+ # @param last_name [String] User's last name
129
+ #
130
+ # @param locale [String] BCP 47 locale code (e.g., en-US, es-ES, fr-FR)
131
+ #
132
+ # @param phone [String] User's phone number in E.164 format
133
+ #
134
+ # @param preferences [::Notiflows::Models::Users::UpdatePreferencesRequest] Request body for updating user preferences. Only provided fields are updated.
135
+ #
136
+ # @param timezone [String] IANA timezone (e.g., America/New_York, Europe/London)
137
+ #
138
+ # @param request_options [Notiflows::RequestOptions, Hash{Symbol=>Object}, nil]
139
+ #
140
+ # @return [Notiflows::Models::User]
141
+ #
142
+ # @see Notiflows::Models::UserUpsertParams
143
+ def upsert(user_external_id, params)
144
+ parsed, options = ::Notiflows::UserUpsertParams.dump_request(params)
145
+ @client.request(
146
+ method: :put,
147
+ path: ["users/%1$s", user_external_id],
148
+ body: parsed,
149
+ model: ::Notiflows::User,
150
+ options: options
151
+ )
152
+ end
153
+
154
+ # @api private
155
+ #
156
+ # @param client [Notiflows::Client]
157
+ def initialize(client:)
158
+ @client = client
159
+ @channel_settings = ChannelSettings.new(client: client)
160
+ @deliveries = Deliveries.new(client: client)
161
+ @notifications = Notifications.new(client: client)
162
+ @preferences = Preferences.new(client: client)
163
+ @subscriptions = Subscriptions.new(client: client)
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notiflows
4
+ VERSION = "0.0.1"
5
+ end
data/lib/notiflows.rb ADDED
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Standard libraries.
4
+ # rubocop:disable Lint/RedundantRequireStatement
5
+ require "English"
6
+ require "base64"
7
+ require "cgi"
8
+ require "date"
9
+ require "erb"
10
+ require "etc"
11
+ require "json"
12
+ require "net/http"
13
+ require "openssl"
14
+ require "pathname"
15
+ require "rbconfig"
16
+ require "securerandom"
17
+ require "set"
18
+ require "stringio"
19
+ require "time"
20
+ require "uri"
21
+ # rubocop:enable Lint/RedundantRequireStatement
22
+
23
+ # We already ship the preferred sorbet manifests in the package itself.
24
+ # `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
25
+ if Object.const_defined?(:Tapioca) &&
26
+ caller.chain([$PROGRAM_NAME]).chain(ARGV).any?(/tapioca/) &&
27
+ ARGV.none?(/dsl/)
28
+ return
29
+ end
30
+
31
+ # Gems.
32
+ require "connection_pool"
33
+
34
+ # Package files.
35
+ require_relative "notiflows/version"
36
+ require_relative "notiflows/internal/util"
37
+ require_relative "notiflows/internal/type/converter"
38
+ require_relative "notiflows/internal/type/unknown"
39
+ require_relative "notiflows/internal/type/boolean"
40
+ require_relative "notiflows/internal/type/file_input"
41
+ require_relative "notiflows/internal/type/enum"
42
+ require_relative "notiflows/internal/type/union"
43
+ require_relative "notiflows/internal/type/array_of"
44
+ require_relative "notiflows/internal/type/hash_of"
45
+ require_relative "notiflows/internal/type/base_model"
46
+ require_relative "notiflows/internal/type/base_page"
47
+ require_relative "notiflows/internal/type/request_parameters"
48
+ require_relative "notiflows/internal"
49
+ require_relative "notiflows/request_options"
50
+ require_relative "notiflows/file_part"
51
+ require_relative "notiflows/errors"
52
+ require_relative "notiflows/internal/transport/base_client"
53
+ require_relative "notiflows/internal/transport/pooled_net_requester"
54
+ require_relative "notiflows/client"
55
+ require_relative "notiflows/internal/cursor_page"
56
+ require_relative "notiflows/models/topics/bulk_subscribe_request"
57
+ require_relative "notiflows/models/users/update_preferences_request"
58
+ require_relative "notiflows/models/delivery"
59
+ require_relative "notiflows/models/delivery_list_params"
60
+ require_relative "notiflows/models/delivery_retrieve_params"
61
+ require_relative "notiflows/models/notification"
62
+ require_relative "notiflows/models/notification_list_deliveries_params"
63
+ require_relative "notiflows/models/notification_list_params"
64
+ require_relative "notiflows/models/notification_retrieve_params"
65
+ require_relative "notiflows/models/notiflow_run_params"
66
+ require_relative "notiflows/models/notiflow_run_response"
67
+ require_relative "notiflows/models/topic"
68
+ require_relative "notiflows/models/topic_delete_params"
69
+ require_relative "notiflows/models/topic_list_params"
70
+ require_relative "notiflows/models/topic_retrieve_params"
71
+ require_relative "notiflows/models/topics/bulk_operation_response"
72
+ require_relative "notiflows/models/topics/subscription_list_params"
73
+ require_relative "notiflows/models/topics/subscription_subscribe_bulk_params"
74
+ require_relative "notiflows/models/topics/subscription_unsubscribe_bulk_params"
75
+ require_relative "notiflows/models/user"
76
+ require_relative "notiflows/models/user_delete_params"
77
+ require_relative "notiflows/models/user_list_params"
78
+ require_relative "notiflows/models/user_retrieve_params"
79
+ require_relative "notiflows/models/users/channel_setting_delete_params"
80
+ require_relative "notiflows/models/users/channel_setting_retrieve_params"
81
+ require_relative "notiflows/models/users/channel_setting_update_params"
82
+ require_relative "notiflows/models/users/delivery_list_params"
83
+ require_relative "notiflows/models/users/delivery_retrieve_params"
84
+ require_relative "notiflows/models/users/mobile_push_settings"
85
+ require_relative "notiflows/models/users/notification_list_params"
86
+ require_relative "notiflows/models/users/notification_retrieve_params"
87
+ require_relative "notiflows/models/users/preference_retrieve_params"
88
+ require_relative "notiflows/models/users/preference_update_params"
89
+ require_relative "notiflows/models/users/slack_settings"
90
+ require_relative "notiflows/models/users/subscription"
91
+ require_relative "notiflows/models/users/subscription_list_params"
92
+ require_relative "notiflows/models/users/subscription_retrieve_params"
93
+ require_relative "notiflows/models/users/subscription_subscribe_params"
94
+ require_relative "notiflows/models/users/subscription_unsubscribe_params"
95
+ require_relative "notiflows/models/users/channel_settings"
96
+ require_relative "notiflows/models/users/preferences"
97
+ require_relative "notiflows/models/user_upsert_params"
98
+ require_relative "notiflows/models"
99
+ require_relative "notiflows/resources/deliveries"
100
+ require_relative "notiflows/resources/notifications"
101
+ require_relative "notiflows/resources/notiflows"
102
+ require_relative "notiflows/resources/topics/subscriptions"
103
+ require_relative "notiflows/resources/topics"
104
+ require_relative "notiflows/resources/users/channel_settings"
105
+ require_relative "notiflows/resources/users/deliveries"
106
+ require_relative "notiflows/resources/users/notifications"
107
+ require_relative "notiflows/resources/users/preferences"
108
+ require_relative "notiflows/resources/users/subscriptions"
109
+ require_relative "notiflows/resources/users"
data/manifest.yaml ADDED
@@ -0,0 +1,17 @@
1
+ dependencies:
2
+ - English
3
+ - base64
4
+ - cgi
5
+ - date
6
+ - erb
7
+ - etc
8
+ - json
9
+ - net/http
10
+ - openssl
11
+ - pathname
12
+ - rbconfig
13
+ - securerandom
14
+ - set
15
+ - stringio
16
+ - time
17
+ - uri
@@ -0,0 +1,82 @@
1
+ # typed: strong
2
+
3
+ module Notiflows
4
+ class Client < Notiflows::Internal::Transport::BaseClient
5
+ DEFAULT_MAX_RETRIES = 2
6
+
7
+ DEFAULT_TIMEOUT_IN_SECONDS = T.let(60.0, Float)
8
+
9
+ DEFAULT_INITIAL_RETRY_DELAY = T.let(0.5, Float)
10
+
11
+ DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float)
12
+
13
+ # Your project's public API key. Found in Project Settings. Starts with `pk_`.
14
+ sig { returns(String) }
15
+ attr_reader :api_key
16
+
17
+ # Your project's secret key. Found in Project Settings. Starts with `sk_`. **Keep
18
+ # this secret!**
19
+ sig { returns(String) }
20
+ attr_reader :secret
21
+
22
+ sig { returns(Notiflows::Resources::Deliveries) }
23
+ attr_reader :deliveries
24
+
25
+ sig { returns(Notiflows::Resources::Notifications) }
26
+ attr_reader :notifications
27
+
28
+ sig { returns(Notiflows::Resources::Notiflows) }
29
+ attr_reader :notiflows
30
+
31
+ sig { returns(Notiflows::Resources::Topics) }
32
+ attr_reader :topics
33
+
34
+ sig { returns(Notiflows::Resources::Users) }
35
+ attr_reader :users
36
+
37
+ # @api private
38
+ sig { override.returns(T::Hash[String, String]) }
39
+ private def auth_headers
40
+ end
41
+
42
+ # @api private
43
+ sig { returns(T::Hash[String, String]) }
44
+ private def api_key_auth
45
+ end
46
+
47
+ # @api private
48
+ sig { returns(T::Hash[String, String]) }
49
+ private def secret_key_auth
50
+ end
51
+
52
+ # Creates and returns a new client for interacting with the API.
53
+ sig do
54
+ params(
55
+ api_key: T.nilable(String),
56
+ secret: T.nilable(String),
57
+ base_url: T.nilable(String),
58
+ max_retries: Integer,
59
+ timeout: Float,
60
+ initial_retry_delay: Float,
61
+ max_retry_delay: Float
62
+ ).returns(T.attached_class)
63
+ end
64
+ def self.new(
65
+ # Your project's public API key. Found in Project Settings. Starts with `pk_`.
66
+ # Defaults to `ENV["NOTIFLOWS_SDK_API_KEY"]`
67
+ api_key: ENV["NOTIFLOWS_SDK_API_KEY"],
68
+ # Your project's secret key. Found in Project Settings. Starts with `sk_`. **Keep
69
+ # this secret!** Defaults to `ENV["NOTIFLOWS_SDK_SECRET"]`
70
+ secret: ENV["NOTIFLOWS_SDK_SECRET"],
71
+ # Override the default base URL for the API, e.g.,
72
+ # `"https://api.example.com/v2/"`. Defaults to `ENV["NOTIFLOWS_BASE_URL"]`
73
+ base_url: ENV["NOTIFLOWS_BASE_URL"],
74
+ # Max number of retries to attempt after a failed retryable request.
75
+ max_retries: Notiflows::Client::DEFAULT_MAX_RETRIES,
76
+ timeout: Notiflows::Client::DEFAULT_TIMEOUT_IN_SECONDS,
77
+ initial_retry_delay: Notiflows::Client::DEFAULT_INITIAL_RETRY_DELAY,
78
+ max_retry_delay: Notiflows::Client::DEFAULT_MAX_RETRY_DELAY
79
+ )
80
+ end
81
+ end
82
+ end