class MailSlurpClient::AttachmentControllerApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/mailslurp_client/api/attachment_controller_api.rb, line 19
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

delete_all_attachments(opts = {}) click to toggle source

Delete all attachments @param [Hash] opts the optional parameters @return [nil]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 25
def delete_all_attachments(opts = {})
  delete_all_attachments_with_http_info(opts)
  nil
end
delete_all_attachments_with_http_info(opts = {}) click to toggle source

Delete all attachments @param [Hash] opts the optional parameters @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 33
def delete_all_attachments_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.delete_all_attachments ...'
  end
  # resource path
  local_var_path = '/attachments'

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

  # header parameters
  header_params = opts[:header_params] || {}

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

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

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttachmentControllerApi#delete_all_attachments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
delete_attachment(attachment_id, opts = {}) click to toggle source

Delete an attachment Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with `SendEmailOptions` when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [nil]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 79
def delete_attachment(attachment_id, opts = {})
  delete_attachment_with_http_info(attachment_id, opts)
  nil
end
delete_attachment_with_http_info(attachment_id, opts = {}) click to toggle source

Delete an attachment Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with &#x60;SendEmailOptions&#x60; when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 89
def delete_attachment_with_http_info(attachment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.delete_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 AttachmentControllerApi.delete_attachment"
  end
  # resource path
  local_var_path = '/attachments/{attachmentId}'.sub('{' + 'attachmentId' + '}', CGI.escape(attachment_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}

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

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

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttachmentControllerApi#delete_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
download_attachment_as_base64_encoded(attachment_id, opts = {}) click to toggle source

Get email attachment as base64 encoded string as alternative to binary responses. To read the content decode the Base64 encoded contents. Returns the specified attachment for a given email as a base 64 encoded string. The response type is application/json. This method is similar to the `downloadAttachment` method but allows some clients to get around issues with binary responses. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [DownloadAttachmentDto]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 139
def download_attachment_as_base64_encoded(attachment_id, opts = {})
  data, _status_code, _headers = download_attachment_as_base64_encoded_with_http_info(attachment_id, opts)
  data
end
download_attachment_as_base64_encoded_with_http_info(attachment_id, opts = {}) click to toggle source

Get email attachment as base64 encoded string as alternative to binary responses. To read the content decode the Base64 encoded contents. Returns the specified attachment for a given email as a base 64 encoded string. The response type is application/json. This method is similar to the &#x60;downloadAttachment&#x60; method but allows some clients to get around issues with binary responses. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [Array<(DownloadAttachmentDto, Integer, Hash)>] DownloadAttachmentDto data, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 149
def download_attachment_as_base64_encoded_with_http_info(attachment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.download_attachment_as_base64_encoded ...'
  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 AttachmentControllerApi.download_attachment_as_base64_encoded"
  end
  # resource path
  local_var_path = '/attachments/{attachmentId}/base64'.sub('{' + 'attachmentId' + '}', 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'])

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

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

  # return_type
  return_type = opts[:return_type] || 'DownloadAttachmentDto' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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: AttachmentControllerApi#download_attachment_as_base64_encoded\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
download_attachment_as_bytes(attachment_id, opts = {}) click to toggle source

Download attachments. Get email attachment bytes. If you have trouble with byte responses try the `downloadAttachmentBase64` response endpoints. Returns the specified attachment for a given email as a stream / array of bytes. You can find attachment ids in email responses endpoint responses. The response type is application/octet-stream. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [String]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 201
def download_attachment_as_bytes(attachment_id, opts = {})
  data, _status_code, _headers = download_attachment_as_bytes_with_http_info(attachment_id, opts)
  data
end
download_attachment_as_bytes_with_http_info(attachment_id, opts = {}) click to toggle source

Download attachments. Get email attachment bytes. If you have trouble with byte responses try the &#x60;downloadAttachmentBase64&#x60; response endpoints. Returns the specified attachment for a given email as a stream / array of bytes. You can find attachment ids in email responses endpoint responses. The response type is application/octet-stream. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [Array<(String, Integer, Hash)>] String data, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 211
def download_attachment_as_bytes_with_http_info(attachment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.download_attachment_as_bytes ...'
  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 AttachmentControllerApi.download_attachment_as_bytes"
  end
  # resource path
  local_var_path = '/attachments/{attachmentId}/bytes'.sub('{' + 'attachmentId' + '}', 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/octet-stream'])

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

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

  # return_type
  return_type = opts[:return_type] || 'String' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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: AttachmentControllerApi#download_attachment_as_bytes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_attachment(attachment_id, opts = {}) click to toggle source

Get an attachment entity Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with `SendEmailOptions` when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [AttachmentEntity]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 263
def get_attachment(attachment_id, opts = {})
  data, _status_code, _headers = get_attachment_with_http_info(attachment_id, opts)
  data
end
get_attachment_info(attachment_id, opts = {}) click to toggle source

Get email attachment metadata information Returns the metadata for an attachment. It is saved separately to the content of the attachment. Contains properties `name` and `content-type` and `content-length` in bytes for a given attachment. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [AttachmentMetaData]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 325
def get_attachment_info(attachment_id, opts = {})
  data, _status_code, _headers = get_attachment_info_with_http_info(attachment_id, opts)
  data
end
get_attachment_info_with_http_info(attachment_id, opts = {}) click to toggle source

Get email attachment metadata information Returns the metadata for an attachment. It is saved separately to the content of the attachment. Contains properties &#x60;name&#x60; and &#x60;content-type&#x60; and &#x60;content-length&#x60; in bytes for a given attachment. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [Array<(AttachmentMetaData, Integer, Hash)>] AttachmentMetaData data, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 335
def get_attachment_info_with_http_info(attachment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.get_attachment_info ...'
  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 AttachmentControllerApi.get_attachment_info"
  end
  # resource path
  local_var_path = '/attachments/{attachmentId}/metadata'.sub('{' + 'attachmentId' + '}', 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'])

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

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

  # return_type
  return_type = opts[:return_type] || 'AttachmentMetaData' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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: AttachmentControllerApi#get_attachment_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_attachment_with_http_info(attachment_id, opts = {}) click to toggle source

Get an attachment entity Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with &#x60;SendEmailOptions&#x60; when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param attachment_id [String] ID of attachment @param [Hash] opts the optional parameters @return [Array<(AttachmentEntity, Integer, Hash)>] AttachmentEntity data, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 273
def get_attachment_with_http_info(attachment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.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 AttachmentControllerApi.get_attachment"
  end
  # resource path
  local_var_path = '/attachments/{attachmentId}'.sub('{' + 'attachmentId' + '}', 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'])

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

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

  # return_type
  return_type = opts[:return_type] || 'AttachmentEntity' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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: AttachmentControllerApi#get_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_attachments(opts = {}) click to toggle source

Get email attachments Get all attachments in paginated response. Each entity contains meta data for the attachment such as `name` and `content-type`. Use the `attachmentId` and the download endpoints to get the file contents. @param [Hash] opts the optional parameters @option opts [DateTime] :before Filter by created at before the given timestamp @option opts [String] :file_name_filter Optional file name and content type search filter @option opts [Integer] :page Optional page index event list pagination (default to 0) @option opts [DateTime] :since Filter by created at after the given timestamp @option opts [Integer] :size Optional page size event list pagination (default to 20) @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC') @return [PageAttachmentEntity]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 392
def get_attachments(opts = {})
  data, _status_code, _headers = get_attachments_with_http_info(opts)
  data
end
get_attachments_with_http_info(opts = {}) click to toggle source

Get email attachments Get all attachments in paginated response. Each entity contains meta data for the attachment such as &#x60;name&#x60; and &#x60;content-type&#x60;. Use the &#x60;attachmentId&#x60; and the download endpoints to get the file contents. @param [Hash] opts the optional parameters @option opts [DateTime] :before Filter by created at before the given timestamp @option opts [String] :file_name_filter Optional file name and content type search filter @option opts [Integer] :page Optional page index event list pagination @option opts [DateTime] :since Filter by created at after the given timestamp @option opts [Integer] :size Optional page size event list pagination @option opts [String] :sort Optional createdAt sort direction ASC or DESC @return [Array<(PageAttachmentEntity, Integer, Hash)>] PageAttachmentEntity data, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 407
def get_attachments_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.get_attachments ...'
  end
  allowable_values = ["ASC", "DESC"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/attachments'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
  query_params[:'fileNameFilter'] = opts[:'file_name_filter'] if !opts[:'file_name_filter'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
  query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

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

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

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

  # return_type
  return_type = opts[:return_type] || 'PageAttachmentEntity' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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: AttachmentControllerApi#get_attachments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
upload_attachment(upload_options, opts = {}) click to toggle source

Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment. Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with `SendEmailOptions` when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param upload_options [UploadAttachmentOptions] uploadOptions @param [Hash] opts the optional parameters @return [Array<String>]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 465
def upload_attachment(upload_options, opts = {})
  data, _status_code, _headers = upload_attachment_with_http_info(upload_options, opts)
  data
end
upload_attachment_bytes(opts = {}) click to toggle source

Upload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment. Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with `SendEmailOptions` when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param [Hash] opts the optional parameters @option opts [String] :content_type Optional contentType for file. For instance &#x60;application/pdf&#x60; @option opts [String] :filename Optional filename to save upload with @option opts [String] :byte_array Byte array request body @return [Array<String>]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 531
def upload_attachment_bytes(opts = {})
  data, _status_code, _headers = upload_attachment_bytes_with_http_info(opts)
  data
end
upload_attachment_bytes_with_http_info(opts = {}) click to toggle source

Upload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment. Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with &#x60;SendEmailOptions&#x60; when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param [Hash] opts the optional parameters @option opts [String] :content_type Optional contentType for file. For instance &#x60;application/pdf&#x60; @option opts [String] :filename Optional filename to save upload with @option opts [String] :byte_array Byte array request body @return [Array<(Array<String>, Integer, Hash)>] Array<String> data, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 543
def upload_attachment_bytes_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.upload_attachment_bytes ...'
  end
  # resource path
  local_var_path = '/attachments/bytes'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/octet-stream'])

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

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

  # return_type
  return_type = opts[:return_type] || 'Array<String>' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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: AttachmentControllerApi#upload_attachment_bytes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
upload_attachment_with_http_info(upload_options, opts = {}) click to toggle source

Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment. Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with &#x60;SendEmailOptions&#x60; when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param upload_options [UploadAttachmentOptions] uploadOptions @param [Hash] opts the optional parameters @return [Array<(Array<String>, Integer, Hash)>] Array<String> data, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 475
def upload_attachment_with_http_info(upload_options, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.upload_attachment ...'
  end
  # verify the required parameter 'upload_options' is set
  if @api_client.config.client_side_validation && upload_options.nil?
    fail ArgumentError, "Missing the required parameter 'upload_options' when calling AttachmentControllerApi.upload_attachment"
  end
  # resource path
  local_var_path = '/attachments'

  # 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'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

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

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

  # return_type
  return_type = opts[:return_type] || 'Array<String>' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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: AttachmentControllerApi#upload_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
upload_multipart_form(file, opts = {}) click to toggle source

Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment. Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with `SendEmailOptions` when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param file [File] file @param [Hash] opts the optional parameters @option opts [String] :content_type Optional content type of attachment @option opts [String] :filename Optional name of file @option opts [String] :x_filename Optional content type header of attachment @return [Array<String>]

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 598
def upload_multipart_form(file, opts = {})
  data, _status_code, _headers = upload_multipart_form_with_http_info(file, opts)
  data
end
upload_multipart_form_with_http_info(file, opts = {}) click to toggle source

Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment. Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with &#x60;SendEmailOptions&#x60; when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. @param file [File] file @param [Hash] opts the optional parameters @option opts [String] :content_type Optional content type of attachment @option opts [String] :filename Optional name of file @option opts [String] :x_filename Optional content type header of attachment @return [Array<(Array<String>, Integer, Hash)>] Array<String> data, response status code and response headers

# File lib/mailslurp_client/api/attachment_controller_api.rb, line 611
def upload_multipart_form_with_http_info(file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AttachmentControllerApi.upload_multipart_form ...'
  end
  # verify the required parameter 'file' is set
  if @api_client.config.client_side_validation && file.nil?
    fail ArgumentError, "Missing the required parameter 'file' when calling AttachmentControllerApi.upload_multipart_form"
  end
  # resource path
  local_var_path = '/attachments/multipart'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])

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

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

  # return_type
  return_type = opts[:return_type] || 'Array<String>' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :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: AttachmentControllerApi#upload_multipart_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end