Class: Zm::Client::SearchFolder

Inherits:
Base::AccountObject show all
Defined in:
lib/zm/client/search_folder/search_folder.rb

Overview

class account SearchFolder

Constant Summary collapse

INSTANCE_VARIABLE_KEYS =
i[id uuid deletable name absFolderPath l luuid color rgb rev ms webOfflineSyncDays activesyncdisabled query sortBy types]

Instance Attribute Summary

Attributes inherited from Base::Object

#grantee_type, #id, #name, #parent, #token

Instance Method Summary collapse

Methods inherited from Base::AccountObject

#soap_account_connector

Methods inherited from Base::Object

#arrow_name, #clone, #convert_json_string_value, #initialize, #instance_variables_array, #instance_variables_hash, #recorded?, #save!, #to_s

Constructor Details

This class inherits a constructor from Zm::Client::Base::Object

Instance Method Details

#build_update_optionsObject



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

def build_update_options
  {
    name: @name,
    color: @color,
    rgb: @rgb
  }.delete_if { |_, v| v.nil? }
end

#color!(new_color) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/zm/client/search_folder/search_folder.rb', line 38

def color!(new_color)
  key = new_color.to_i.zero? ? :rgb : :color
  options = {}
  options[key] = new_color
  @parent.sacc.folder_action(@parent.token, :color, @id, options)
  instance_variable_set("@#{key}", new_color)
end

#concatObject



12
13
14
# File 'lib/zm/client/search_folder/search_folder.rb', line 12

def concat
  INSTANCE_VARIABLE_KEYS.map { |key| instance_variable_get(arrow_name(key)) }
end

#create!Object



23
24
25
26
# File 'lib/zm/client/search_folder/search_folder.rb', line 23

def create!
  rep = @parent.sacc.create_search_folder(@parent.token, name, query, types, l, color, sortBy)
  init_from_json(rep[:Body][:CreateSearchFolderResponse][:search].first)
end

#delete!Object



54
55
56
# File 'lib/zm/client/search_folder/search_folder.rb', line 54

def delete!
  @parent.sacc.folder_action(@parent.token, :delete, id)
end

#init_from_json(json) ⇒ Object



16
17
18
19
20
21
# File 'lib/zm/client/search_folder/search_folder.rb', line 16

def init_from_json(json)
  INSTANCE_VARIABLE_KEYS.each do |key|
    var_name = "@#{key}"
    instance_variable_set(var_name, json[key])
  end
end

#modify!Object



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

def modify!
  @parent.sacc.modify_search_folder(@parent.token, id, query, types)
  @parent.sacc.folder_action(@parent.token, :update, id, build_update_options)
end

#query!(new_query) ⇒ Object



33
34
35
36
# File 'lib/zm/client/search_folder/search_folder.rb', line 33

def query!(new_query)
  @parent.sacc.modify_search_folder(@parent.token, id, new_query, types)
  instance_variable_set("@query", new_query)
end

#rename!(new_name) ⇒ Object



58
59
60
# File 'lib/zm/client/search_folder/search_folder.rb', line 58

def rename!(new_name)
  # todo
end