Class: Zm::Client::Base::AdminObject

Inherits:
Object
  • Object
show all
Defined in:
lib/zm/client/base/admin_object.rb

Overview

Abstract Class Provisionning AdminObject

Instance Attribute Summary

Attributes inherited from Object

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

Instance Method Summary collapse

Methods inherited from Object

#arrow_name, #clone, #concat, #convert_json_string_value, #disable_builder, #enable_builder, #initialize, #instance_variables_array, #instance_variables_hash, #logger, #recorded?, #save!, #to_s, #use_builder?

Constructor Details

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

Instance Method Details

#init_from_json(json) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/zm/client/base/admin_object.rb', line 29

def init_from_json(json)
  # TODO : know in advance the typing of variables
  super(json)
  return unless json[:a].is_a? Array

  # fix car le tableau peut contenir des {} vide !
  json[:a].reject! { |n| n[:n].nil? }
  json_map = json[:a].map { |n| ["@#{n[:n]}", n[:_content]] }.freeze

  json_hash = json_map.reduce({}) { |h, (k, v)| (h[k] ||= []); h[k].push(v); h }.inject({}) { |h, (k, v)| v.length == 1 ? h[k] = v.first : h[k] = v; h }

  json_hash.each do |k, v|
    instance_variable_set(k, convert_json_string_value(v))
  end

  # Hash[json_map].each do |k, v|
  #   instance_variable_set(k, convert_json_string_value(v))
  # end
end

#soap_account_connectorObject Also known as: sacc



17
18
19
# File 'lib/zm/client/base/admin_object.rb', line 17

def 
  @parent.
end

#soap_admin_connectorObject Also known as: sac



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

def soap_admin_connector
  @parent.soap_admin_connector
end

#to_hObject



23
24
25
26
27
# File 'lib/zm/client/base/admin_object.rb', line 23

def to_h
  hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
  hashmap.delete_if { |_, v| v.nil? }
  hashmap
end