Class: SocketLabs::InjectionApi::Core::Serialization::AttachmentJson
- Inherits:
-
Object
- Object
- SocketLabs::InjectionApi::Core::Serialization::AttachmentJson
- Defined in:
- lib/socketlabs/injectionapi/core/serialization/attachment_json.rb
Overview
Represents a message attachment in the form of a byte array. To be serialized into JSON string before sending to the Injection Api.
Instance Attribute Summary collapse
-
#content ⇒ Object
Content of an Attachment.
-
#content_id ⇒ Object
ContentId for an Attachment.
-
#custom_headers ⇒ Object
the list of custom headers added to the attachment.
-
#mime_type ⇒ Object
the MIME type of the attachment.
-
#name ⇒ Object
the name of attachment.
Instance Method Summary collapse
-
#initialize ⇒ AttachmentJson
constructor
Initializes a new instance of the AttachmentJson class.
-
#to_hash ⇒ hash
build json hash for AttachmentJson.
Constructor Details
#initialize ⇒ AttachmentJson
Initializes a new instance of the AttachmentJson class
25 26 27 28 29 30 31 |
# 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 |
Instance Attribute Details
#content ⇒ Object
Content of an Attachment. The BASE64 encoded str.
20 21 22 |
# File 'lib/socketlabs/injectionapi/core/serialization/attachment_json.rb', line 20 def content @content end |
#content_id ⇒ Object
ContentId for an Attachment.
18 19 20 |
# File 'lib/socketlabs/injectionapi/core/serialization/attachment_json.rb', line 18 def content_id @content_id end |
#custom_headers ⇒ Object
the list of custom headers added to the attachment.
22 23 24 |
# File 'lib/socketlabs/injectionapi/core/serialization/attachment_json.rb', line 22 def custom_headers @custom_headers end |
#mime_type ⇒ Object
the MIME type of the attachment.
16 17 18 |
# File 'lib/socketlabs/injectionapi/core/serialization/attachment_json.rb', line 16 def mime_type @mime_type end |
#name ⇒ Object
the name of attachment
14 15 16 |
# File 'lib/socketlabs/injectionapi/core/serialization/attachment_json.rb', line 14 def name @name end |
Instance Method Details
#to_hash ⇒ hash
build json hash for AttachmentJson
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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 |