Class: Sendmux::Sending::Generated::AttachmentsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/sendmux_sending_generated/api/attachments_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AttachmentsApi

Returns a new instance of AttachmentsApi.



19
20
21
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#sending_complete_attachment_upload(x_sendmux_upload_token, content_length, upload_id, body, opts = {}) ⇒ AttachmentUploadResponse

Upload bytes to an attachment upload URL 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.

Parameters:

  • x_sendmux_upload_token (String)

    Short-lived upload token returned by POST /emails/attachment-uploads.

  • content_length (Integer)

    Exact number of bytes in the binary request body.

  • upload_id (String)

    Upload intent ID returned by POST /emails/attachment-uploads.

  • body (File)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



30
31
32
33
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 30

def sending_complete_attachment_upload(x_sendmux_upload_token, content_length, upload_id, body, opts = {})
  data, _status_code, _headers = sending_complete_attachment_upload_with_http_info(x_sendmux_upload_token, content_length, upload_id, body, opts)
  data
end

#sending_complete_attachment_upload_with_http_info(x_sendmux_upload_token, content_length, upload_id, body, opts = {}) ⇒ Array<(AttachmentUploadResponse, Integer, Hash)>

Upload bytes to an attachment upload URL 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.

Parameters:

  • x_sendmux_upload_token (String)

    Short-lived upload token returned by POST /emails/attachment-uploads.

  • content_length (Integer)

    Exact number of bytes in the binary request body.

  • upload_id (String)

    Upload intent ID returned by POST /emails/attachment-uploads.

  • body (File)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(AttachmentUploadResponse, Integer, Hash)>)

    AttachmentUploadResponse data, response status code and response headers



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 43

