Class: Zm::Client::Folder

Inherits:
Base::FolderObject show all
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

Attributes inherited from Base::Object

#grantee_type, #name, #parent, #token

Instance Method Summary collapse

Methods included from Model::AttributeChangeObserver

included

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.

Yields:

  • (_self)

Yield Parameters:



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

#absFolderPathObject

Returns the value of attribute absFolderPath.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def absFolderPath
  @absFolderPath
end

#aclObject (readonly)

Returns the value of attribute acl.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def acl
  @acl
end

#activesyncdisabledObject (readonly)

Returns the value of attribute activesyncdisabled.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def activesyncdisabled
  @activesyncdisabled
end

#brokenObject (readonly)

Returns the value of attribute broken.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def broken
  @broken
end

#deletableObject (readonly)

Returns the value of attribute deletable.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def deletable
  @deletable
end

#fbObject (readonly)

Returns the value of attribute fb.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def fb
  @fb
end

#foldersObject

Returns the value of attribute folders.



16
17
18
# File 'lib/zm/client/folder/folder.rb', line 16

def folders
  @folders
end

#grantsObject

Returns the value of attribute grants.



16
17
18
# File 'lib/zm/client/folder/folder.rb', line 16

def grants
  @grants
end

#i4msObject (readonly)

Returns the value of attribute i4ms.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def i4ms
  @i4ms
end

#i4nextObject (readonly)

Returns the value of attribute i4next.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def i4next
  @i4next
end

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def id
  @id
end

#itemCountObject (readonly)

Returns the value of attribute itemCount.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def itemCount
  @itemCount
end

#luuidObject (readonly)

Returns the value of attribute luuid.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def luuid
  @luuid
end

#msObject (readonly)

Returns the value of attribute ms.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def ms
  @ms
end

#nObject (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

#ownerObject (readonly)

Returns the value of attribute owner.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def owner
  @owner
end

#reminderObject (readonly)

Returns the value of attribute reminder.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def reminder
  @reminder
end

#retention_policiesObject

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

#revObject (readonly)

Returns the value of attribute rev.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def rev
  @rev
end

#ridObject (readonly)

Returns the value of attribute rid.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def rid
  @rid
end

#ruuidObject (readonly)

Returns the value of attribute ruuid.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def ruuid
  @ruuid
end

#sObject (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

#typeObject (readonly)

Returns the value of attribute type.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def type
  @type
end

#uuidObject (readonly)

Returns the value of attribute uuid.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def uuid
  @uuid
end

#webOfflineSyncDaysObject (readonly)

Returns the value of attribute webOfflineSyncDays.



13
14
15
# File 'lib/zm/client/folder/folder.rb', line 13

def webOfflineSyncDays
  @webOfflineSyncDays
end

#zidObject (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_keysObject



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

Returns:

  • (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

Returns:

  • (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)

options = 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: options)

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_queryObject



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!(options)
  options.delete_if { |k, v| v.nil? || !respond_to?(k) }
  return false if options.empty?

  @parent.sacc.folder_action(@parent.token, jsns_builder.to_patch(options))

  options.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