Class: Zm::Client::MessageJsnsInitializer
- Inherits:
-
Object
- Object
- Zm::Client::MessageJsnsInitializer
- Defined in:
- lib/zm/client/message/message_jsns_initializer.rb
Overview
class for initialize account message
Class Method Summary collapse
- .create(parent, json) ⇒ Object
- .update(item, json) ⇒ Object
- .update_attachment(item, json) ⇒ Object
- .update_body(item, json) ⇒ Object
- .update_mps(item, mps) ⇒ Object
Class Method Details
.create(parent, json) ⇒ Object
8 9 10 11 12 |
# File 'lib/zm/client/message/message_jsns_initializer.rb', line 8 def create(parent, json) Message.new(parent).tap do |item| update(item, json) end end |
.update(item, json) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/zm/client/message/message_jsns_initializer.rb', line 14 def update(item, json) item.id = json.delete(:id) item.d = json.delete(:d) item.l = json.delete(:l) item.su = json.delete(:su) item.fr = json.delete(:fr) item.autoSendTime = json.delete(:autoSendTime) item.mid = json.delete(:mid) item.idnt = json.delete(:idnt) item.f = json.delete(:f) item.tn = json.delete(:tn) item.s = json.delete(:s) json[:e].each do |e| recipient = Recipient.new(e.delete(:t), e.delete(:a), e.delete(:p)) item.recipients.add(recipient) end update_mps(item, json.delete(:mp)) item end |
.update_attachment(item, json) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/zm/client/message/message_jsns_initializer.rb', line 58 def (item, json) pj = Zm::Client::Message::Attachment.new(self) pj.mid = json.delete(:mid) pj.aid = json.delete(:aid) pj.ct = json.delete(:ct) pj.s = json.delete(:s) pj.filename = json.delete(:filename) pj.ci = json.delete(:ci) pj.cd = json.delete(:cd) pj.part = json.delete(:part) item..add(pj) end |
.update_body(item, json) ⇒ Object
53 54 55 56 |
# File 'lib/zm/client/message/message_jsns_initializer.rb', line 53 def update_body(item, json) item.body.text = json[:content] if json[:ct] == ContentType::TEXT item.body.html = json[:content] if json[:ct] == ContentType::HTML end |
.update_mps(item, mps) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/zm/client/message/message_jsns_initializer.rb', line 37 def update_mps(item, mps) return if mps.nil? mps = [mps] unless mps.is_a?(Array) mps.each do |mp| if ContentType::ALL.include?(mp[:ct]) update_body(item, mp) elsif mp[:cd] == 'attachment' (item, mp) else update_mps(item, mp[:mp]) end end end |