Class: Zm::Client::Message
- Inherits:
-
Base::Object
- Object
- Base::Object
- Zm::Client::Message
- Includes:
- BelongsToFolder, BelongsToTag
- Defined in:
- lib/zm/client/message/message.rb,
lib/zm/client/message/message_flags.rb,
lib/zm/client/message/message_recipients.rb,
lib/zm/client/message/attachments_collection.rb
Overview
class message for account
Defined Under Namespace
Classes: Attachment, AttachmentsCollection, Body, FlagsCollection, Recipient, Recipients
Instance Attribute Summary collapse
-
#autoSendTime ⇒ Object
Returns the value of attribute autoSendTime.
-
#d ⇒ Object
Returns the value of attribute d.
-
#f ⇒ Object
Returns the value of attribute f.
-
#fr ⇒ Object
Returns the value of attribute fr.
-
#id ⇒ Object
Returns the value of attribute id.
-
#idnt ⇒ Object
Returns the value of attribute idnt.
-
#l ⇒ Object
Returns the value of attribute l.
-
#mid ⇒ Object
Returns the value of attribute mid.
-
#s ⇒ Object
(also: #size)
Returns the value of attribute s.
-
#su ⇒ Object
Returns the value of attribute su.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#tn ⇒ Object
Returns the value of attribute tn.
Attributes inherited from Base::Object
Instance Method Summary collapse
- #attachments ⇒ Object
- #body ⇒ Object
- #create!(*args) ⇒ Object
- #date ⇒ Object
- #delete! ⇒ Object
- #download(dest_file_path, fmt = 'eml') ⇒ Object
- #flags ⇒ Object
-
#initialize(parent) {|_self| ... } ⇒ Message
constructor
A new instance of Message.
- #jsns_builder ⇒ Object
- #modify!(*args) ⇒ Object
- #read(fmt = 'eml') ⇒ Object
- #recipients ⇒ Object
- #rename!(*args) ⇒ Object
- #sacc ⇒ Object
- #send! ⇒ Object
- #spam! ⇒ Object
- #unspam! ⇒ Object
- #update!(l: nil, rgb: nil, color: nil, f: nil, tn: nil) ⇒ Object
Methods included from BelongsToTag
Methods included from BelongsToFolder
#folder, #folder!, #folder=, #folder_id, #move!, #trash!
Methods inherited from Base::Object
#clone, #inspect, #instance_variables_map, #logger, #recorded?, #save!, #to_h, #to_s, #update_attribute
Constructor Details
#initialize(parent) {|_self| ... } ⇒ Message
Returns a new instance of Message.
14 15 16 17 18 19 |
# File 'lib/zm/client/message/message.rb', line 14 def initialize(parent) @parent = parent @subject = '' yield(self) if block_given? end |
Instance Attribute Details
#autoSendTime ⇒ Object
Returns the value of attribute autoSendTime.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def autoSendTime @autoSendTime end |
#d ⇒ Object
Returns the value of attribute d.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def d @d end |
#f ⇒ Object
Returns the value of attribute f.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def f @f end |
#fr ⇒ Object
Returns the value of attribute fr.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def fr @fr end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def id @id end |
#idnt ⇒ Object
Returns the value of attribute idnt.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def idnt @idnt end |
#l ⇒ Object
Returns the value of attribute l.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def l @l end |
#mid ⇒ Object
Returns the value of attribute mid.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def mid @mid end |
#s ⇒ Object Also known as: size
Returns the value of attribute s.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def s @s end |
#su ⇒ Object
Returns the value of attribute su.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def su @su end |
#subject ⇒ Object
Returns the value of attribute subject.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def subject @subject end |
#tn ⇒ Object
Returns the value of attribute tn.
10 11 12 |
# File 'lib/zm/client/message/message.rb', line 10 def tn @tn end |
Instance Method Details
#attachments ⇒ Object
27 28 29 30 31 |
# File 'lib/zm/client/message/message.rb', line 27 def return if defined? = AttachmentsCollection.new end |
#body ⇒ Object
33 34 35 36 37 |
# File 'lib/zm/client/message/message.rb', line 33 def body return @body if defined? @body @body = Body.new end |
#create!(*args) ⇒ Object
57 58 59 |
# File 'lib/zm/client/message/message.rb', line 57 def create!(*args) raise NotImplementedError end |
#date ⇒ Object
49 50 51 |
# File 'lib/zm/client/message/message.rb', line 49 def date @date ||= Time.at(d.to_i / 1000) end |
#delete! ⇒ Object
88 89 90 91 92 93 |
# File 'lib/zm/client/message/message.rb', line 88 def delete! return false if @id.nil? @parent.sacc.invoke(jsns_builder.to_delete) @id = nil end |
#download(dest_file_path, fmt = 'eml') ⇒ Object
39 40 41 42 |
# File 'lib/zm/client/message/message.rb', line 39 def download(dest_file_path, fmt = 'eml') uploader = Upload.new(@parent, RestAccountConnector.new) uploader.download_file( Zm::Client::FolderDefault::ROOT[:path], fmt, [Zm::Client::FolderView::MESSAGE], [@id], dest_file_path) end |
#flags ⇒ Object
53 54 55 |
# File 'lib/zm/client/message/message.rb', line 53 def flags @flags ||= FlagsCollection.new(self) end |
#jsns_builder ⇒ Object
117 118 119 |
# File 'lib/zm/client/message/message.rb', line 117 def jsns_builder @jsns_builder ||= MessageJsnsBuilder.new(self) end |
#modify!(*args) ⇒ Object
61 62 63 |
# File 'lib/zm/client/message/message.rb', line 61 def modify!(*args) raise NotImplementedError end |
#read(fmt = 'eml') ⇒ Object
44 45 46 47 |
# File 'lib/zm/client/message/message.rb', line 44 def read(fmt = 'eml') uploader = Upload.new(@parent, RestAccountConnector.new) uploader.read_file( Zm::Client::FolderDefault::ROOT[:path], fmt, [Zm::Client::FolderView::MESSAGE], [@id]) end |
#recipients ⇒ Object
21 22 23 24 25 |
# File 'lib/zm/client/message/message.rb', line 21 def recipients return @recipients if defined? @recipients @recipients = Recipients.new end |
#rename!(*args) ⇒ Object
84 85 86 |
# File 'lib/zm/client/message/message.rb', line 84 def rename!(*args) raise NotImplementedError end |
#sacc ⇒ Object
113 114 115 |
# File 'lib/zm/client/message/message.rb', line 113 def sacc @parent.sacc end |
#send! ⇒ Object
103 104 105 106 |
# File 'lib/zm/client/message/message.rb', line 103 def send! soap_request = SoapElement.mail(SoapMailConstants::SEND_MSG_REQUEST).add_attributes(jsns_builder.to_jsns) @parent.sacc.invoke(soap_request) end |
#spam! ⇒ Object
99 100 101 |
# File 'lib/zm/client/message/message.rb', line 99 def spam! @parent.sacc.invoke(jsns_builder.to_spam) end |
#unspam! ⇒ Object
95 96 97 |
# File 'lib/zm/client/message/message.rb', line 95 def unspam! @parent.sacc.invoke(jsns_builder.to_unspam) end |
#update!(l: nil, rgb: nil, color: nil, f: nil, tn: nil) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/zm/client/message/message.rb', line 65 def update!(l: nil, rgb: nil, color: nil, f: nil, tn: nil) attrs = { op: :update, id: @id, l: l, rgb: rgb, color: color, f: f, tn: tn } attrs.delete_if { |_, v| v.nil? } soap_request = SoapElement.mail(SoapMailConstants::MSG_ACTION_REQUEST) node_action = SoapElement.create(SoapConstants::ACTION).add_attributes(attrs) soap_request.add_node(node_action) @parent.sacc.invoke(soap_request) end |