Class: Zm::Client::DistributionListJsnsInitializer
- Inherits:
-
Base::BaseJsnsInitializer
- Object
- Base::BaseJsnsInitializer
- Zm::Client::DistributionListJsnsInitializer
- Defined in:
- lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb
Overview
class for initialize distribution list
Class Method Summary collapse
Methods inherited from Base::BaseJsnsInitializer
convert_json_string_value, formatted_json, valorise
Class Method Details
.create(parent, json) ⇒ Object
8 9 10 11 12 |
# File 'lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb', line 8 def create(parent, json) item = DistributionList.new(parent) update(item, json) 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 36 |
# File 'lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb', line 14 def update(item, json) item.id = json[:id] item.name = json[:name] formatted_json(json).each do |k, v| valorise(item, k, v) end unless item.zimbraMailForwardingAddress.is_a?(Array) item.zimbraMailForwardingAddress = [item.zimbraMailForwardingAddress] item.zimbraMailForwardingAddress.compact! end if json[:dlm].is_a?(Array) item.members.all = json[:dlm].map { |a| a[:_content] }.compact elsif !item.zimbraMailForwardingAddress.empty? item.members.all = item.zimbraMailForwardingAddress end item.owners.all = json[:owners].first[:owner].map { |a| a[:name] }.compact if json[:owners].is_a?(Array) item end |