surge_api 0.17.0 → 0.18.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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +51 -16
  4. data/lib/surge_api/client.rb +22 -1
  5. data/lib/surge_api/internal/transport/base_client.rb +5 -0
  6. data/lib/surge_api/internal/util.rb +22 -7
  7. data/lib/surge_api/models/account_archive_params.rb +9 -1
  8. data/lib/surge_api/models/account_retrieve_status_params.rb +9 -1
  9. data/lib/surge_api/models/account_update_params.rb +9 -1
  10. data/lib/surge_api/models/attachment_get_file_params.rb +9 -1
  11. data/lib/surge_api/models/audience_add_contact_params.rb +9 -1
  12. data/lib/surge_api/models/audience_create_params.rb +9 -1
  13. data/lib/surge_api/models/audience_list_contacts_params.rb +9 -1
  14. data/lib/surge_api/models/blast_create_params.rb +9 -1
  15. data/lib/surge_api/models/campaign_create_params.rb +6 -10
  16. data/lib/surge_api/models/campaign_list_params.rb +9 -1
  17. data/lib/surge_api/models/campaign_retrieve_params.rb +9 -1
  18. data/lib/surge_api/models/campaign_update_params.rb +6 -10
  19. data/lib/surge_api/models/contact_create_params.rb +9 -1
  20. data/lib/surge_api/models/contact_list_params.rb +9 -1
  21. data/lib/surge_api/models/contact_retrieve_params.rb +9 -1
  22. data/lib/surge_api/models/contact_update_params.rb +9 -1
  23. data/lib/surge_api/models/message.rb +1 -0
  24. data/lib/surge_api/models/message_create_params.rb +6 -11
  25. data/lib/surge_api/models/message_delivered_webhook_event.rb +1 -0
  26. data/lib/surge_api/models/message_failed_webhook_event.rb +1 -0
  27. data/lib/surge_api/models/message_list_params.rb +9 -1
  28. data/lib/surge_api/models/message_params.rb +74 -2
  29. data/lib/surge_api/models/message_received_webhook_event.rb +1 -0
  30. data/lib/surge_api/models/message_retrieve_params.rb +9 -1
  31. data/lib/surge_api/models/message_sent_webhook_event.rb +1 -0
  32. data/lib/surge_api/models/phone_number.rb +1 -1
  33. data/lib/surge_api/models/phone_number_list_params.rb +9 -1
  34. data/lib/surge_api/models/phone_number_purchase_params.rb +9 -1
  35. data/lib/surge_api/models/phone_number_release_params.rb +22 -0
  36. data/lib/surge_api/models/phone_number_update_params.rb +38 -0
  37. data/lib/surge_api/models/recording_delete_params.rb +9 -1
  38. data/lib/surge_api/models/recording_get_file_params.rb +9 -1
  39. data/lib/surge_api/models/recording_list_params.rb +9 -1
  40. data/lib/surge_api/models/recording_retrieve_params.rb +9 -1
  41. data/lib/surge_api/models/user_create_params.rb +9 -1
  42. data/lib/surge_api/models/user_create_token_params.rb +9 -1
  43. data/lib/surge_api/models/user_delete_params.rb +9 -1
  44. data/lib/surge_api/models/user_list_params.rb +9 -1
  45. data/lib/surge_api/models/user_retrieve_params.rb +9 -1
  46. data/lib/surge_api/models/user_update_params.rb +9 -1
  47. data/lib/surge_api/models/verification_check_params.rb +9 -1
  48. data/lib/surge_api/models/verification_create_params.rb +9 -1
  49. data/lib/surge_api/models.rb +4 -0
  50. data/lib/surge_api/resources/campaigns.rb +4 -14
  51. data/lib/surge_api/resources/messages.rb +6 -7
  52. data/lib/surge_api/resources/phone_numbers.rb +46 -0
  53. data/lib/surge_api/resources/verifications.rb +7 -4
  54. data/lib/surge_api/resources/webhooks.rb +11 -1
  55. data/lib/surge_api/version.rb +1 -1
  56. data/lib/surge_api.rb +3 -0
  57. data/rbi/surge_api/client.rbi +6 -0
  58. data/rbi/surge_api/internal/util.rbi +8 -0
  59. data/rbi/surge_api/models/account_archive_params.rbi +18 -5
  60. data/rbi/surge_api/models/account_retrieve_status_params.rbi +8 -0
  61. data/rbi/surge_api/models/account_update_params.rbi +8 -0
  62. data/rbi/surge_api/models/attachment_get_file_params.rbi +18 -5
  63. data/rbi/surge_api/models/audience_add_contact_params.rbi +12 -1
  64. data/rbi/surge_api/models/audience_create_params.rbi +12 -1
  65. data/rbi/surge_api/models/audience_list_contacts_params.rbi +8 -0
  66. data/rbi/surge_api/models/blast_create_params.rbi +8 -0
  67. data/rbi/surge_api/models/campaign_create_params.rbi +7 -27
  68. data/rbi/surge_api/models/campaign_list_params.rbi +8 -0
  69. data/rbi/surge_api/models/campaign_retrieve_params.rbi +18 -5
  70. data/rbi/surge_api/models/campaign_update_params.rbi +7 -27
  71. data/rbi/surge_api/models/contact_create_params.rbi +8 -0
  72. data/rbi/surge_api/models/contact_list_params.rbi +8 -0
  73. data/rbi/surge_api/models/contact_retrieve_params.rbi +18 -5
  74. data/rbi/surge_api/models/contact_update_params.rbi +8 -0
  75. data/rbi/surge_api/models/message.rbi +2 -0
  76. data/rbi/surge_api/models/message_create_params.rbi +7 -29
  77. data/rbi/surge_api/models/message_delivered_webhook_event.rbi +5 -0
  78. data/rbi/surge_api/models/message_failed_webhook_event.rbi +5 -0
  79. data/rbi/surge_api/models/message_list_params.rbi +8 -0
  80. data/rbi/surge_api/models/message_params.rbi +225 -6
  81. data/rbi/surge_api/models/message_received_webhook_event.rbi +5 -0
  82. data/rbi/surge_api/models/message_retrieve_params.rbi +18 -5
  83. data/rbi/surge_api/models/message_sent_webhook_event.rbi +5 -0
  84. data/rbi/surge_api/models/phone_number_list_params.rbi +8 -0
  85. data/rbi/surge_api/models/phone_number_purchase_params.rbi +8 -0
  86. data/rbi/surge_api/models/phone_number_release_params.rbi +40 -0
  87. data/rbi/surge_api/models/phone_number_update_params.rbi +65 -0
  88. data/rbi/surge_api/models/recording_delete_params.rbi +18 -5
  89. data/rbi/surge_api/models/recording_get_file_params.rbi +18 -5
  90. data/rbi/surge_api/models/recording_list_params.rbi +8 -0
  91. data/rbi/surge_api/models/recording_retrieve_params.rbi +18 -5
  92. data/rbi/surge_api/models/user_create_params.rbi +8 -0
  93. data/rbi/surge_api/models/user_create_token_params.rbi +8 -0
  94. data/rbi/surge_api/models/user_delete_params.rbi +18 -5
  95. data/rbi/surge_api/models/user_list_params.rbi +8 -0
  96. data/rbi/surge_api/models/user_retrieve_params.rbi +18 -5
  97. data/rbi/surge_api/models/user_update_params.rbi +8 -0
  98. data/rbi/surge_api/models/verification_check_params.rbi +12 -1
  99. data/rbi/surge_api/models/verification_create_params.rbi +12 -1
  100. data/rbi/surge_api/models.rbi +4 -0
  101. data/rbi/surge_api/resources/campaigns.rbi +10 -2
  102. data/rbi/surge_api/resources/messages.rbi +9 -1
  103. data/rbi/surge_api/resources/phone_numbers.rbi +34 -0
  104. data/rbi/surge_api/resources/verifications.rbi +5 -1
  105. data/rbi/surge_api/resources/webhooks.rbi +10 -2
  106. data/sig/surge_api/client.rbs +3 -0
  107. data/sig/surge_api/internal/util.rbs +4 -0
  108. data/sig/surge_api/models/account_archive_params.rbs +8 -3
  109. data/sig/surge_api/models/account_retrieve_status_params.rbs +5 -0
  110. data/sig/surge_api/models/account_update_params.rbs +5 -0
  111. data/sig/surge_api/models/attachment_get_file_params.rbs +11 -3
  112. data/sig/surge_api/models/audience_add_contact_params.rbs +10 -2
  113. data/sig/surge_api/models/audience_create_params.rbs +6 -1
  114. data/sig/surge_api/models/audience_list_contacts_params.rbs +5 -1
  115. data/sig/surge_api/models/blast_create_params.rbs +5 -0
  116. data/sig/surge_api/models/campaign_create_params.rbs +4 -9
  117. data/sig/surge_api/models/campaign_list_params.rbs +5 -1
  118. data/sig/surge_api/models/campaign_retrieve_params.rbs +8 -3
  119. data/sig/surge_api/models/campaign_update_params.rbs +4 -12
  120. data/sig/surge_api/models/contact_create_params.rbs +5 -0
  121. data/sig/surge_api/models/contact_list_params.rbs +5 -1
  122. data/sig/surge_api/models/contact_retrieve_params.rbs +8 -3
  123. data/sig/surge_api/models/contact_update_params.rbs +5 -0
  124. data/sig/surge_api/models/message.rbs +2 -1
  125. data/sig/surge_api/models/message_create_params.rbs +4 -9
  126. data/sig/surge_api/models/message_delivered_webhook_event.rbs +2 -1
  127. data/sig/surge_api/models/message_failed_webhook_event.rbs +2 -1
  128. data/sig/surge_api/models/message_list_params.rbs +5 -1
  129. data/sig/surge_api/models/message_params.rbs +88 -6
  130. data/sig/surge_api/models/message_received_webhook_event.rbs +2 -1
  131. data/sig/surge_api/models/message_retrieve_params.rbs +8 -3
  132. data/sig/surge_api/models/message_sent_webhook_event.rbs +2 -1
  133. data/sig/surge_api/models/phone_number_list_params.rbs +5 -1
  134. data/sig/surge_api/models/phone_number_purchase_params.rbs +5 -0
  135. data/sig/surge_api/models/phone_number_release_params.rbs +20 -0
  136. data/sig/surge_api/models/phone_number_update_params.rbs +36 -0
  137. data/sig/surge_api/models/recording_delete_params.rbs +8 -3
  138. data/sig/surge_api/models/recording_get_file_params.rbs +11 -3
  139. data/sig/surge_api/models/recording_list_params.rbs +5 -1
  140. data/sig/surge_api/models/recording_retrieve_params.rbs +8 -3
  141. data/sig/surge_api/models/user_create_params.rbs +5 -0
  142. data/sig/surge_api/models/user_create_token_params.rbs +5 -1
  143. data/sig/surge_api/models/user_delete_params.rbs +8 -3
  144. data/sig/surge_api/models/user_list_params.rbs +5 -1
  145. data/sig/surge_api/models/user_retrieve_params.rbs +8 -3
  146. data/sig/surge_api/models/user_update_params.rbs +5 -0
  147. data/sig/surge_api/models/verification_check_params.rbs +6 -1
  148. data/sig/surge_api/models/verification_create_params.rbs +6 -1
  149. data/sig/surge_api/models.rbs +4 -0
  150. data/sig/surge_api/resources/campaigns.rbs +2 -2
  151. data/sig/surge_api/resources/messages.rbs +1 -1
  152. data/sig/surge_api/resources/phone_numbers.rbs +12 -0
  153. data/sig/surge_api/resources/verifications.rbs +1 -0
  154. data/sig/surge_api/resources/webhooks.rbs +3 -1
  155. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcd65a3f11b5c187dcefe5f82f90dfef4bb4421e06115246ccda187f459e9202
