Class: Zm::Client::FolderJsnsBuilder

Inherits:
BaseAccountJsnsBuilder show all
Defined in:
lib/zm/client/folder/folder_jsns_builder.rb

Overview

class for account folder jsns builder

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

#to_emptyObject



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/zm/client/folder/folder_jsns_builder.rb', line 80

def to_empty
  action = {
    op: :empty,
    id: @item.id,
    recursive: false
  }

  attrs = { action: action }

  SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST).add_attributes(attrs)
end

#to_findObject



7
8
9
10
# File 'lib/zm/client/folder/folder_jsns_builder.rb', line 7

def to_find
  attrs = { folder: { l: @item.id } }
  SoapElement.mail(SoapMailConstants::GET_FOLDER_REQUEST).add_attributes(attrs)
end

#to_jsnsObject Also known as: to_create



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/zm/client/folder/folder_jsns_builder.rb', line 12

def to_jsns
  folder = {
    f: @item.f,
    name: @item.name,
    l: @item.l,
    color: @item.color,
    rgb: @item.rgb,
    url: @item.url,
    fb: @item.fb,
    view: @item.view
  }.delete_if { |_, v| v.nil? }

  attrs = { folder: folder }

  SoapElement.mail(SoapMailConstants::CREATE_FOLDER_REQUEST).add_attributes(attrs)
end

#to_patch(options) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/zm/client/folder/folder_jsns_builder.rb', line 55

def to_patch(options)
  action = {
    op: :update,
    id: @item.id
  }.merge(options)

  attrs = { action: action }

  SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST).add_attributes(attrs)
end

#to_retentionpolicyObject



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/zm/client/folder/folder_jsns_builder.rb', line 66

def to_retentionpolicy
  retentionpolicy = @item.retention_policies.all.map { |rp| retentionpolicy_jsns(rp) }.reduce({}, :merge)

  attrs = {
    action: {
      op: :retentionpolicy,
      id: @item.id,
      retentionPolicy: retentionpolicy
    }
  }

  SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST).add_attributes(attrs)
end

#to_updateObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/zm/client/folder/folder_jsns_builder.rb', line 31

def to_update
  action = {
    op: :update,
    id: @item.id,
    f: @item.f,
    name: @item.name,
    l: @item.l,
    color: @item.color,
    rgb: @item.rgb,
    url: @item.url,
    fb: @item.fb,
    view: @item.view
  }.delete_if { |_, v| v.nil? }

  if @item.is_immutable?
    action.delete(:name)
    action.delete(:l)
  end

  attrs = { action: action }

  SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST).add_attributes(attrs)
end