Class: Zm::Client::Message

Inherits:
Base::Object show all
Includes:
BelongsToFolder, BelongsToTag, MailboxItemConcern, RequestMethodsMailbox
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

Attributes included from MailboxItemConcern

#l

Attributes inherited from Base::Object

#id, #name, #parent, #token

Instance Method Summary collapse

Methods included from MailboxItemConcern

#id, #id=, #mailbox_id

Methods included from RequestMethodsMailbox

#build_delete, #delete!

Methods included from BelongsToTag

#tags

Methods included from BelongsToFolder

#folder, #folder!, #folder=, #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.

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
21
22
23
24
25
26
# File 'lib/zm/client/message/message.rb', line 17

def initialize(parent)
  @parent = parent
  @subject = ''

  @recipients = Recipients.new
  @body = Body.new
  @attachments = AttachmentsCollection.new

  yield(self) if block_given?
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



13
14
15
# File 'lib/zm/client/message/message.rb', line 13

def attachments
  @attachments
end

#autoSendTimeObject

Returns the value of attribute autoSendTime.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def autoSendTime
  @autoSendTime
end

#bodyObject (readonly)

Returns the value of attribute body.



13
14
15
# File 'lib/zm/client/message/message.rb', line 13

def body
  @body
end

#dObject

Returns the value of attribute d.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def d
  @d
end

#fObject

Returns the value of attribute f.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def f
  @f
end

#frObject

Returns the value of attribute fr.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def fr
  @fr
end

#idntObject

Returns the value of attribute idnt.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def idnt
  @idnt
end

#midObject

Returns the value of attribute mid.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def mid
  @mid
end

#recipientsObject (readonly)

Returns the value of attribute recipients.



13
14
15
# File 'lib/zm/client/message/message.rb', line 13

def recipients
  @recipients
end

#sObject Also known as: size

Returns the value of attribute s.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def s
  @s
end

#suObject

Returns the value of attribute su.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def su
  @su
end

#subjectObject

Returns the value of attribute subject.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def subject
  @subject
end

#tnObject

Returns the value of attribute tn.



12
13
14
# File 'lib/zm/client/message/message.rb', line 12

def tn
  @tn
end

Instance Method Details

#build_createObject

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/zm/client/message/message.rb', line 54

def build_create
  raise NotImplementedError
end

#build_modifyObject

Raises:

  • (NotImplementedError)


62
63
64
# File 'lib/zm/client/message/message.rb', line 62

def build_modify
  raise NotImplementedError
end

#build_rename(*args) ⇒ Object

Raises:

  • (NotImplementedError)


85
86
87
# File 'lib/zm/client/message/message.rb', line 85

def build_rename(*args)
  raise NotImplementedError
end

#build_sendObject



109
110
111
112
# File 'lib/zm/client/message/message.rb', line 109

def build_send
  SoapElement.mail(SoapMailConstants::SEND_MSG_REQUEST)
             .add_attributes(jsns_builder.to_jsns)
end

#build_spamObject



101
102
103
# File 'lib/zm/client/message/message.rb', line 101

def build_spam
  jsns_builder.to_spam
end

#build_unspamObject



93
94
95
# File 'lib/zm/client/message/message.rb', line 93

def build_unspam
  jsns_builder.to_unspam
end

#create!(*args) ⇒ Object

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/zm/client/message/message.rb', line 50

def create!(*args)
  raise NotImplementedError
end

#dateObject



38
39
40
41
42
# File 'lib/zm/client/message/message.rb', line 38

def date
  return @date if defined? @date

  @date = Time.at(d.to_i / 1000)
end

#download(dest_file_path, fmt: 'eml') ⇒ Object



28
29
30
31
# File 'lib/zm/client/message/message.rb', line 28

def download(dest_file_path, fmt: 'eml')
  uploader = @parent.build_uploader
  uploader.download_file(dest_file_path, id, FolderView::MESSAGE, fmt:)
end

#flagsObject



44
45
46
47
48
# File 'lib/zm/client/message/message.rb', line 44

def flags
  return @flags if defined? @flags

  @flags = FlagsCollection.new(self)
end

#jsns_builderObject



119
120
121
122
123
# File 'lib/zm/client/message/message.rb', line 119

def jsns_builder
  return @jsns_builder if defined? @jsns_builder

  @jsns_builder = MessageJsnsBuilder.new(self)
end

#modify!(*args) ⇒ Object

Raises:

  • (NotImplementedError)


58
59
60
# File 'lib/zm/client/message/message.rb', line 58

def modify!(*args)
  raise NotImplementedError
end

#readObject



33
34
35
36
# File 'lib/zm/client/message/message.rb', line 33

def read
  uploader = @parent.build_uploader
  uploader.read_file(id, FolderView::MESSAGE, fmt: 'eml')
end

#rename!(*args) ⇒ Object

Raises:

  • (NotImplementedError)


81
82
83
# File 'lib/zm/client/message/message.rb', line 81

def rename!(*args)
  raise NotImplementedError
end

#send!Object



105
106
107
# File 'lib/zm/client/message/message.rb', line 105

def send!
  @parent.soap_connector.invoke(build_send)
end

#spam!Object



97
98
99
# File 'lib/zm/client/message/message.rb', line 97

def spam!
  @parent.soap_connector.invoke(build_spam)
end

#unspam!Object



89
90
91
# File 'lib/zm/client/message/message.rb', line 89

def unspam!
  @parent.soap_connector.invoke(build_unspam)
end

#update!(attrs) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/zm/client/message/message.rb', line 66

def update!(attrs)
  authorized_keys = i[l rgb color f tn]

  attrs.reject! { |k| !authorized_keys.include?(k) }

  attrs.merge!({ op: :update, id: id })

  attrs.compact!

  soap_request = SoapElement.mail(SoapMailConstants::ITEM_ACTION_REQUEST)
  node_action = SoapElement.create(SoapConstants::ACTION).add_attributes(attrs)
  soap_request.add_node(node_action)
  @parent.soap_connector.invoke(soap_request)
end