Class: Zm::Client::Folder
- Inherits:
-
Base::Object
- Object
- Base::Object
- Zm::Client::Folder
- Includes:
- BelongsToFolder
- Defined in:
- lib/zm/client/folder/folder.rb
Overview
class for account folder
Instance Attribute Summary collapse
-
#absFolderPath ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#acl ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#activesyncdisabled ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#broken ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#color ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#deletable ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#f ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#fb ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#folders ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#grants ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#i4ms ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#i4next ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#id ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#itemCount ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#l ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#luuid ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#ms ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#n ⇒ Object
(also: #nb_messages, #nb_items)
include Zm::Model::AttributeChangeObserver.
-
#name ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#owner ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#reminder ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#retention_policies ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#rev ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#rgb ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#rid ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#ruuid ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#s ⇒ Object
(also: #size)
include Zm::Model::AttributeChangeObserver.
-
#type ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#url ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#uuid ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#view ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#webOfflineSyncDays ⇒ Object
include Zm::Model::AttributeChangeObserver.
-
#zid ⇒ Object
include Zm::Model::AttributeChangeObserver.
Attributes inherited from Base::Object
Instance Method Summary collapse
- #add_appointments(ics) ⇒ Object
- #add_message(eml, d = nil, f = nil, tn = nil) ⇒ Object
- #color! ⇒ Object
- #create! ⇒ Object
- #delete! ⇒ Object
- #download(dest_file_path, fmt = 'tgz') ⇒ Object
- #empty! ⇒ Object (also: #clear)
- #empty? ⇒ Boolean
-
#initialize(parent) {|_self| ... } ⇒ Folder
constructor
A new instance of Folder.
- #is_immutable? ⇒ Boolean
- #modify! ⇒ Object
- #reload! ⇒ Object
- #remove_flag!(pattern) ⇒ Object
- #rename!(new_name) ⇒ Object
- #to_query ⇒ Object
- #update!(hash) ⇒ Object
- #upload(file_path, fmt = nil, types = nil, resolve = 'replace') ⇒ Object
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.
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
#absFolderPath ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def absFolderPath @absFolderPath end |
#acl ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def acl @acl end |
#activesyncdisabled ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def activesyncdisabled @activesyncdisabled end |
#broken ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def broken @broken end |
#color ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def color @color end |
#deletable ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def deletable @deletable end |
#f ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def f @f end |
#fb ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def fb @fb end |
#folders ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def folders @folders end |
#grants ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def grants @grants end |
#i4ms ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def i4ms @i4ms end |
#i4next ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def i4next @i4next end |
#id ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def id @id end |
#itemCount ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def itemCount @itemCount end |
#l ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def l @l end |
#luuid ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def luuid @luuid end |
#ms ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def ms @ms end |
#n ⇒ Object 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 |
#name ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def name @name end |
#owner ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def owner @owner end |
#reminder ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def reminder @reminder end |
#retention_policies ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def retention_policies @retention_policies end |
#rev ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def rev @rev end |
#rgb ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def rgb @rgb end |
#rid ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def rid @rid end |
#ruuid ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def ruuid @ruuid end |
#s ⇒ Object Also known as: size
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def s @s end |
#type ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def type @type end |
#url ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def url @url end |
#uuid ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def uuid @uuid end |
#view ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def view @view end |
#webOfflineSyncDays ⇒ Object
include Zm::Model::AttributeChangeObserver
10 11 12 |
# File 'lib/zm/client/folder/folder.rb', line 10 def webOfflineSyncDays @webOfflineSyncDays end |
#zid ⇒ Object
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 (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
84 85 86 |
# File 'lib/zm/client/folder/folder.rb', line 84 def empty? @n.zero? end |
#is_immutable? ⇒ 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_query ⇒ Object
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 |