Class: Zm::Client::Folder
- Inherits:
-
Base::FolderObject
- Object
- Base::Object
- Base::AccountObject
- Base::FolderObject
- Zm::Client::Folder
- Includes:
- Model::AttributeChangeObserver
- Defined in:
- lib/zm/client/folder/folder.rb
Overview
class for account folder
Constant Summary collapse
- INSTANCE_VARIABLE_KEYS =
i[type id uuid name absFolderPath l url luuid f view rev ms webOfflineSyncDays activesyncdisabled n s i4ms i4next zid rid ruuid owner reminder acl itemCount broken deletable color rgb fb].freeze
Instance Attribute Summary collapse
-
#absFolderPath ⇒ Object
Returns the value of attribute absFolderPath.
-
#acl ⇒ Object
readonly
Returns the value of attribute acl.
-
#activesyncdisabled ⇒ Object
readonly
Returns the value of attribute activesyncdisabled.
-
#broken ⇒ Object
readonly
Returns the value of attribute broken.
-
#deletable ⇒ Object
readonly
Returns the value of attribute deletable.
-
#fb ⇒ Object
readonly
Returns the value of attribute fb.
-
#folders ⇒ Object
Returns the value of attribute folders.
-
#grants ⇒ Object
Returns the value of attribute grants.
-
#i4ms ⇒ Object
readonly
Returns the value of attribute i4ms.
-
#i4next ⇒ Object
readonly
Returns the value of attribute i4next.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#itemCount ⇒ Object
readonly
Returns the value of attribute itemCount.
-
#luuid ⇒ Object
readonly
Returns the value of attribute luuid.
-
#ms ⇒ Object
readonly
Returns the value of attribute ms.
-
#n ⇒ Object
(also: #nb_messages, #nb_items)
readonly
Returns the value of attribute n.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#reminder ⇒ Object
readonly
Returns the value of attribute reminder.
-
#retention_policies ⇒ Object
Returns the value of attribute retention_policies.
-
#rev ⇒ Object
readonly
Returns the value of attribute rev.
-
#rid ⇒ Object
readonly
Returns the value of attribute rid.
-
#ruuid ⇒ Object
readonly
Returns the value of attribute ruuid.
-
#s ⇒ Object
(also: #size)
readonly
Returns the value of attribute s.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
-
#webOfflineSyncDays ⇒ Object
readonly
Returns the value of attribute webOfflineSyncDays.
-
#zid ⇒ Object
readonly
Returns the value of attribute zid.
Attributes inherited from Base::Object
#grantee_type, #name, #parent, #token
Instance Method Summary collapse
- #all_instance_variable_keys ⇒ Object
- #create! ⇒ Object
- #delete! ⇒ Object
- #download(dest_file_path, fmt = 'tgz') ⇒ Object
- #empty! ⇒ Object (also: #clear)
- #empty? ⇒ Boolean
- #export(dest_file_path) ⇒ Object
- #import(file_path) ⇒ Object
-
#initialize(parent) {|_self| ... } ⇒ Folder
constructor
A new instance of Folder.
- #is_immutable? ⇒ Boolean
-
#reload! ⇒ Object
def add_retention_policy!(retention_policies) options = if retention_policies.is_a?(Hash) retention_policies else retention_policies.map(&:to_h).reduce({}, :merge) end.
- #to_query ⇒ Object
- #update!(options) ⇒ Object
- #upload(file_path, fmt = nil, types = nil, resolve = 'replace') ⇒ Object
Methods included from Model::AttributeChangeObserver
Methods inherited from Base::FolderObject
#color!, #modify!, #move!, #rename!
Methods inherited from Base::AccountObject
#concat, #init_from_json, #modify!, #rename!, #soap_account_connector, #to_h
Methods inherited from Base::Object
#arrow_name, #clone, #concat, #convert_json_string_value, #disable_builder, #enable_builder, #init_from_json, #instance_variables_array, #instance_variables_hash, #logger, #recorded?, #save!, #to_s, #use_builder?
Constructor Details
#initialize(parent) {|_self| ... } ⇒ Folder
Returns a new instance of Folder.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zm/client/folder/folder.rb', line 30 def initialize(parent) super(parent) @type = :folder @folders = [] @grants = FolderGrantsCollection.new(self) @retention_policies = FolderRetentionPoliciesCollection.new(self) yield(self) if block_given? extend(DocumentFolder) if view == 'document' end |
Instance Attribute Details
#absFolderPath ⇒ Object
Returns the value of attribute absFolderPath.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def absFolderPath @absFolderPath end |
#acl ⇒ Object (readonly)
Returns the value of attribute acl.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def acl @acl end |
#activesyncdisabled ⇒ Object (readonly)
Returns the value of attribute activesyncdisabled.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def activesyncdisabled @activesyncdisabled end |
#broken ⇒ Object (readonly)
Returns the value of attribute broken.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def broken @broken end |
#deletable ⇒ Object (readonly)
Returns the value of attribute deletable.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def deletable @deletable end |
#fb ⇒ Object (readonly)
Returns the value of attribute fb.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def fb @fb end |
#folders ⇒ Object
Returns the value of attribute folders.
16 17 18 |
# File 'lib/zm/client/folder/folder.rb', line 16 def folders @folders end |
#grants ⇒ Object
Returns the value of attribute grants.
16 17 18 |
# File 'lib/zm/client/folder/folder.rb', line 16 def grants @grants end |
#i4ms ⇒ Object (readonly)
Returns the value of attribute i4ms.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def i4ms @i4ms end |
#i4next ⇒ Object (readonly)
Returns the value of attribute i4next.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def i4next @i4next end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def id @id end |
#itemCount ⇒ Object (readonly)
Returns the value of attribute itemCount.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def itemCount @itemCount end |
#luuid ⇒ Object (readonly)
Returns the value of attribute luuid.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def luuid @luuid end |
#ms ⇒ Object (readonly)
Returns the value of attribute ms.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def ms @ms end |
#n ⇒ Object (readonly) Also known as: nb_messages, nb_items
Returns the value of attribute n.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def n @n end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def owner @owner end |
#reminder ⇒ Object (readonly)
Returns the value of attribute reminder.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def reminder @reminder end |
#retention_policies ⇒ Object
Returns the value of attribute retention_policies.
16 17 18 |
# File 'lib/zm/client/folder/folder.rb', line 16 def retention_policies @retention_policies end |
#rev ⇒ Object (readonly)
Returns the value of attribute rev.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def rev @rev end |
#rid ⇒ Object (readonly)
Returns the value of attribute rid.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def rid @rid end |
#ruuid ⇒ Object (readonly)
Returns the value of attribute ruuid.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def ruuid @ruuid end |
#s ⇒ Object (readonly) Also known as: size
Returns the value of attribute s.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def s @s end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def type @type end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def uuid @uuid end |
#webOfflineSyncDays ⇒ Object (readonly)
Returns the value of attribute webOfflineSyncDays.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def webOfflineSyncDays @webOfflineSyncDays end |
#zid ⇒ Object (readonly)
Returns the value of attribute zid.
13 14 15 |
# File 'lib/zm/client/folder/folder.rb', line 13 def zid @zid end |
Instance Method Details
#all_instance_variable_keys ⇒ Object
21 22 23 |
# File 'lib/zm/client/folder/folder.rb', line 21 def all_instance_variable_keys INSTANCE_VARIABLE_KEYS end |
#create! ⇒ Object
51 52 53 54 55 |
# File 'lib/zm/client/folder/folder.rb', line 51 def create! rep = @parent.sacc.create_folder(@parent.token, jsns_builder.to_jsns) json = rep[:Body][:CreateFolderResponse][:folder].first FolderJsnsInitializer.update(self, json) end |
#delete! ⇒ Object
97 98 99 100 101 |
# File 'lib/zm/client/folder/folder.rb', line 97 def delete! return false if is_immutable? super end |
#download(dest_file_path, fmt = 'tgz') ⇒ Object
114 115 116 117 118 |
# File 'lib/zm/client/folder/folder.rb', line 114 def download(dest_file_path, fmt = 'tgz') uploader = Upload.new(@parent, RestAccountConnector.new) # uploader.download_file(absFolderPath, fmt, [view], nil, dest_file_path) uploader.download_folder(@id, fmt, dest_file_path) end |
#empty! ⇒ Object Also known as: clear
91 92 93 94 |
# File 'lib/zm/client/folder/folder.rb', line 91 def empty! @parent.sacc.folder_action(@parent.token, jsns_builder.to_empty) unless @n.zero? @n = 0 end |
#empty? ⇒ Boolean
87 88 89 |
# File 'lib/zm/client/folder/folder.rb', line 87 def empty? @n.zero? end |
#export(dest_file_path) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/zm/client/folder/folder.rb', line 120 def export(dest_file_path) h = { fmt: 'tgz', emptyname: 'Vide', charset: 'UTF-8', auth: 'qp', zauthtoken: @parent.token, query: to_query } url_query = absFolderPath + '?' + h.map { |k, v| [k, v].join('=') }.join('&') @parent.uploader.download_file_with_url(url_query, dest_file_path) end |
#import(file_path) ⇒ Object
109 110 111 112 |
# File 'lib/zm/client/folder/folder.rb', line 109 def import(file_path) uploader = Upload.new(@parent, RestAccountConnector.new) uploader.send_file(absFolderPath, 'tgz', nil, 'skip', file_path) end |
#is_immutable? ⇒ Boolean
43 44 45 |
# File 'lib/zm/client/folder/folder.rb', line 43 def is_immutable? @is_immutable ||= Zm::Client::FolderDefault::IDS.include?(@id.to_i) end |
#reload! ⇒ Object
def add_retention_policy!(retention_policies)
= if retention_policies.is_a?(Hash)
retention_policies
else
retention_policies.map(&:to_h).reduce({}, :merge)
end
@parent.sacc.folder_action(@parent.token, 'retentionPolicy', @id, retentionPolicy: )
end
80 81 82 83 84 85 |
# File 'lib/zm/client/folder/folder.rb', line 80 def reload! rep = @parent.sacc.get_folder(@parent.token, jsns_builder.to_find) json = rep[:Body][:GetFolderResponse][:folder].first FolderJsnsInitializer.update(self, json) true end |
#to_query ⇒ Object
47 48 49 |
# File 'lib/zm/client/folder/folder.rb', line 47 def to_query "inid:#{id}" end |
#update!(options) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/zm/client/folder/folder.rb', line 57 def update!() .delete_if { |k, v| v.nil? || !respond_to?(k) } return false if .empty? @parent.sacc.folder_action(@parent.token, jsns_builder.to_patch()) .each do |k, v| instance_variable_set("@#{k}", v) end true end |
#upload(file_path, fmt = nil, types = nil, resolve = 'replace') ⇒ Object
103 104 105 106 107 |
# File 'lib/zm/client/folder/folder.rb', line 103 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 |