Sha256: 228d5570487976ba885b972e3ad21c54e2a48eecb7fb6d134e32d26fa713809e

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

module Nuncium
  module Responses
    module Messages
      class Attachment
        attr_accessor :file_type, :file_name, :encoded_content, :decoded_content

        def initialize(hash)
          @file_type = hash['dmMimeType']
          @file_name = hash['dmFileDescr']
          @encoded_content = hash['dmEncodedContent']
          @decoded_content = Base64.decode64(@encoded_content)
        end

        def download(destination = '/tmp')
          file_destination = "#{destination}/#{@file_name}"
          File.open(file_destination, 'wb') do |f|
            f.write(@decoded_content)
          end
          file_destination
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nuncium-0.13.0 lib/nuncium/responses/messages/attachment.rb