Class: Zm::Client::Folder

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

Overview

class for account folder

Instance Attribute Summary collapse

Attributes inherited from Base::Object

#id, #parent, #token

Instance Method Summary collapse

Methods included from MailboxItemConcern

#id, #id=, #mailbox_id

Methods included from RequestMethodsMailbox

#build_create, #build_delete, #build_modify, #build_rename, #modify!, #rename!, #update!

Methods included from BelongsToFolder

#folder, #folder!, #folder=, #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:



19
20
21
22
23
24
25
26
# File 'lib/zm/client/folder/folder.rb', line 19

def initialize(parent)
  super

  @type = :folder
  @folders = []

  yield(self) if block_given?
end

Instance Attribute Details

#absFolderPathObject

Returns the value of attribute absFolderPath.



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

def absFolderPath
  @absFolderPath
end

#aclObject

Returns the value of attribute acl.



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

def acl
  @acl
end

#activesyncdisabledObject

Returns the value of attribute activesyncdisabled.



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

def activesyncdisabled
  @activesyncdisabled
end

#brokenObject

Returns the value of attribute broken.



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

def broken
  @broken
end

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#deletableObject

Returns the value of attribute deletable.



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

def deletable
  @deletable
end

#fObject

Returns the value of attribute f.



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

def f
  @f
end

#fbObject

Returns the value of attribute fb.



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

def fb
  @fb
end

#foldersObject

Returns the value of attribute folders.



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

def folders
  @folders
end

#i4msObject

Returns the value of attribute i4ms.



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

def i4ms
  @i4ms
end

#i4nextObject

Returns the value of attribute i4next.



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

def i4next
  @i4next
end

#itemCountObject

Returns the value of attribute itemCount.



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

def itemCount
  @itemCount
end

#luuidObject

Returns the value of attribute luuid.



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

def luuid
  @luuid
end

#msObject

Returns the value of attribute ms.



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

def ms
  @ms
end

#nObject Also known as: nb_messages, nb_items

Returns the value of attribute n.



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

def n
  @n
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#ownerObject

Returns the value of attribute owner.



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

def owner
  @owner
end

#reminderObject

Returns the value of attribute reminder.



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

def reminder
  @reminder
end

#revObject

Returns the value of attribute rev.



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

def rev
  @rev
end

#rgbObject

Returns the value of attribute rgb.



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

def rgb
  @rgb
end

#ridObject

Returns the value of attribute rid.



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

def rid
  @rid
end

#ruuidObject

Returns the value of attribute ruuid.



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

def ruuid
  @ruuid
end

#sObject Also known as: size

Returns the value of attribute s.



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

def s
  @s
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#uuidObject

Returns the value of attribute uuid.



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

def uuid
  @uuid
end

#viewObject

Returns the value of attribute view.



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

def view
  @view
end

#webOfflineSyncDaysObject

Returns the value of attribute webOfflineSyncDays.



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

def webOfflineSyncDays
  @webOfflineSyncDays
end

#zidObject

Returns the value of attribute zid.



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

def zid
  @zid
end

Instance Method Details

#add_appointments(ics) ⇒ Object



127
128
129
# File 'lib/zm/client/folder/folder.rb', line 127

def add_appointments(ics)
  @parent.soap_connector.invoke(build_add_appointments(ics)).dig(:ImportAppointmentsResponse, :appt)
end

#add_contacts(csv) ⇒ Object



139
140
141
# File 'lib/zm/client/folder/folder.rb', line 139

def add_contacts(csv)
  @parent.soap_connector.invoke(build_add_contacts(csv)).dig(:ImportContactsResponse, :cn)
end

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



107
108
109
# File 'lib/zm/client/folder/folder.rb', line 107

def add_message(eml, d = nil, f = nil, tn = nil)
  @parent.soap_connector.invoke(build_add_message(eml, d, f, tn))
end

#build_add_appointments(ics) ⇒ Object



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

def build_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)
  soap_request
end

#build_add_contacts(csv) ⇒ Object



143
144
145
146
147
148
149
# File 'lib/zm/client/folder/folder.rb', line 143

def build_add_contacts(csv)
  attrs = { l: id, ct: SoapConstants::CSV }
  soap_request = SoapElement.mail(SoapMailConstants::IMPORT_CONTACTS_REQUEST).add_attributes(attrs)
  node_content = SoapElement.create(SoapConstants::CONTENT).add_content(csv)
  soap_request.add_node(node_content)
  soap_request
end

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



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/zm/client/folder/folder.rb', line 111

def build_add_message(eml, d = nil, f = nil, tn = nil)
  m = {
    l: id,
    d: d,
    f: f,
    tn: tn,
    content: { _content: eml }
  }
  m.compact!

  attrs = { m: m }

  SoapElement.mail(SoapMailConstants::ADD_MSG_REQUEST)
             .add_attributes(attrs)
end

#build_colorObject



69
70
71
# File 'lib/zm/client/folder/folder.rb', line 69

def build_color
  jsns_builder.to_color
end

#build_emptyObject



92
93
94
# File 'lib/zm/client/folder/folder.rb', line 92

def build_empty
  jsns_builder.to_empty
end

#color!Object



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

def color!
  @parent.soap_connector.invoke(build_color)
  true
end

#create!Object



57
58
59
60
61
62
# File 'lib/zm/client/folder/folder.rb', line 57

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

#delete!Object



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

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

  @parent.soap_connector.invoke(build_delete)
end

#download(dest_file_path, fmt: nil) ⇒ Object



151
152
153
154
# File 'lib/zm/client/folder/folder.rb', line 151

def download(dest_file_path, fmt: nil)
  uploader = @parent.build_uploader
  uploader.download_folder(dest_file_path, id, fmt:)
end

#empty!Object Also known as: clear



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

def empty!
  return false if empty?

  @parent.soap_connector.invoke(build_empty)
  @n = 0
end

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  @n.zero?
end

#grantsObject



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

def grants
  return @grants if defined? @grants

  @grants = FolderGrantsCollection.new(self)
end

#is_immutable?Boolean

Returns:

  • (Boolean)


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

def is_immutable?
  return @is_immutable if defined? @is_immutable

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

#lObject Also known as: folder_id



28
29
30
31
32
# File 'lib/zm/client/folder/folder.rb', line 28

def l
  return @l if defined? @l

  FolderDefault::ROOT.id
end

#reload!Object



73
74
75
76
77
78
# File 'lib/zm/client/folder/folder.rb', line 73

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

#remove_flag!(pattern) ⇒ Object



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

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

#retention_policiesObject



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

def retention_policies
  return @retention_policies if defined? @retention_policies

  @retention_policies = FolderRetentionPoliciesCollection.new(self)
end

#to_queryObject



53
54
55
# File 'lib/zm/client/folder/folder.rb', line 53

def to_query
  "inid:#{id}"
end

#upload(src_file_path, fmt: nil, resolve: nil) ⇒ Object



156
157
158
159
# File 'lib/zm/client/folder/folder.rb', line 156

def upload(src_file_path, fmt: nil, resolve: nil)
  uploader = @parent.build_uploader
  uploader.send_file(src_file_path, id, fmt:, type: view, resolve:)
end