Class: Zm::Client::BaseAccountJsnsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/zm/client/base/base_account_jsns_builder.rb

Overview

class for account tag jsns builder

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ BaseAccountJsnsBuilder

Returns a new instance of BaseAccountJsnsBuilder.



7
8
9
# File 'lib/zm/client/base/base_account_jsns_builder.rb', line 7

def initialize(item)
  @item = item
end

Instance Method Details

#build(attrs) ⇒ Object



90
91
92
93
94
95
# File 'lib/zm/client/base/base_account_jsns_builder.rb', line 90

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

#to_colorObject



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/zm/client/base/base_account_jsns_builder.rb', line 67

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



46
47
48
49
50
51
52
53
# File 'lib/zm/client/base/base_account_jsns_builder.rb', line 46

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

  build(attrs)
end

#to_move(new_folder_id = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/zm/client/base/base_account_jsns_builder.rb', line 23

def to_move(new_folder_id = nil)
  new_folder_id ||= @item.l

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

  build(attrs)
end

#to_patch(hash) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/zm/client/base/base_account_jsns_builder.rb', line 35

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

  attrs.reject! { |_, v| v.nil? }

  build(attrs)
end

#to_rename(new_name = nil) ⇒ Object



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

def to_rename(new_name = nil)
  new_name ||= @item.name

  attrs = {
    op: :rename,
    id: @item.id,
    name: new_name
  }

  build(attrs)
end

#to_tag(tag_name = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/zm/client/base/base_account_jsns_builder.rb', line 11

def to_tag(tag_name = nil)
  tag_name ||= @item.tn

  attrs = {
    op: :tag,
    id: @item.id,
    tn: tag_name
  }

  build(attrs)
end

#to_trashObject



81
82
83
84
85
86
87
88
# File 'lib/zm/client/base/base_account_jsns_builder.rb', line 81

def to_trash
  attrs = {
    op: :trash,
    id: @item.id
  }

  build(attrs)
end