Class: Zm::Client::GroupContactJsnsBuilder

Inherits:
BaseAccountJsnsBuilder show all
Defined in:
lib/zm/client/contact/group_contact_jsns_builder.rb

Overview

class for account contact jsns builder

Constant Summary collapse

EXCLUDE_INSTANCE_VARIABLE_KEYS =
i[@id @name @parent @l @type @tn @jsns_builder].freeze

Instance Method Summary collapse

Methods inherited from BaseAccountJsnsBuilder

#build, #initialize, #to_color, #to_delete, #to_move, #to_rename, #to_tag, #to_trash

Constructor Details

This class inherits a constructor from Zm::Client::BaseAccountJsnsBuilder

Instance Method Details

#instance_variables_arrayObject



50
51
52
# File 'lib/zm/client/contact/group_contact_jsns_builder.rb', line 50

def instance_variables_array
  [[:nickname, @item.name], [:fullName, @item.name], [:fileAs, "8:#{@item.name}"], i[type group]]
end

#to_jsnsObject Also known as: to_create



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/zm/client/contact/group_contact_jsns_builder.rb', line 9

def to_jsns
  jsns = {
    cn: {
      a: instance_variables_array.map(&Utils::A_NODE_PROC),
      l: @item.folder_id || Zm::Client::FolderDefault::CONTACTS[:id],
      m: @item.members.all.map do |m|
        { type: m.type, value: m.value }
      end
    }
  }

  SoapElement.mail(SoapMailConstants::CREATE_CONTACT_REQUEST).add_attributes(jsns)
end

#to_patch(hash) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/zm/client/contact/group_contact_jsns_builder.rb', line 37

def to_patch(hash)
  jsns = {
    cn: {
      id: @item.id,
      a: hash.map(&Utils::A_ARRAY_PROC).flatten(1).map(&Utils::A_NODE_PROC)
    }
  }

  SoapElement.mail(SoapMailConstants::MODIFY_CONTACT_REQUEST).add_attributes(jsns)
end

#to_updateObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/zm/client/contact/group_contact_jsns_builder.rb', line 23

def to_update
  jsns = {
    cn: {
      a: instance_variables_array.map(&Utils::A_NODE_PROC),
      id: @item.id,
      m: @item.members.all.reject(&:current?).map do |m|
        { type: m.type, value: m.value, op: m.op }
      end
    }
  }

  SoapElement.mail(SoapMailConstants::MODIFY_CONTACT_REQUEST).add_attributes(jsns)
end