4
- data.tar.gz: c8bac9291bc751a4ddfdb952f70eb32fcb696ef886a5c3521f149e7235f18733
3
+ metadata.gz: d65004cf163c9724f560bd9541e0f55ceabd3d516e6938d318f7ab17302d0880
4
+ data.tar.gz: d80c1e25b422f575977b4f8a073640aae972e50492e7b1430b3c7835193c22a6
5
5
  SHA512:
6
- metadata.gz: '0032493ed7b14b18fc06f216c37ed91814fbd61874e777604013cde0c694859767b177820dc298559024a9a2c7f39d878157e7e6b24035fce20ad07fa1b984e0'
7
- data.tar.gz: abe1e0ff490003f4f4376847989c4b0f982abb34ac3eae1bc308b81abf22a03e4078dd08d49c23db58a91e271831d450fe2087938286455fcc381d126602a14c
6
+ metadata.gz: be50b1c68afb192da466f0bc4bc3d17f2c413ecdcbee12aab3fa7ea5f60b0346098dea593c83bee5802ac7806db14c7f3e0d726237414445c3bcb1989cc89930
7
+ data.tar.gz: 0c9ff556f313c28bff2152bf9670846441f797cfd81476bde254983534e4bead99b06eec575455ea89e2daf32903d39bdeee679eed0c142051d6877719fd2053
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.18.0 (2026-06-30)
4
+
5
+ Full Changelog: [v0.17.0...v0.18.0](https://github.com/surgeapi/ruby-sdk/compare/v0.17.0...v0.18.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** add contact to attachment types ([2deb16b](https://github.com/surgeapi/ruby-sdk/commit/2deb16b7a54e656be02438844c68de41dcdc0aff))
10
+ * **api:** add message settings ([a0b6be6](https://github.com/surgeapi/ruby-sdk/commit/a0b6be6586d6392a9a01143c3e838618246e0183))
11
+ * **api:** add update phone number endpoint ([1953448](https://github.com/surgeapi/ruby-sdk/commit/1953448bc582187a06e9a474fd7587510868d389))
12
+ * **api:** remove extraneous empty properties ([230dd27](https://github.com/surgeapi/ruby-sdk/commit/230dd27965e2d6ac14920a584baefe9067a702c1))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **client:** send content-type header for requests with an omitted optional body ([b482a41](https://github.com/surgeapi/ruby-sdk/commit/b482a41647474442749c52b692083119985c5d39))
18
+
19
+
20
+ ### Chores
21
+
22
+ * **internal:** bound formatter parallelism to CPU count ([85fcacc](https://github.com/surgeapi/ruby-sdk/commit/85fcaccabe7f4f1321306a5edd86a63eb2c50322))
23
+ * **spec:** remove extraneous empty properties ([e985a21](https://github.com/surgeapi/ruby-sdk/commit/e985a21b5b45e835fe2a623c3cc38030fee2455d))
24
+
3
25
  ## 0.17.0 (2026-05-04)
4
26
 
5
27
  Full Changelog: [v0.16.0...v0.17.0](https://github.com/surgeapi/ruby-sdk/compare/v0.16.0...v0.17.0)
data/README.md CHANGED
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
17
17
  <!-- x-release-please-start-version -->
18
18
 
19
19
  ```ruby
20
- gem "surge_api", "~> 0.17.0"
20
+ gem "surge_api", "~> 0.18.0"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
@@ -32,7 +32,10 @@ surge = SurgeAPI::Client.new(
32
32
  api_key: ENV["SURGE_API_KEY"] # This is the default and can be omitted
33
33
  )
34
34
 
35
- message = surge.messages.create("acct_01j9a43avnfqzbjfch6pygv1td")
35
+ message = surge.messages.create(
36
+ "acct_01j9a43avnfqzbjfch6pygv1td",
37
+ message_params: {conversation: {contact: {phone_number: "+18015551234"}}}
38
+ )
36
39
 
37
40
  puts(message.id)
38
41
  ```
@@ -71,7 +74,10 @@ When the library is unable to connect to the API, or if the API returns a non-su
71
74
 
72
75
  ```ruby
73
76
  begin
74
- message = surge.messages.create("acct_01j9a43avnfqzbjfch6pygv1td")
77
+ message = surge.messages.create(
78
+ "acct_01j9a43avnfqzbjfch6pygv1td",
79
+ message_params: {conversation: {contact: {phone_number: "+18015551234"}}}
80
+ )
75
81
  rescue SurgeAPI::Errors::APIConnectionError => e
76
82
  puts("The server could not be reached")
77
83
  puts(e.cause) # an underlying Exception, likely raised within `net/http`
@@ -114,7 +120,11 @@ surge = SurgeAPI::Client.new(
114
120
  )
115
121
 
116
122
  # Or, configure per-request:
117
- surge.messages.create("acct_01j9a43avnfqzbjfch6pygv1td", request_options: {max_retries: 5})
123
+ surge.messages.create(
124
+ "acct_01j9a43avnfqzbjfch6pygv1td",
125
+ message_params: {conversation: {contact: {phone_number: "+18015551234"}}},
126
+ request_options: {max_retries: 5}
127
+ )
118
128
  ```
119
129
 
120
130
  ### Timeouts
@@ -128,7 +138,11 @@ surge = SurgeAPI::Client.new(
128
138
  )
129
139
 
130
140
  # Or, configure per-request:
131
- surge.messages.create("acct_01j9a43avnfqzbjfch6pygv1td", request_options: {timeout: 5})
141
+ surge.messages.create(
142
+ "acct_01j9a43avnfqzbjfch6pygv1td",
143
+ message_params: {conversation: {contact: {phone_number: "+18015551234"}}},
144
+ request_options: {timeout: 5}
145
+ )
132
146
  ```
133
147
 
134
148
  On timeout, `SurgeAPI::Errors::APITimeoutError` is raised.
@@ -161,6 +175,7 @@ Note: the `extra_` parameters of the same name overrides the documented paramete
161
175
  message =
162
176
  surge.messages.create(
163
177
  "acct_01j9a43avnfqzbjfch6pygv1td",
178
+ message_params: {conversation: {contact: {phone_number: "+18015551234"}}},
164
179
  request_options: {
165
180
  extra_query: {my_query_parameter: value},
166
181
  extra_body: {my_body_parameter: value},
@@ -206,17 +221,37 @@ This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitio
206
221
  You can provide typesafe request parameters like so:
207
222
 
208
223
  ```ruby
209
- surge.messages.create("acct_01j9a43avnfqzbjfch6pygv1td")
224
+ surge.messages.create(
225
+ "acct_01j9a43avnfqzbjfch6pygv1td",
226
+ message_params: SurgeAPI::MessageParams::MessageParamsWithConversation.new(
227
+ conversation: SurgeAPI::MessageParams::MessageParamsWithConversation::Conversation.new(
228
+ contact: SurgeAPI::MessageParams::MessageParamsWithConversation::Conversation::Contact.new(
229
+ phone_number: "+18015551234"
230
+ )
231
+ )
232
+ )
233
+ )
210
234
  ```
211
235
 
212
236
  Or, equivalently:
213
237
 
214
238
  ```ruby
215
239
  # Hashes work, but are not typesafe:
216
- surge.messages.create("acct_01j9a43avnfqzbjfch6pygv1td")
240
+ surge.messages.create(
241
+ "acct_01j9a43avnfqzbjfch6pygv1td",
242
+ message_params: {conversation: {contact: {phone_number: "+18015551234"}}}
243
+ )
217
244
 
218
245
  # You can also splat a full Params class:
219
- params = SurgeAPI::MessageCreateParams.new
246
+ params = SurgeAPI::MessageCreateParams.new(
247
+ message_params: SurgeAPI::MessageParams::MessageParamsWithConversation.new(
248
+ conversation: SurgeAPI::MessageParams::MessageParamsWithConversation::Conversation.new(
249
+ contact: SurgeAPI::MessageParams::MessageParamsWithConversation::Conversation::Contact.new(
250
+ phone_number: "+18015551234"
251
+ )
252
+ )
253
+ )
254
+ )
220
255
  surge.messages.create("acct_01j9a43avnfqzbjfch6pygv1td", **params)
221
256
  ```
222
257
 
@@ -225,25 +260,25 @@ surge.messages.create("acct_01j9a43avnfqzbjfch6pygv1td", **params)
225
260
  Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:
226
261
 
227
262
  ```ruby
228
- # :high
229
- puts(SurgeAPI::CampaignParams::Volume::HIGH)
263
+ # :local
264
+ puts(SurgeAPI::PhoneNumberPurchaseParams::Type::LOCAL)
230
265
 
231
- # Revealed type: `T.all(SurgeAPI::CampaignParams::Volume, Symbol)`
232
- T.reveal_type(SurgeAPI::CampaignParams::Volume::HIGH)
266
+ # Revealed type: `T.all(SurgeAPI::PhoneNumberPurchaseParams::Type, Symbol)`
267
+ T.reveal_type(SurgeAPI::PhoneNumberPurchaseParams::Type::LOCAL)
233
268
  ```
234
269
 
235
270
  Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
236
271
 
237
272
  ```ruby
238
273
  # Using the enum constants preserves the tagged type information:
239
- surge.campaigns.create(
240
- volume: SurgeAPI::CampaignParams::Volume::HIGH,
274
+ surge.phone_numbers.purchase(
275
+ type: SurgeAPI::PhoneNumberPurchaseParams::Type::LOCAL,
241
276
  # …
242
277
  )
243
278
 
244
279
  # Literal values are also permissible:
245
- surge.campaigns.create(
246
- volume: :high,
280
+ surge.phone_numbers.purchase(
281
+ type: :local,
247
282
  # …
248
283
  )
249
284
  ```
@@ -18,6 +18,9 @@ module SurgeAPI
18
18
  # @return [String]
19
19
  attr_reader :api_key
20
20
 
21
+ # @return [String, nil]
22
+ attr_reader :webhook_signing_secret
23
+
21
24
  # @return [SurgeAPI::Resources::Accounts]
22
25
  attr_reader :accounts
23
26
 
@@ -67,6 +70,8 @@ module SurgeAPI
67
70
  #
68
71
  # @param api_key [String, nil] Defaults to `ENV["SURGE_API_KEY"]`
69
72
  #
73
+ # @param webhook_signing_secret [String, nil] Defaults to `ENV["SURGE_WEBHOOK_SIGNING_SECRET"]`
74
+ #
70
75
  # @param base_url [String, nil] Override the default base URL for the API, e.g.,
71
76
  # `"https://api.example.com/v2/"`. Defaults to `ENV["SURGE_BASE_URL"]`
72
77
  #
@@ -79,6 +84,7 @@ module SurgeAPI
79
84
  # @param max_retry_delay [Float]
80
85
  def initialize(
81
86
  api_key: ENV["SURGE_API_KEY"],
87
+ webhook_signing_secret: ENV["SURGE_WEBHOOK_SIGNING_SECRET"],
82
88
  base_url: ENV["SURGE_BASE_URL"],
83
89
  max_retries: self.class::DEFAULT_MAX_RETRIES,
84
90
  timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
@@ -91,14 +97,29 @@ module SurgeAPI
91
97
  raise ArgumentError.new("api_key is required, and can be set via environ: \"SURGE_API_KEY\"")
92
98
  end
93
99
 
100
+ headers = {}
101
+ custom_headers_env = ENV["SURGE_CUSTOM_HEADERS"]
102
+ unless custom_headers_env.nil?
103
+ parsed = {}
104
+ custom_headers_env.split("\n").each do |line|
105
+ colon = line.index(":")
106
+ unless colon.nil?
107
+ parsed[line[0...colon].strip] = line[(colon + 1)..].strip
108
+ end
109
+ end
110
+ headers = parsed.merge(headers)
111
+ end
112
+
94
113
  @api_key = api_key.to_s
114
+ @webhook_signing_secret = webhook_signing_secret&.to_s
95
115
 
96
116
  super(
97
117
  base_url: base_url,
98
118
  timeout: timeout,
99
119
  max_retries: max_retries,
100
120
  initial_retry_delay: initial_retry_delay,
101
- max_retry_delay: max_retry_delay
121
+ max_retry_delay: max_retry_delay,
122
+ headers: headers
102
123
  )
103
124
 
104
125
  @accounts = SurgeAPI::Resources::Accounts.new(client: self)
@@ -306,6 +306,11 @@ module SurgeAPI
306
306
  SurgeAPI::Internal::Util.deep_merge(*[req[:body], opts[:extra_body]].compact)
307
307
  end
308
308
 
309
+ # Generated methods always pass `req[:body]` for operations that define a
310
+ # request body, so only elide the content-type header when the operation
311
+ # has no body at all, not when an optional body param was omitted.
312
+ headers.delete("content-type") if body.nil? && !req.key?(:body)
313
+
309
314
  url = SurgeAPI::Internal::Util.join_parsed_uri(
310
315
  @base_url_components,
311
316
  {**req, path: path, query: query}
@@ -157,7 +157,7 @@ module SurgeAPI
157
157
  in Hash | nil => coerced
158
158
  coerced
159
159
  else
160
- message = "Expected a #{Hash} or #{SurgeAPI::Internal::Type::BaseModel}, got #{data.inspect}"
160
+ message = "Expected a #{Hash} or #{SurgeAPI::Internal::Type::BaseModel}, got #{input.inspect}"
161
161
  raise ArgumentError.new(message)
162
162
  end
163
163
  end
@@ -237,6 +237,11 @@ module SurgeAPI
237
237
  end
238
238
  end
239
239
 
240
+ # @type [Regexp]
241
+ #
242
+ # https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
243
+ RFC_3986_NOT_PCHARS = /[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/
244
+
240
245
  class << self
241
246
  # @api private
242
247
  #
@@ -247,6 +252,15 @@ module SurgeAPI
247
252
  "#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}"
248
253
  end
249
254
 
255
+ # @api private
256
+ #
257
+ # @param path [String, Integer]
258
+ #
259
+ # @return [String]
260
+ def encode_path(path)
261
+ path.to_s.gsub(SurgeAPI::Internal::Util::RFC_3986_NOT_PCHARS) { ERB::Util.url_encode(_1) }
262
+ end
263
+
250
264
  # @api private
251
265
  #
252
266
  # @param path [String, Array<String>]
@@ -259,7 +273,7 @@ module SurgeAPI
259
273
  in []
260
274
  ""
261
275
  in [String => p, *interpolations]
262
- encoded = interpolations.map { ERB::Util.url_encode(_1) }
276
+ encoded = interpolations.map { encode_path(_1) }
263
277
  format(p, *encoded)
264
278
  end
265
279
  end
@@ -571,16 +585,15 @@ module SurgeAPI
571
585
  y << "Content-Disposition: form-data"
572
586
 
573
587
  unless key.nil?
574
- name = ERB::Util.url_encode(key.to_s)
575
- y << "; name=\"#{name}\""
588
+ y << "; name=\"#{key}\""
576
589
  end
577
590
 
578
591
  case val
579
592
  in SurgeAPI::FilePart unless val.filename.nil?
580
- filename = ERB::Util.url_encode(val.filename)
593
+ filename = encode_path(val.filename)
581
594
  y << "; filename=\"#{filename}\""
582
595
  in Pathname | IO
583
- filename = ERB::Util.url_encode(::File.basename(val.to_path))
596
+ filename = encode_path(::File.basename(val.to_path))
584
597
  y << "; filename=\"#{filename}\""
585
598
  else
586
599
  end
@@ -597,6 +610,7 @@ module SurgeAPI
597
610
  #
598
611
  # @return [Array(String, Enumerable<String>)]
599
612
  private def encode_multipart_streaming(body)
613
+ # rubocop:disable Style/CaseEquality
600
614
  # RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
601
615
  boundary = SecureRandom.urlsafe_base64(46)
602
616
 
@@ -606,7 +620,7 @@ module SurgeAPI
606
620
  in Hash
607
621
  body.each do |key, val|
608
622
  case val
609
- in Array if val.all? { primitive?(_1) }
623
+ in Array if val.all? { primitive?(_1) || SurgeAPI::Internal::Type::FileInput === _1 }
610
624
  val.each do |v|
611
625
  write_multipart_chunk(y, boundary: boundary, key: key, val: v, closing: closing)
612
626
  end
@@ -622,6 +636,7 @@ module SurgeAPI
622
636
 
623
637
  fused_io = fused_enum(strio) { closing.each(&:call) }
624
638
  [boundary, fused_io]
639
+ # rubocop:enable Style/CaseEquality
625
640
  end
626
641
 
627
642
  # @api private
@@ -7,7 +7,15 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
- # @!method initialize(request_options: {})
10
+ # @!attribute id
11
+ # The ID of the account to archive.
12
+ #
13
+ # @return [String]
14
+ required :id, String
15
+
16
+ # @!method initialize(id:, request_options: {})
17
+ # @param id [String] The ID of the account to archive.
18
+ #
11
19
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
12
20
  end
13
21
  end
@@ -7,6 +7,12 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute account_id
11
+ # ID of the account to check
12
+ #
13
+ # @return [String]
14
+ required :account_id, String
15
+
10
16
  # @!attribute capabilities
11
17
  # capabilities about which to check the status
12
18
  #
@@ -14,7 +20,9 @@ module SurgeAPI
14
20
  optional :capabilities,
15
21
  -> { SurgeAPI::Internal::Type::ArrayOf[enum: SurgeAPI::AccountRetrieveStatusParams::Capability] }
16
22
 
17
- # @!method initialize(capabilities: nil, request_options: {})
23
+ # @!method initialize(account_id:, capabilities: nil, request_options: {})
24
+ # @param account_id [String] ID of the account to check
25
+ #
18
26
  # @param capabilities [Array<Symbol, SurgeAPI::Models::AccountRetrieveStatusParams::Capability>] capabilities about which to check the status
19
27
  #
20
28
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
@@ -7,6 +7,12 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute id
11
+ # The ID for the account to update.
12
+ #
13
+ # @return [String]
14
+ required :id, String
15
+
10
16
  # @!attribute brand_name
11
17
  # The name by which the people this account communicates with know it. If not
12
18
  # provided, this will match the name field.
@@ -37,10 +43,12 @@ module SurgeAPI
37
43
  # @return [String, nil]
38
44
  optional :time_zone, String, nil?: true
39
45
 
40
- # @!method initialize(brand_name: nil, name: nil, organization: nil, time_zone: nil, request_options: {})
46
+ # @!method initialize(id:, brand_name: nil, name: nil, organization: nil, time_zone: nil, request_options: {})
41
47
  # Some parameter documentations has been truncated, see
42
48
  # {SurgeAPI::Models::AccountUpdateParams} for more details.
43
49
  #
50
+ # @param id [String] The ID for the account to update.
51
+ #
44
52
  # @param brand_name [String] The name by which the people this account communicates with know it. If not prov
45
53
  #
46
54
  # @param name [String] The name of the account that will be visible for your internal organizational pu
@@ -7,7 +7,15 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
- # @!method initialize(request_options: {})
10
+ # @!attribute attachment_id
11
+ # The ID of the attachment.
12
+ #
13
+ # @return [String]
14
+ required :attachment_id, String
15
+
16
+ # @!method initialize(attachment_id:, request_options: {})
17
+ # @param attachment_id [String] The ID of the attachment.
18
+ #
11
19
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
12
20
  end
13
21
  end
@@ -7,6 +7,12 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute audience_id
11
+ # The audience ID to add the contact to.
12
+ #
13
+ # @return [String]
14
+ required :audience_id, String
15
+
10
16
  # @!attribute id
11
17
  # The ID of the contact to add. The contact must belong to the same account as the
12
18
  # audience.
@@ -14,10 +20,12 @@ module SurgeAPI
14
20
  # @return [String]
15
21
  required :id, String
16
22
 
17
- # @!method initialize(id:, request_options: {})
23
+ # @!method initialize(audience_id:, id:, request_options: {})
18
24
  # Some parameter documentations has been truncated, see
19
25
  # {SurgeAPI::Models::AudienceAddContactParams} for more details.
20
26
  #
27
+ # @param audience_id [String] The audience ID to add the contact to.
28
+ #
21
29
  # @param id [String] The ID of the contact to add. The contact must belong to the same account as the
22
30
  #
23
31
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
@@ -7,13 +7,21 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute account_id
11
+ # The account for which the audience should be created.
12
+ #
13
+ # @return [String]
14
+ required :account_id, String
15
+
10
16
  # @!attribute name
11
17
  # The audience name.
12
18
  #
13
19
  # @return [String]
14
20
  required :name, String
15
21
 
16
- # @!method initialize(name:, request_options: {})
22
+ # @!method initialize(account_id:, name:, request_options: {})
23
+ # @param account_id [String] The account for which the audience should be created.
24
+ #
17
25
  # @param name [String] The audience name.
18
26
  #
19
27
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
@@ -7,6 +7,12 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute audience_id
11
+ # The audience ID to list contacts for.
12
+ #
13
+ # @return [String]
14
+ required :audience_id, String
15
+
10
16
  # @!attribute after
11
17
  # Cursor for forward pagination. Use the next_cursor from a previous response.
12
18
  #
@@ -20,10 +26,12 @@ module SurgeAPI
20
26
  # @return [String, nil]
21
27
  optional :before, String
22
28
 
23
- # @!method initialize(after: nil, before: nil, request_options: {})
29
+ # @!method initialize(audience_id:, after: nil, before: nil, request_options: {})
24
30
  # Some parameter documentations has been truncated, see
25
31
  # {SurgeAPI::Models::AudienceListContactsParams} for more details.
26
32
  #
33
+ # @param audience_id [String] The audience ID to list contacts for.
34
+ #
27
35
  # @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
28
36
  #
29
37
  # @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
@@ -7,6 +7,12 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute account_id
11
+ # The account for which the blast should be sent.
12
+ #
13
+ # @return [String]
14
+ required :account_id, String
15
+
10
16
  # @!attribute attachments
11
17
  #
12
18
  # @return [Array<SurgeAPI::Models::BlastCreateParams::Attachment>, nil]
@@ -61,10 +67,12 @@ module SurgeAPI
61
67
  # @return [Array<String>, nil]
62
68
  optional :to, SurgeAPI::Internal::Type::ArrayOf[String]
63
69
 
64
- # @!method initialize(attachments: nil, body: nil, contacts: nil, from: nil, name: nil, segments: nil, send_at: nil, to: nil, request_options: {})
70
+ # @!method initialize(account_id:, attachments: nil, body: nil, contacts: nil, from: nil, name: nil, segments: nil, send_at: nil, to: nil, request_options: {})
65
71
  # Some parameter documentations has been truncated, see
66
72
  # {SurgeAPI::Models::BlastCreateParams} for more details.
67
73
  #
74
+ # @param account_id [String] The account for which the blast should be sent.
75
+ #
68
76
  # @param attachments [Array<SurgeAPI::Models::BlastCreateParams::Attachment>]
69
77
  #
70
78
  # @param body [String, nil] The message body.
@@ -7,18 +7,14 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
- # @!attribute campaign_params
11
- # Parameters for creating a new campaign. Either provide full campaign details or
12
- # import using a TCR ID.
10
+ # @!attribute account_id
11
+ # The account for which the campaign should be created.
13
12
  #
14
- # @return [SurgeAPI::Models::CampaignParams::StandardCampaignParams, SurgeAPI::Models::CampaignParams::ExternalCampaignParams]
15
- required :campaign_params, union: -> { SurgeAPI::CampaignParams }
13
+ # @return [String]
14
+ required :account_id, String
16
15
 
17
- # @!method initialize(campaign_params:, request_options: {})
18
- # Some parameter documentations has been truncated, see
19
- # {SurgeAPI::Models::CampaignCreateParams} for more details.
20
- #
21
- # @param campaign_params [SurgeAPI::Models::CampaignParams::StandardCampaignParams, SurgeAPI::Models::CampaignParams::ExternalCampaignParams] Parameters for creating a new campaign. Either provide full campaign details or
16
+ # @!method initialize(account_id:, request_options: {})
17
+ # @param account_id [String] The account for which the campaign should be created.
22
18
  #
23
19
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
24
20
  end
@@ -7,6 +7,12 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute account_id
11
+ # The account ID to list campaigns for.
12
+ #
13
+ # @return [String]
14
+ required :account_id, String
15
+
10
16
  # @!attribute after
11
17
  # Cursor for forward pagination. Use the next_cursor from a previous response.
12
18
  #
@@ -20,10 +26,12 @@ module SurgeAPI
20
26
  # @return [String, nil]
21
27
  optional :before, String
22
28
 
23
- # @!method initialize(after: nil, before: nil, request_options: {})
29
+ # @!method initialize(account_id:, after: nil, before: nil, request_options: {})
24
30
  # Some parameter documentations has been truncated, see
25
31
  # {SurgeAPI::Models::CampaignListParams} for more details.
26
32
  #
33
+ # @param account_id [String] The account ID to list campaigns for.
34
+ #
27
35
  # @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
28
36
  #
29
37
  # @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
@@ -7,7 +7,15 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
- # @!method initialize(request_options: {})
10
+ # @!attribute id
11
+ # The ID of the campaign to retrieve.
12
+ #
13
+ # @return [String]
14
+ required :id, String
15
+
16
+ # @!method initialize(id:, request_options: {})
17
+ # @param id [String] The ID of the campaign to retrieve.
18
+ #
11
19
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
12
20
  end
13
21
  end
@@ -7,18 +7,14 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
- # @!attribute campaign_params
11
- # Parameters for creating a new campaign. Either provide full campaign details or
12
- # import using a TCR ID.
10
+ # @!attribute id
11
+ # The ID of the campaign to update.
13
12
  #
14
- # @return [SurgeAPI::Models::CampaignParams::StandardCampaignParams, SurgeAPI::Models::CampaignParams::ExternalCampaignParams]
15
- required :campaign_params, union: -> { SurgeAPI::CampaignParams }
13
+ # @return [String]
14
+ required :id, String
16
15
 
17
- # @!method initialize(campaign_params:, request_options: {})
18
- # Some parameter documentations has been truncated, see
19
- # {SurgeAPI::Models::CampaignUpdateParams} for more details.
20
- #
21
- # @param campaign_params [SurgeAPI::Models::CampaignParams::StandardCampaignParams, SurgeAPI::Models::CampaignParams::ExternalCampaignParams] Parameters for creating a new campaign. Either provide full campaign details or
16
+ # @!method initialize(id:, request_options: {})
17
+ # @param id [String] The ID of the campaign to update.
22
18
  #
23
19
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
24
20
  end
@@ -7,6 +7,12 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute account_id
11
+ # The account for which the contact should be created.
12
+ #
13
+ # @return [String]
14
+ required :account_id, String
15
+
10
16
  # @!attribute phone_number
11
17
  # The contact's phone number in E.164 format.
12
18
  #
@@ -37,7 +43,9 @@ module SurgeAPI
37
43
  # @return [Hash{Symbol=>String}, nil]
38
44
  optional :metadata, SurgeAPI::Internal::Type::HashOf[String]
39
45
 
40
- # @!method initialize(phone_number:, email: nil, first_name: nil, last_name: nil, metadata: nil, request_options: {})
46
+ # @!method initialize(account_id:, phone_number:, email: nil, first_name: nil, last_name: nil, metadata: nil, request_options: {})
47
+ # @param account_id [String] The account for which the contact should be created.
48
+ #
41
49
  # @param phone_number [String] The contact's phone number in E.164 format.
42
50
  #
43
51
  # @param email [String] The contact's email address.