class SocketLabs::InjectionApi::Core::Serialization::AttachmentJson

Represents a message attachment in the form of a byte array. To be serialized into JSON string before sending to the Injection Api.

Attributes

content[RW]

Content of an Attachment. The BASE64 encoded str.

content_id[RW]

ContentId for an Attachment.

custom_headers[RW]

the list of custom headers added to the attachment.

mime_type[RW]

the MIME type of the attachment.

name[RW]

the name of attachment

Public Class Methods

new() click to toggle source

Initializes a new instance of the AttachmentJson class

# File lib/socketlabs/injectionapi/core/serialization/attachment_json.rb, line 25
def initialize
  @name = nil
  @mime_type = nil
  @content_id = nil
  @content = nil
  @custom_headers = Array.new
end

Public Instance Methods

to_hash() click to toggle source

build json hash for AttachmentJson @return [hash]

# File lib/socketlabs/injectionapi/core/serialization/attachment_json.rb, line 35
def to_hash
  json =
  {
    :name=> @name,
    :content=> @content,
    :contentType=> @mime_type
  }
  unless @content_id.nil? || @content_id.empty?
    json[:contentId] = @content_id
  end
  unless @custom_headers.nil? || @custom_headers.length == 0
    e = Array.new
    @custom_headers.each do |value|
      e.push(value.to_hash)
    end
    json[:customHeaders] = e
  end
  json
end