Class: Zm::Client::TagJsnsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/zm/client/tag/tag_jsns_builder.rb

Overview

class for account tag jsns builder

Instance Method Summary collapse

Constructor Details

#initialize(tag) ⇒ TagJsnsBuilder

Returns a new instance of TagJsnsBuilder.



8
9
10
# File 'lib/zm/client/tag/tag_jsns_builder.rb', line 8

def initialize(tag)
  @tag = tag
end

Instance Method Details

#to_deleteObject



35
36
37
38
39
40
41
42
# File 'lib/zm/client/tag/tag_jsns_builder.rb', line 35

def to_delete
  action = {
    op: :delete,
    id: @tag.id
  }

  { action: action }
end

#to_jsnsObject Also known as: to_create



12
13
14
15
16
17
18
19
20
# File 'lib/zm/client/tag/tag_jsns_builder.rb', line 12

def to_jsns
  tag = {
    name: @tag.name,
    color: @tag.color,
    rgb: @tag.rgb
  }.delete_if { |_, v| v.nil? }

  { tag: tag }
end

#to_renameObject



44
45
46
47
48
49
50
51
52
# File 'lib/zm/client/tag/tag_jsns_builder.rb', line 44

def to_rename
  action = {
    op: :rename,
    id: @tag.id,
    name: @tag.name
  }

  { action: action }
end

#to_updateObject



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

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

  { action: action }
end