sendmux-sending 1.1.0 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5301be9c45f5bac835a7737c78dc6d1cdeecd233d281b89d1f8ecec9f1edbf10
4
- data.tar.gz: d5e0f65ed993691e988e1ca9d25051dc3188ff62e7151ae67804338677bc04c6
3
+ metadata.gz: 6dbfe224c407947d8b0b69e3c8ac663c5d2e6af75b820ef775971f40fb659545
4
+ data.tar.gz: d73c320e4b15a22d56b28a82e96076780c5b77009e185f0a4e7fcc517785ea40
5
5
  SHA512:
6
- metadata.gz: 0cafeb960f73fc14508a567ff55a7a21548f64b3ae188d42b3d7ae9b3cab023c9aa61806dd51a6c1997bd7adb5a95d3051e4c576b47da0fb9193208c468a7a22
7
- data.tar.gz: f4f5aeb71bb646281e9798f5404a2bb833f5f73b4731fb10685a83adf35b548abdc8da3825598fadac44348abf834135a211aca700af2e4c36ec160df90bb781
6
+ metadata.gz: 20b08ea90472135d92dcf0e346790489cd219c2f64c8004b0dbc3881cc01746eb8b0b98862bb27e9bd55999fd771098116f69dda0373916bce80e9979780e65c
7
+ data.tar.gz: a05947636992ca4e2b71d35cc73219a008c53000d83eb4a954bda632bbd3ccbc6e6924c2810ef510eb5b7506c8762d257bf6c631da7e8aa21c6681ce0bdf45fb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-sending/v1.1.0...ruby-sending/v1.2.0) (2026-07-08)
4
+
5
+
6
+ ### Features
7
+
8
+ * **sdk:** add sending attachment upload surfaces ([#96](https://github.com/Sendmux/sendmux-sdk/issues/96)) ([b8f9d5f](https://github.com/Sendmux/sendmux-sdk/commit/b8f9d5fe3c1ae510db82ce05c55cbcad92b43b44))
9
+
3
10
  ## [1.1.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-sending/v1.0.0...ruby-sending/v1.1.0) (2026-07-01)
4
11
 
5
12
 
@@ -26,6 +26,10 @@ module Sendmux
26
26
  @api_client = ApiClient.new(@configuration)
27
27
  end
28
28
 
29
+ def attachments
30
+ @attachments ||= Generated::AttachmentsApi.new(@api_client)
31
+ end
32
+
29
33
  def emails
30
34
  @emails ||= Generated::EmailsApi.new(@api_client)
31
35
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sendmux
4
4
  module Sending
5
- VERSION = '1.1.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
@@ -0,0 +1,370 @@
1
+ =begin
2
+ #Sendmux Sending API
3
+
4
+ #Send emails programmatically via the Sendmux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module Sendmux::Sending::Generated
16
+ class AttachmentsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Upload bytes to an attachment upload URL
23
+ # Upload the exact binary bytes for a previously-created attachment upload URL. This operation uses the short-lived upload token header returned by POST /emails/attachment-uploads, not a Sendmux API key.
24
+ # @param x_sendmux_upload_token [String] Short-lived upload token returned by POST /emails/attachment-uploads.
25
+ # @param content_length [Integer] Exact number of bytes in the binary request body.
26
+ # @param upload_id [String] Upload intent ID returned by POST /emails/attachment-uploads.
27
+ # @param body [File]
28
+ # @param [Hash] opts the optional parameters
29
+ # @return [AttachmentUploadResponse]
30
+ def sending_complete_attachment_upload(x_sendmux_upload_token, content_length, upload_id, body, opts = {})
31
+ data, _status_code, _headers = sending_complete_attachment_upload_with_http_info(x_sendmux_upload_token, content_length, upload_id, body, opts)
32
+ data
33
+ end
34
+
35
+ # Upload bytes to an attachment upload URL
36
+ # Upload the exact binary bytes for a previously-created attachment upload URL. This operation uses the short-lived upload token header returned by POST /emails/attachment-uploads, not a Sendmux API key.
37
+ # @param x_sendmux_upload_token [String] Short-lived upload token returned by POST /emails/attachment-uploads.
38
+ # @param content_length [Integer] Exact number of bytes in the binary request body.
39
+ # @param upload_id [String] Upload intent ID returned by POST /emails/attachment-uploads.
40
+ # @param body [File]
41
+ # @param [Hash] opts the optional parameters
42
+ # @return [Array<(AttachmentUploadResponse, Integer, Hash)>] AttachmentUploadResponse data, response status code and response headers
43
+ def sending_complete_attachment_upload_with_http_info(x_sendmux_upload_token, content_length, upload_id, body, opts = {})
44
+ if @api_client.config.debugging
45
+ @api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_complete_attachment_upload ...'
46
+ end
47
+ # verify the required parameter 'x_sendmux_upload_token' is set
48
+ if @api_client.config.client_side_validation && x_sendmux_upload_token.nil?
49
+ fail ArgumentError, "Missing the required parameter 'x_sendmux_upload_token' when calling AttachmentsApi.sending_complete_attachment_upload"
50
+ end
51
+ # verify the required parameter 'content_length' is set
52
+ if @api_client.config.client_side_validation && content_length.nil?
53
+ fail ArgumentError, "Missing the required parameter 'content_length' when calling AttachmentsApi.sending_complete_attachment_upload"
54
+ end
55
+ if @api_client.config.client_side_validation && content_length < 1
56
+ fail ArgumentError, 'invalid value for "content_length" when calling AttachmentsApi.sending_complete_attachment_upload, must be greater than or equal to 1.'
57
+ end
58
+
59
+ # verify the required parameter 'upload_id' is set
60
+ if @api_client.config.client_side_validation && upload_id.nil?
61
+ fail ArgumentError, "Missing the required parameter 'upload_id' when calling AttachmentsApi.sending_complete_attachment_upload"
62
+ end
63
+ pattern = Regexp.new(/^upl_[a-z0-9]{24}$/)
64
+ if @api_client.config.client_side_validation && upload_id !~ pattern
65
+ fail ArgumentError, "invalid value for 'upload_id' when calling AttachmentsApi.sending_complete_attachment_upload, must conform to the pattern #{pattern}."
66
+ end
67
+
68
+ # verify the required parameter 'body' is set
69
+ if @api_client.config.client_side_validation && body.nil?
70
+ fail ArgumentError, "Missing the required parameter 'body' when calling AttachmentsApi.sending_complete_attachment_upload"
71
+ end
72
+ # resource path
73
+ local_var_path = '/emails/attachment-uploads/{upload_id}'.sub('{upload_id}', CGI.escape(upload_id.to_s))
74
+
75
+ # query parameters
76
+ query_params = opts[:query_params] || {}
77
+
78
+ # header parameters
79
+ header_params = opts[:header_params] || {}
80
+ # HTTP header 'Accept' (if needed)
81
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
82
+ # HTTP header 'Content-Type'
83
+ content_type = @api_client.select_header_content_type(['application/octet-stream'])
84
+ if !content_type.nil?
85
+ header_params['Content-Type'] = content_type
86
+ end
87
+ header_params[:'X-Sendmux-Upload-Token'] = x_sendmux_upload_token
88
+ header_params[:'Content-Length'] = content_length
89
+
90
+ # form parameters
91
+ form_params = opts[:form_params] || {}
92
+
93
+ # http body (model)
94
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
95
+
96
+ # return_type
97
+ return_type = opts[:debug_return_type] || 'AttachmentUploadResponse'
98
+
99
+ # auth_names
100
+ auth_names = opts[:debug_auth_names] || []
101
+
102
+ new_options = opts.merge(
103
+ :operation => :"AttachmentsApi.sending_complete_attachment_upload",
104
+ :header_params => header_params,
105
+ :query_params => query_params,
106
+ :form_params => form_params,
107
+ :body => post_body,
108
+ :auth_names => auth_names,
109
+ :return_type => return_type
110
+ )
111
+
112
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
113
+ if @api_client.config.debugging
114
+ @api_client.config.logger.debug "API called: AttachmentsApi#sending_complete_attachment_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
115
+ end
116
+ return data, status_code, headers
117
+ end
118
+
119
+ # Create an attachment upload URL
120
+ # Create a short-lived upload URL and token that lets a remote client PUT one binary attachment without exposing the API key on the upload request. Requires `email.send` permission.
121
+ # @param attachment_upload_intent_request [AttachmentUploadIntentRequest]
122
+ # @param [Hash] opts the optional parameters
123
+ # @option opts [String] :idempotency_key Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.
124
+ # @return [AttachmentUploadIntentResponse]
125
+ def sending_create_attachment_upload(attachment_upload_intent_request, opts = {})
126
+ data, _status_code, _headers = sending_create_attachment_upload_with_http_info(attachment_upload_intent_request, opts)
127
+ data
128
+ end
129
+
130
+ # Create an attachment upload URL
131
+ # Create a short-lived upload URL and token that lets a remote client PUT one binary attachment without exposing the API key on the upload request. Requires &#x60;email.send&#x60; permission.
132
+ # @param attachment_upload_intent_request [AttachmentUploadIntentRequest]
133
+ # @param [Hash] opts the optional parameters
134
+ # @option opts [String] :idempotency_key Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.
135
+ # @return [Array<(AttachmentUploadIntentResponse, Integer, Hash)>] AttachmentUploadIntentResponse data, response status code and response headers
136
+ def sending_create_attachment_upload_with_http_info(attachment_upload_intent_request, opts = {})
137
+ if @api_client.config.debugging
138
+ @api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_create_attachment_upload ...'
139
+ end
140
+ # verify the required parameter 'attachment_upload_intent_request' is set
141
+ if @api_client.config.client_side_validation && attachment_upload_intent_request.nil?
142
+ fail ArgumentError, "Missing the required parameter 'attachment_upload_intent_request' when calling AttachmentsApi.sending_create_attachment_upload"
143
+ end
144
+ if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
145
+ fail ArgumentError, 'invalid value for "opts[:"idempotency_key"]" when calling AttachmentsApi.sending_create_attachment_upload, the character length must be smaller than or equal to 255.'
146
+ end
147
+
148
+ # resource path
149
+ local_var_path = '/emails/attachment-uploads'
150
+
151
+ # query parameters
152
+ query_params = opts[:query_params] || {}
153
+
154
+ # header parameters
155
+ header_params = opts[:header_params] || {}
156
+ # HTTP header 'Accept' (if needed)
157
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
158
+ # HTTP header 'Content-Type'
159
+ content_type = @api_client.select_header_content_type(['application/json'])
160
+ if !content_type.nil?
161
+ header_params['Content-Type'] = content_type
162
+ end
163
+ header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
164
+
165
+ # form parameters
166
+ form_params = opts[:form_params] || {}
167
+
168
+ # http body (model)
169
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(attachment_upload_intent_request)
170
+
171
+ # return_type
172
+ return_type = opts[:debug_return_type] || 'AttachmentUploadIntentResponse'
173
+
174
+ # auth_names
175
+ auth_names = opts[:debug_auth_names] || ['BearerAuth']
176
+
177
+ new_options = opts.merge(
178
+ :operation => :"AttachmentsApi.sending_create_attachment_upload",
179
+ :header_params => header_params,
180
+ :query_params => query_params,
181
+ :form_params => form_params,
182
+ :body => post_body,
183
+ :auth_names => auth_names,
184
+ :return_type => return_type
185
+ )
186
+
187
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
188
+ if @api_client.config.debugging
189
+ @api_client.config.logger.debug "API called: AttachmentsApi#sending_create_attachment_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
190
+ end
191
+ return data, status_code, headers
192
+ end
193
+
194
+ # Get attachment metadata
195
+ # Return metadata for a temporary uploaded attachment owned by the authenticated team. File bytes are not returned.
196
+ # @param attachment_id [String] Temporary attachment ID returned by an upload endpoint.
197
+ # @param [Hash] opts the optional parameters
198
+ # @return [AttachmentUploadResponse]
199
+ def sending_get_attachment(attachment_id, opts = {})
200
+ data, _status_code, _headers = sending_get_attachment_with_http_info(attachment_id, opts)
201
+ data
202
+ end
203
+
204
+ # Get attachment metadata
205
+ # Return metadata for a temporary uploaded attachment owned by the authenticated team. File bytes are not returned.
206
+ # @param attachment_id [String] Temporary attachment ID returned by an upload endpoint.
207
+ # @param [Hash] opts the optional parameters
208
+ # @return [Array<(AttachmentUploadResponse, Integer, Hash)>] AttachmentUploadResponse data, response status code and response headers
209
+ def sending_get_attachment_with_http_info(attachment_id, opts = {})
210
+ if @api_client.config.debugging
211
+ @api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_get_attachment ...'
212
+ end
213
+ # verify the required parameter 'attachment_id' is set
214
+ if @api_client.config.client_side_validation && attachment_id.nil?
215
+ fail ArgumentError, "Missing the required parameter 'attachment_id' when calling AttachmentsApi.sending_get_attachment"
216
+ end
217
+ pattern = Regexp.new(/^att_[a-z0-9]{24}$/)
218
+ if @api_client.config.client_side_validation && attachment_id !~ pattern
219
+ fail ArgumentError, "invalid value for 'attachment_id' when calling AttachmentsApi.sending_get_attachment, must conform to the pattern #{pattern}."
220
+ end
221
+
222
+ # resource path
223
+ local_var_path = '/emails/attachments/{attachment_id}'.sub('{attachment_id}', CGI.escape(attachment_id.to_s))
224
+
225
+ # query parameters
226
+ query_params = opts[:query_params] || {}
227
+
228
+ # header parameters
229
+ header_params = opts[:header_params] || {}
230
+ # HTTP header 'Accept' (if needed)
231
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
232
+
233
+ # form parameters
234
+ form_params = opts[:form_params] || {}
235
+
236
+ # http body (model)
237
+ post_body = opts[:debug_body]
238
+
239
+ # return_type
240
+ return_type = opts[:debug_return_type] || 'AttachmentUploadResponse'
241
+
242
+ # auth_names
243
+ auth_names = opts[:debug_auth_names] || ['BearerAuth']
244
+
245
+ new_options = opts.merge(
246
+ :operation => :"AttachmentsApi.sending_get_attachment",
247
+ :header_params => header_params,
248
+ :query_params => query_params,
249
+ :form_params => form_params,
250
+ :body => post_body,
251
+ :auth_names => auth_names,
252
+ :return_type => return_type
253
+ )
254
+
255
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
256
+ if @api_client.config.debugging
257
+ @api_client.config.logger.debug "API called: AttachmentsApi#sending_get_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
258
+ end
259
+ return data, status_code, headers
260
+ end
261
+
262
+ # Upload an attachment
263
+ # Upload binary attachment bytes and receive a temporary attachment_id for use in attachments[]. Requires `email.send` permission.
264
+ # @param content_length [Integer] Exact number of bytes in the binary request body.
265
+ # @param filename [String] Filename to associate with the uploaded attachment.
266
+ # @param body [File]
267
+ # @param [Hash] opts the optional parameters
268
+ # @option opts [String] :idempotency_key Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.
269
+ # @option opts [String] :content_type MIME type override for the uploaded attachment.
270
+ # @return [AttachmentUploadResponse]
271
+ def sending_upload_attachment(content_length, filename, body, opts = {})
272
+ data, _status_code, _headers = sending_upload_attachment_with_http_info(content_length, filename, body, opts)
273
+ data
274
+ end
275
+
276
+ # Upload an attachment
277
+ # Upload binary attachment bytes and receive a temporary attachment_id for use in attachments[]. Requires &#x60;email.send&#x60; permission.
278
+ # @param content_length [Integer] Exact number of bytes in the binary request body.
279
+ # @param filename [String] Filename to associate with the uploaded attachment.
280
+ # @param body [File]
281
+ # @param [Hash] opts the optional parameters
282
+ # @option opts [String] :idempotency_key Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.
283
+ # @option opts [String] :content_type MIME type override for the uploaded attachment.
284
+ # @return [Array<(AttachmentUploadResponse, Integer, Hash)>] AttachmentUploadResponse data, response status code and response headers
285
+ def sending_upload_attachment_with_http_info(content_length, filename, body, opts = {})
286
+ if @api_client.config.debugging
287
+ @api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_upload_attachment ...'
288
+ end
289
+ # verify the required parameter 'content_length' is set
290
+ if @api_client.config.client_side_validation && content_length.nil?
291
+ fail ArgumentError, "Missing the required parameter 'content_length' when calling AttachmentsApi.sending_upload_attachment"
292
+ end
293
+ if @api_client.config.client_side_validation && content_length < 1
294
+ fail ArgumentError, 'invalid value for "content_length" when calling AttachmentsApi.sending_upload_attachment, must be greater than or equal to 1.'
295
+ end
296
+
297
+ # verify the required parameter 'filename' is set
298
+ if @api_client.config.client_side_validation && filename.nil?
299
+ fail ArgumentError, "Missing the required parameter 'filename' when calling AttachmentsApi.sending_upload_attachment"
300
+ end
301
+ if @api_client.config.client_side_validation && filename.to_s.length > 255
302
+ fail ArgumentError, 'invalid value for "filename" when calling AttachmentsApi.sending_upload_attachment, the character length must be smaller than or equal to 255.'
303
+ end
304
+
305
+ if @api_client.config.client_side_validation && filename.to_s.length < 1
306
+ fail ArgumentError, 'invalid value for "filename" when calling AttachmentsApi.sending_upload_attachment, the character length must be greater than or equal to 1.'
307
+ end
308
+
309
+ # verify the required parameter 'body' is set
310
+ if @api_client.config.client_side_validation && body.nil?
311
+ fail ArgumentError, "Missing the required parameter 'body' when calling AttachmentsApi.sending_upload_attachment"
312
+ end
313
+ if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
314
+ fail ArgumentError, 'invalid value for "opts[:"idempotency_key"]" when calling AttachmentsApi.sending_upload_attachment, the character length must be smaller than or equal to 255.'
315
+ end
316
+
317
+ if @api_client.config.client_side_validation && !opts[:'content_type'].nil? && opts[:'content_type'].to_s.length > 255
318
+ fail ArgumentError, 'invalid value for "opts[:"content_type"]" when calling AttachmentsApi.sending_upload_attachment, the character length must be smaller than or equal to 255.'
319
+ end
320
+
321
+ # resource path
322
+ local_var_path = '/emails/attachments'
323
+
324
+ # query parameters
325
+ query_params = opts[:query_params] || {}
326
+ query_params[:'filename'] = filename
327
+ query_params[:'content_type'] = opts[:'content_type'] if !opts[:'content_type'].nil?
328
+
329
+ # header parameters
330
+ header_params = opts[:header_params] || {}
331
+ # HTTP header 'Accept' (if needed)
332
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
333
+ # HTTP header 'Content-Type'
334
+ content_type = @api_client.select_header_content_type(['application/octet-stream'])
335
+ if !content_type.nil?
336
+ header_params['Content-Type'] = content_type
337
+ end
338
+ header_params[:'Content-Length'] = content_length
339
+ header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
340
+
341
+ # form parameters
342
+ form_params = opts[:form_params] || {}
343
+
344
+ # http body (model)
345
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
346
+
347
+ # return_type
348
+ return_type = opts[:debug_return_type] || 'AttachmentUploadResponse'
349
+
350
+ # auth_names
351
+ auth_names = opts[:debug_auth_names] || ['BearerAuth']
352
+
353
+ new_options = opts.merge(
354
+ :operation => :"AttachmentsApi.sending_upload_attachment",
355
+ :header_params => header_params,
356
+ :query_params => query_params,
357
+ :form_params => form_params,
358
+ :body => post_body,
359
+ :auth_names => auth_names,
360
+ :return_type => return_type
361
+ )
362
+
363
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
364
+ if @api_client.config.debugging
365
+ @api_client.config.logger.debug "API called: AttachmentsApi#sending_upload_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
366
+ end
367
+ return data, status_code, headers
368
+ end
369
+ end
370
+ end
@@ -114,7 +114,7 @@ module Sendmux::Sending::Generated
114
114
  config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
115
115
  end
116
116
  end
117
- request.headers = header_params
117
+ request.headers = stringify_header_params(header_params)
118
118
  request.body = req_body
119
119
 
120
120
  # Overload default options only if provided
@@ -126,6 +126,12 @@ module Sendmux::Sending::Generated
126
126
  request
127
127
  end
128
128
 
129
+ def stringify_header_params(header_params)
130
+ header_params.each_with_object({}) do |(key, value), result|
131
+ result[key] = value.nil? ? value : value.to_s
132
+ end
133
+ end
134
+
129
135
  # Builds the HTTP request body
130
136
  #
131
137
  # @param [Hash] header_params Header parameters