def sending_complete_attachment_upload_with_http_info(x_sendmux_upload_token, content_length, upload_id, body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_complete_attachment_upload ...'
  end
  # verify the required parameter 'x_sendmux_upload_token' is set
  if @api_client.config.client_side_validation && x_sendmux_upload_token.nil?
    fail ArgumentError, "Missing the required parameter 'x_sendmux_upload_token' when calling AttachmentsApi.sending_complete_attachment_upload"
  end
  # verify the required parameter 'content_length' is set
  if @api_client.config.client_side_validation && content_length.nil?
    fail ArgumentError, "Missing the required parameter 'content_length' when calling AttachmentsApi.sending_complete_attachment_upload"
  end
  if @api_client.config.client_side_validation && content_length < 1
    fail ArgumentError, 'invalid value for "content_length" when calling AttachmentsApi.sending_complete_attachment_upload, must be greater than or equal to 1.'
  end

  # verify the required parameter 'upload_id' is set
  if @api_client.config.client_side_validation && upload_id.nil?
    fail ArgumentError, "Missing the required parameter 'upload_id' when calling AttachmentsApi.sending_complete_attachment_upload"
  end
  pattern = Regexp.new(/^upl_[a-z0-9]{24}$/)
  if @api_client.config.client_side_validation && upload_id !~ pattern
    fail ArgumentError, "invalid value for 'upload_id' when calling AttachmentsApi.sending_complete_attachment_upload, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling AttachmentsApi.sending_complete_attachment_upload"
  end
  # resource path
  local_var_path = '/emails/attachment-uploads/{upload_id}'.sub('{upload_id}', CGI.escape(upload_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/octet-stream'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'X-Sendmux-Upload-Token'] = x_sendmux_upload_token
  header_params[:'Content-Length'] = content_length

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'AttachmentUploadResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"AttachmentsApi.sending_complete_attachment_upload",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttachmentsApi#sending_complete_attachment_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#sending_create_attachment_upload(attachment_upload_intent_request, opts = {}) ⇒ AttachmentUploadIntentResponse

Create an attachment upload URL 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.

Parameters:

Options Hash (opts):

  • :idempotency_key (String)

    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.

Returns:



125
126
127
128
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 125

def sending_create_attachment_upload(attachment_upload_intent_request, opts = {})
  data, _status_code, _headers = sending_create_attachment_upload_with_http_info(attachment_upload_intent_request, opts)
  data
end

#sending_create_attachment_upload_with_http_info(attachment_upload_intent_request, opts = {}) ⇒ Array<(AttachmentUploadIntentResponse, Integer, Hash)>

Create an attachment upload URL 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.

Parameters:

Options Hash (opts):

  • :idempotency_key (String)

    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.

Returns:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 136

def sending_create_attachment_upload_with_http_info(attachment_upload_intent_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_create_attachment_upload ...'
  end
  # verify the required parameter 'attachment_upload_intent_request' is set
  if @api_client.config.client_side_validation && attachment_upload_intent_request.nil?
    fail ArgumentError, "Missing the required parameter 'attachment_upload_intent_request' when calling AttachmentsApi.sending_create_attachment_upload"
  end
  if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
    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.'
  end

  # resource path
  local_var_path = '/emails/attachment-uploads'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(attachment_upload_intent_request)

  # return_type
  return_type = opts[:debug_return_type] || 'AttachmentUploadIntentResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerAuth']

  new_options = opts.merge(
    :operation => :"AttachmentsApi.sending_create_attachment_upload",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttachmentsApi#sending_create_attachment_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#sending_get_attachment(attachment_id, opts = {}) ⇒ AttachmentUploadResponse

Get attachment metadata Return metadata for a temporary uploaded attachment owned by the authenticated team. File bytes are not returned.

Parameters:

  • attachment_id (String)

    Temporary attachment ID returned by an upload endpoint.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



199
200
201
202
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 199

def sending_get_attachment(attachment_id, opts = {})
  data, _status_code, _headers = sending_get_attachment_with_http_info(attachment_id, opts)
  data
end

#sending_get_attachment_with_http_info(attachment_id, opts = {}) ⇒ Array<(AttachmentUploadResponse, Integer, Hash)>

Get attachment metadata Return metadata for a temporary uploaded attachment owned by the authenticated team. File bytes are not returned.

Parameters:

  • attachment_id (String)

    Temporary attachment ID returned by an upload endpoint.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(AttachmentUploadResponse, Integer, Hash)>)

    AttachmentUploadResponse data, response status code and response headers



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 209

def sending_get_attachment_with_http_info(attachment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_get_attachment ...'
  end
  # verify the required parameter 'attachment_id' is set
  if @api_client.config.client_side_validation && attachment_id.nil?
    fail ArgumentError, "Missing the required parameter 'attachment_id' when calling AttachmentsApi.sending_get_attachment"
  end
  pattern = Regexp.new(/^att_[a-z0-9]{24}$/)
  if @api_client.config.client_side_validation && attachment_id !~ pattern
    fail ArgumentError, "invalid value for 'attachment_id' when calling AttachmentsApi.sending_get_attachment, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/emails/attachments/{attachment_id}'.sub('{attachment_id}', CGI.escape(attachment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'AttachmentUploadResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerAuth']

  new_options = opts.merge(
    :operation => :"AttachmentsApi.sending_get_attachment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttachmentsApi#sending_get_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#sending_upload_attachment(content_length, filename, body, opts = {}) ⇒ AttachmentUploadResponse

Upload an attachment Upload binary attachment bytes and receive a temporary attachment_id for use in attachments. Requires email.send permission.

Parameters:

  • content_length (Integer)

    Exact number of bytes in the binary request body.

  • filename (String)

    Filename to associate with the uploaded attachment.

  • body (File)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    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.

  • :content_type (String)

    MIME type override for the uploaded attachment.

Returns:



271
272
273
274
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 271

def sending_upload_attachment(content_length, filename, body, opts = {})
  data, _status_code, _headers = sending_upload_attachment_with_http_info(content_length, filename, body, opts)
  data
end

#sending_upload_attachment_with_http_info(content_length, filename, body, opts = {}) ⇒ Array<(AttachmentUploadResponse, Integer, Hash)>

Upload an attachment Upload binary attachment bytes and receive a temporary attachment_id for use in attachments. Requires `email.send` permission.

Parameters:

  • content_length (Integer)

    Exact number of bytes in the binary request body.

  • filename (String)

    Filename to associate with the uploaded attachment.

  • body (File)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    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.

  • :content_type (String)

    MIME type override for the uploaded attachment.

Returns:

  • (Array<(AttachmentUploadResponse, Integer, Hash)>)

    AttachmentUploadResponse data, response status code and response headers



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/sendmux_sending_generated/api/attachments_api.rb', line 285

def sending_upload_attachment_with_http_info(content_length, filename, body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_upload_attachment ...'
  end
  # verify the required parameter 'content_length' is set
  if @api_client.config.client_side_validation && content_length.nil?
    fail ArgumentError, "Missing the required parameter 'content_length' when calling AttachmentsApi.sending_upload_attachment"
  end
  if @api_client.config.client_side_validation && content_length < 1
    fail ArgumentError, 'invalid value for "content_length" when calling AttachmentsApi.sending_upload_attachment, must be greater than or equal to 1.'
  end

  # verify the required parameter 'filename' is set
  if @api_client.config.client_side_validation && filename.nil?
    fail ArgumentError, "Missing the required parameter 'filename' when calling AttachmentsApi.sending_upload_attachment"
  end
  if @api_client.config.client_side_validation && filename.to_s.length > 255
    fail ArgumentError, 'invalid value for "filename" when calling AttachmentsApi.sending_upload_attachment, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && filename.to_s.length < 1
    fail ArgumentError, 'invalid value for "filename" when calling AttachmentsApi.sending_upload_attachment, the character length must be greater than or equal to 1.'
  end

  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling AttachmentsApi.sending_upload_attachment"
  end
  if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
    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.'
  end

  if @api_client.config.client_side_validation && !opts[:'content_type'].nil? && opts[:'content_type'].to_s.length > 255
    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.'
  end

  # resource path
  local_var_path = '/emails/attachments'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filename'] = filename
  query_params[:'content_type'] = opts[:'content_type'] if !opts[:'content_type'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/octet-stream'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'Content-Length'] = content_length
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'AttachmentUploadResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerAuth']

  new_options = opts.merge(
    :operation => :"AttachmentsApi.sending_upload_attachment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttachmentsApi#sending_upload_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end