Class: Zm::Client::Folder

Inherits:
Base::Object show all
Includes:
BelongsToFolder
Defined in:
lib/zm/client/folder/folder.rb

Overview

class for account folder

Instance Attribute Summary collapse

Attributes inherited from Base::Object

#parent, #token

Instance Method Summary collapse

Methods included from BelongsToFolder

#folder, #folder!, #folder=, #folder_id, #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| ... } ⇒ Folder

Returns a new instance of Folder.

Yields:

  • (_self)

Yield Parameters:



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/zm/client/folder/folder.rb', line 20

def initialize(parent)
  super(parent)

  @l = FolderDefault::ROOT[:id]
  @type = :folder
  @folders = []
  @grants = FolderGrantsCollection.new(self)
  @retention_policies = FolderRetentionPoliciesCollection.new(self)

  yield(self) if block_given?
end

Instance Attribute Details

#absFolderPathObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def absFolderPath
  @absFolderPath
end

#aclObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def acl
  @acl
end

#activesyncdisabledObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def activesyncdisabled
  @activesyncdisabled
end

#brokenObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def broken
  @broken
end

#colorObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def color
  @color
end

#deletableObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def deletable
  @deletable
end

#fObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def f
  @f
end

#fbObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def fb
  @fb
end

#foldersObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def folders
  @folders
end

#grantsObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def grants
  @grants
end

#i4msObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def i4ms
  @i4ms
end

#i4nextObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def i4next
  @i4next
end

#idObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def id
  @id
end

#itemCountObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def itemCount
  @itemCount
end

#lObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def l
  @l
end

#luuidObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def luuid
  @luuid
end

#msObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def ms
  @ms
end

#nObject Also known as: nb_messages, nb_items

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def n
  @n
end

#nameObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def name
  @name
end

#ownerObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def owner
  @owner
end

#reminderObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def reminder
  @reminder
end

#retention_policiesObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def retention_policies
  @retention_policies
end

#revObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def rev
  @rev
end

#rgbObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def rgb
  @rgb
end

#ridObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def rid
  @rid
end

#ruuidObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def ruuid
  @ruuid
end

#sObject Also known as: size

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def s
  @s
end

#typeObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def type
  @type
end

#urlObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def url
  @url
end

#uuidObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def uuid
  @uuid
end

#viewObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def view
  @view
end

#webOfflineSyncDaysObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def webOfflineSyncDays
  @webOfflineSyncDays
end

#zidObject

include Zm::Model::AttributeChangeObserver



10
11
12
# File 'lib/zm/client/folder/folder.rb', line 10

def zid
  @zid
end

Instance Method Details

#add_appointments(ics) ⇒ Object



123
124
125
126
127
128
129
# File 'lib/zm/client/folder/folder.rb', line 123

def add_appointments(ics)
  attrs = { l: id, ct: SoapConstants::TEXT_CALENDAR }
  soap_request = SoapElement.mail(SoapMailConstants::IMPORT_APPOINTMENTS_REQUEST).add_attributes(attrs)
  node_content = SoapElement.create(SoapConstants::CONTENT).add_content(ics)
  soap_request.add_node(node_content)
  @parent.sacc.invoke(soap_request).dig(:ImportAppointmentsResponse, :appt)
end

#add_message(eml, d = nil, f = nil, tn = nil) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/zm/client/folder/folder.rb', line 108

def add_message(eml, d = nil, f = nil, tn = nil)
  m = {
    l: id,
    d: d,
    f: f,
    tn: tn,
    content: { _content: eml }
  }.reject { |_, v| v.nil? }

  attrs = { m: m }

  soap_request = SoapElement.mail(SoapMailConstants::ADD_MSG_REQUEST).add_attributes(attrs)
  @parent.sacc.invoke(soap_request)
end

#color!Object



64
65
66
67
68
# File 'lib/zm/client/folder/folder.rb', line 64

def color!
  @parent.sacc.invoke(jsns_builder.to_color)

  true
end

#create!Object



40
41
42
43
44
45
# File 'lib/zm/client/folder/folder.rb', line 40

def create!
  rep = @parent.sacc.invoke(jsns_builder.to_jsns)
  json = rep[:CreateFolderResponse][:folder].first
  FolderJsnsInitializer.update(self, json)
  @id
end

#delete!Object



96
97
98
99
100
101
# File 'lib/zm/client/folder/folder.rb', line 96

def delete!
  return false if is_immutable? || @id.nil?

  @parent.sacc.invoke(jsns_builder.to_delete)
  @id = nil
end

#download(dest_file_path, fmt = 'tgz') ⇒ Object



131
132
133
134
# File 'lib/zm/client/folder/folder.rb', line 131

def download(dest_file_path, fmt = 'tgz')
  uploader = Upload.new(@parent, RestAccountConnector.new)
  uploader.download_folder(@id, fmt, dest_file_path)
end

#empty!Object Also known as: clear



88
89
90
91
92
93
# File 'lib/zm/client/folder/folder.rb', line 88

def empty!
  return false if empty?

  @parent.sacc.invoke(jsns_builder.to_empty)
  @n = 0
end

#empty?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/zm/client/folder/folder.rb', line 84

def empty?
  @n.zero?
end

#is_immutable?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/zm/client/folder/folder.rb', line 32

def is_immutable?
  @is_immutable ||= Zm::Client::FolderDefault::IDS.include?(@id.to_i)
end

#modify!Object



47
48
49
50
# File 'lib/zm/client/folder/folder.rb', line 47

def modify!
  @parent.sacc.invoke(jsns_builder.to_update)
  true
end

#reload!Object



77
78
79
80
81
82
# File 'lib/zm/client/folder/folder.rb', line 77

def reload!
  rep = @parent.sacc.invoke(jsns_builder.to_find)
  json = rep[:GetFolderResponse][:folder].first
  FolderJsnsInitializer.update(self, json)
  true
end

#remove_flag!(pattern) ⇒ Object



103
104
105
106
# File 'lib/zm/client/folder/folder.rb', line 103

def remove_flag!(pattern)
  flags = f.tr(pattern, '')
  update!(f: flags)
end

#rename!(new_name) ⇒ Object



70
71
72
73
74
75
# File 'lib/zm/client/folder/folder.rb', line 70

def rename!(new_name)
  return false if new_name == @name

  @parent.sacc.invoke(jsns_builder.to_rename(new_name))
  @name = new_name
end

#to_queryObject



36
37
38
# File 'lib/zm/client/folder/folder.rb', line 36

def to_query
  "inid:#{id}"
end

#update!(hash) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/zm/client/folder/folder.rb', line 52

def update!(hash)
  return false if hash.delete_if { |k, v| v.nil? || !respond_to?(k) }.empty?

  do_update!(hash)

  hash.each do |key, value|
    update_attribute(key, value)
  end

  true
end

#upload(file_path, fmt = nil, types = nil, resolve = 'replace') ⇒ Object



136
137
138
139
140
# File 'lib/zm/client/folder/folder.rb', line 136

def upload(file_path, fmt = nil, types = nil, resolve = 'replace')
  fmt ||= File.extname(file_path)[1..]
  uploader = Upload.new(@parent, RestAccountConnector.new)
  uploader.send_file(absFolderPath, fmt, types, resolve, file_path)
end