Class: Zm::Client::SearchFolderJsnsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/zm/client/search_folder/search_folder_jsns_builder.rb

Overview

class for account search folder jsns builder

Instance Method Summary collapse

Constructor Details

#initialize(search_folder) ⇒ SearchFolderJsnsBuilder

Returns a new instance of SearchFolderJsnsBuilder.



7
8
9
# File 'lib/zm/client/search_folder/search_folder_jsns_builder.rb', line 7

def initialize(search_folder)
  @item = search_folder
end

Instance Method Details

#build(attrs) ⇒ Object



97
98
99
100
101
102
# File 'lib/zm/client/search_folder/search_folder_jsns_builder.rb', line 97

def build(attrs)
  soap_request = SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST)
  node_action = SoapElement.create(SoapConstants::ACTION).add_attributes(attrs)
  soap_request.add_node(node_action)
  soap_request
end

#to_colorObject



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/zm/client/search_folder/search_folder_jsns_builder.rb', line 74

def to_color
  attrs = {
    op: :color,
    id: @item.id,
    rgb: @item.rgb,
    color: @item.color
  }

  # attrs[:rgb] = @item.rgb if @item.rgb_changed?
  # attrs[:color] = @item.color if @item.color_changed?

  build(attrs)
end

#to_deleteObject



88
89
90
91
92
93
94
95
# File 'lib/zm/client/search_folder/search_folder_jsns_builder.rb', line 88

def to_delete
  attrs = {
    op: :delete,
    id: @item.id
  }

  build(attrs)
end

#to_jsnsObject Also known as: to_create



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/zm/client/search_folder/search_folder_jsns_builder.rb', line 11

def to_jsns
  attrs = {
    name: @item.name,
    query: @item.query,
    types: @item.types,
    l: @item.l,
    color: @item.color,
    sortBy: @item.sortBy
  }.delete_if { |_, v| v.nil? }

  soap_request = SoapElement.mail(SoapMailConstants::CREATE_SEARCH_FOLDER_REQUEST)
  node_search = SoapElement.create(SoapConstants::SEARCH).add_attributes(attrs)
  soap_request.add_node(node_search)
  soap_request
end

#to_modifyObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/zm/client/search_folder/search_folder_jsns_builder.rb', line 29

def to_modify
  attrs = {
    id: @item.id,
    query: @item.query,
    types: @item.types
  }.reject { |_, v| v.nil? }

  soap_request = SoapElement.mail(SoapMailConstants::MODIFY_SEARCH_FOLDER_REQUEST)
  node_search = SoapElement.create(SoapConstants::SEARCH).add_attributes(attrs)
  soap_request.add_node(node_search)
  soap_request
end

#to_moveObject



64
65
66
67
68
69
70
71
72
# File 'lib/zm/client/search_folder/search_folder_jsns_builder.rb', line 64

def to_move
  attrs = {
    op: :move,
    id: @item.id,
    l: @item.l
  }

  build(attrs)
end

#to_rename(new_name) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/zm/client/search_folder/search_folder_jsns_builder.rb', line 54

def to_rename(new_name)
  attrs = {
    op: :rename,
    id: @item.id,
    name: new_name
  }

  build(attrs)
end

#to_updateObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/zm/client/search_folder/search_folder_jsns_builder.rb', line 42

def to_update
  attrs = {
    op: :update,
    id: @item.id,
    name: @item.name,
    color: @item.color,
    rgb: @item.rgb
  }.reject { |_, v| v.nil? }

  build(attrs)
end