Class: Zm::Client::FolderJsnsInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/zm/client/folder/folder_jsns_initializer.rb

Overview

class for initialize account folder

Class Method Summary collapse

Class Method Details

.create(parent, json) ⇒ Object



8
9
10
11
# File 'lib/zm/client/folder/folder_jsns_initializer.rb', line 8

def create(parent, json)
  item = Folder.new(parent)
  update(item, json)
end

.update(item, json) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/zm/client/folder/folder_jsns_initializer.rb', line 13

def update(item, json)
  item.type = json[:type]
  item.id = json[:id].to_i
  item.uuid = json[:uuid]
  item.name = json[:name]
  item.absFolderPath = json[:absFolderPath]
  item.l = json[:l].to_i
  item.url = json[:url]
  item.luuid = json[:luuid]
  item.f = json[:f]
  item.view = json[:view]
  item.rev = json[:rev]
  item.ms = json[:ms]
  item.webOfflineSyncDays = json[:webOfflineSyncDays]
  item.activesyncdisabled = json[:activesyncdisabled]
  item.n = json[:n]
  item.s = json[:s]
  item.i4ms = json[:i4ms]
  item.i4next = json[:i4next]
  item.zid = json[:zid]
  item.rid = json[:rid]
  item.ruuid = json[:ruuid]
  item.owner = json[:owner]
  item.reminder = json[:reminder]
  item.acl = json[:acl]
  item.itemCount = json[:itemCount]
  item.broken = json[:broken]
  item.deletable = json[:deletable]
  item.color = json[:color]
  item.rgb = json[:rgb]
  item.fb = json[:fb]

  if !json[:acl].nil? && json[:acl][:grant].is_a?(Array)
    json[:acl][:grant].each do |json|
      item.grants.create(json[:zid], json[:gt], json[:perm], json[:d])
    end
  end

  if json[:retentionPolicy].is_a?(Array)
    json[:retentionPolicy].first.map do |policy, v|
      next if v.first[:policy].nil?

      type = v.first[:policy].first[:type]
      lifetime = v.first[:policy].first[:lifetime]
      item.retention_policies.create(policy, lifetime, type)
    end
  end

  item.extend(DocumentFolder) if item.view == Zm::Client::FolderView::DOCUMENT

  item
end