Class: Zm::Client::Message
Overview
class message for account
Defined Under Namespace
Classes: Attachment, Attachments, Body, Recipient, Recipients
Constant Summary
collapse
- INSTANCE_VARIABLE_KEYS =
i[id date l su fr]
Instance Attribute Summary collapse
Attributes inherited from Base::Object
#grantee_type, #id, #name, #parent, #token
Instance Method Summary
collapse
#soap_account_connector
#arrow_name, #clone, #concat, #convert_json_string_value, #instance_variables_array, #instance_variables_hash, #recorded?, #save!, #to_s
Constructor Details
#initialize(parent, json = nil) {|_self| ... } ⇒ Message
Returns a new instance of Message.
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/zm/client/message/message.rb', line 13
def initialize(parent, json = nil)
@parent = parent
@recipients = Recipients.new
@subject = ''
@body = Body.new
@attachments = Attachments.new
init_from_json(json) if json.is_a?(Hash)
yield(self) if block_given?
end
|
Instance Attribute Details
#attachments ⇒ Object
Returns the value of attribute attachments.
11
12
13
|
# File 'lib/zm/client/message/message.rb', line 11
def attachments
@attachments
end
|
#body ⇒ Object
Returns the value of attribute body.
11
12
13
|
# File 'lib/zm/client/message/message.rb', line 11
def body
@body
end
|
#folder ⇒ Object
Returns the value of attribute folder.
11
12
13
|
# File 'lib/zm/client/message/message.rb', line 11
def folder
@folder
end
|
#recipients ⇒ Object
Returns the value of attribute recipients.
11
12
13
|
# File 'lib/zm/client/message/message.rb', line 11
def recipients
@recipients
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
|
Instance Method Details
#delete! ⇒ Object
43
44
45
|
# File 'lib/zm/client/message/message.rb', line 43
def delete!
msg_action('delete')
end
|
#flag! ⇒ Object
64
65
66
|
# File 'lib/zm/client/message/message.rb', line 64
def flag!
msg_action('flag')
end
|
#from ⇒ Object
25
26
27
|
# File 'lib/zm/client/message/message.rb', line 25
def from
@from ||= @recipients.find { |r| r.field == Recipient::FROM }
end
|
#init_from_json(json) ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/zm/client/message/message.rb', line 92
def init_from_json(json)
@id = json[:id]
@date = Time.at(json[:d]/1000)
@l = json[:l]
@su = json[:su]
@fr = json[:fr]
json[:e].each do |e|
recipient = Recipient.new(e[:t], e[:a], e[:p])
@recipients.add(recipient)
end
end
|
#move!(folder_id = l) ⇒ Object
47
48
49
50
|
# File 'lib/zm/client/message/message.rb', line 47
def move!(folder_id = l)
msg_action('move', l: folder_id)
l = folder_id if l != folder_id
end
|
#msg_action(action_name, options = {}) ⇒ Object
106
107
108
109
|
# File 'lib/zm/client/message/message.rb', line 106
def msg_action(action_name, options = {})
@parent.sacc.msg_action(@parent.token, action_name, id, options)
true
end
|
#read! ⇒ Object
56
57
58
|
# File 'lib/zm/client/message/message.rb', line 56
def read!
msg_action('read')
end
|
#send! ⇒ Object
88
89
90
|
# File 'lib/zm/client/message/message.rb', line 88
def send!
@parent.sacc.send_msg(@parent.token, to_jsns)
end
|
#spam! ⇒ Object
80
81
82
|
# File 'lib/zm/client/message/message.rb', line 80
def spam!
msg_action('spam')
end
|
#tag!(tag_name) ⇒ Object
72
73
74
|
# File 'lib/zm/client/message/message.rb', line 72
def tag!(tag_name)
msg_action('tag', tn: tag_name)
end
|
#to_jsns ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/zm/client/message/message.rb', line 34
def to_jsns
{
attach: @attachments.to_jsns,
e: @recipients.to_jsns,
su: { _content: @subject },
mp: @body.to_jsns
}
end
|
#trash! ⇒ Object
84
85
86
|
# File 'lib/zm/client/message/message.rb', line 84
def trash!
msg_action('trash')
end
|
#unflag! ⇒ Object
60
61
62
|
# File 'lib/zm/client/message/message.rb', line 60
def unflag!
msg_action('!flag')
end
|
#unread! ⇒ Object
52
53
54
|
# File 'lib/zm/client/message/message.rb', line 52
def unread!
msg_action('!read')
end
|
#unspam! ⇒ Object
76
77
78
|
# File 'lib/zm/client/message/message.rb', line 76
def unspam!
msg_action('!spam')
end
|
#untag!(tag_name) ⇒ Object
68
69
70
|
# File 'lib/zm/client/message/message.rb', line 68
def untag!(tag_name)
msg_action('!tag', tn: tag_name)
end
|