Class: Zm::Client::Tag

Inherits:
Base::AccountObject show all
Defined in:
lib/zm/client/tag/tag.rb

Overview

class account tag

Constant Summary collapse

INSTANCE_VARIABLE_KEYS =
i[id name color rgb u n d rev md ms]

Instance Attribute Summary

Attributes inherited from Base::Object

#grantee_type, #id, #name, #parent, #token

Instance Method Summary collapse

Methods inherited from Base::AccountObject

#soap_account_connector

Methods inherited from Base::Object

#arrow_name, #clone, #convert_json_string_value, #initialize, #instance_variables_array, #instance_variables_hash, #recorded?, #save!, #to_s

Constructor Details

This class inherits a constructor from Zm::Client::Base::Object

Instance Method Details

#concatObject



12
13
14
# File 'lib/zm/client/tag/tag.rb', line 12

def concat
  INSTANCE_VARIABLE_KEYS.map { |key| instance_variable_get(arrow_name(key)) }
end

#create!Object



22
23
24
25
# File 'lib/zm/client/tag/tag.rb', line 22

def create!
  rep = @parent.sacc.create_tag(@parent.token, @name, @color, @rgb)
  init_from_json(rep[:Body][:CreateTagResponse][:tag].first)
end

#delete!Object



31
32
33
# File 'lib/zm/client/tag/tag.rb', line 31

def delete!
  @parent.sacc.tag_action(@parent.token, :delete, @id)
end

#init_from_json(json) ⇒ Object



16
17
18
19
20
# File 'lib/zm/client/tag/tag.rb', line 16

def init_from_json(json)
  INSTANCE_VARIABLE_KEYS.each do |key|
    instance_variable_set(arrow_name(key), json[key])
  end
end

#modify!Object



27
28
29
# File 'lib/zm/client/tag/tag.rb', line 27

def modify!
  @parent.sacc.tag_action(@parent.token, :update, @id, { color: @color, rgb: @rgb })
end

#rename!(new_name) ⇒ Object



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

def rename!(new_name)
  @parent.sacc.tag_action(
    @parent.token,
    :rename,
    @id,
    name: new_name
  )
end