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



52
53
54
# File 'lib/zm/client/contact/group_contact_jsns_builder.rb', line 52

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

#members_nodeObject



46
47
48
49
50
# File 'lib/zm/client/contact/group_contact_jsns_builder.rb', line 46

def members_node
  @item.members.all.reject(&:current?).map do |m|
    { type: m.type, value: m.value, op: m.op }
  end
end

#to_jsnsObject Also known as: to_create



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

def to_jsns
  {
    cn: {
      a: instance_variables_array.map(&Utils::A_NODE_PROC),
      l: @item.folder_id || Zm::Client::FolderDefault::CONTACTS[:id],
      m: members_node
    }
  }

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

#to_patch(hash) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/zm/client/contact/group_contact_jsns_builder.rb', line 33

def to_patch(hash)
  {
    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



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/zm/client/contact/group_contact_jsns_builder.rb', line 21

def to_update
  jsns = {
    cn: {
      a: instance_variables_array.map(&Utils::A_NODE_PROC),
      id: @item.id,
      m: members_node
    }
  }

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