From ad74632897a466e93444737c5569c7f7780d3ac9 Mon Sep 17 00:00:00 2001 From: nikkel Date: Fri, 20 Mar 2020 02:24:48 +0700 Subject: [PATCH] Upload files to 'lib/postman' --- lib/postman/attachment.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/postman/attachment.rb diff --git a/lib/postman/attachment.rb b/lib/postman/attachment.rb new file mode 100644 index 0000000..7226dc2 --- /dev/null +++ b/lib/postman/attachment.rb @@ -0,0 +1,31 @@ +require 'base64' + +module Postman + class Attachment + + def initialize(attributes) + @attributes = attributes + end + + def filename + @attributes['filename'] + end + + def content_type + @attributes['content_type'] + end + + def size + @attributes['size'] + end + + def hash + @attributes['hash'] + end + + def data + @data ||= Base64.decode64(@attributes['data']) + end + + end +end