Class: Zm::Client::ContactJsnsBuilder
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
#build, #initialize, #to_color, #to_delete, #to_move, #to_rename, #to_tag, #to_trash
Instance Method Details
#all_instance_variables ⇒ Object
55
56
57
|
# File 'lib/zm/client/contact/contact_jsns_builder.rb', line 55
def all_instance_variables
@item.instance_variables - EXCLUDE_INSTANCE_VARIABLE_KEYS
end
|
#instance_variables_array(zcs_attrs) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/zm/client/contact/contact_jsns_builder.rb', line 42
def instance_variables_array(zcs_attrs)
arr = zcs_attrs.map do |name|
n = name.to_s[1..]
value = @item.instance_variable_get(name)
[n, value]
end
multi_value = arr.select { |a| a.last.is_a?(Array) }
arr.reject! { |a| a.last.is_a?(Array) || a.last.nil? }
multi_value.each { |a| arr += a.last.map { |v| [a.first, v] } }
arr
end
|
#to_jsns ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/zm/client/contact/contact_jsns_builder.rb', line 9
def to_jsns
jsns = {
cn: {
a: instance_variables_array(all_instance_variables).map(&Utils::A_NODE_PROC),
l: @item.folder_id || Zm::Client::FolderDefault::CONTACTS[:id]
}
}
SoapElement.mail(SoapMailConstants::CREATE_CONTACT_REQUEST).add_attributes(jsns)
end
|
#to_patch(hash) ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/zm/client/contact/contact_jsns_builder.rb', line 31
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_update ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/zm/client/contact/contact_jsns_builder.rb', line 20
def to_update
jsns = {
cn: {
a: instance_variables_array(all_instance_variables).map(&Utils::A_NODE_PROC),
id: @item.id
}
}
SoapElement.mail(SoapMailConstants::MODIFY_CONTACT_REQUEST).add_attributes(jsns)
end
|