Class: Zm::Client::Signature

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

Overview

class account signature

Constant Summary collapse

TYPE_TXT =
'text/plain'
TYPE_HTML =
'text/html'
INSTANCE_VARIABLE_KEYS =
i[id name txt html]

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

#as_jsnsObject



57
58
59
# File 'lib/zm/client/signature/signature.rb', line 57

def as_jsns
  SignatureJsnsBuilder.new(self).to_jsns
end

#concatObject



14
15
16
# File 'lib/zm/client/signature/signature.rb', line 14

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

#contentObject



53
54
55
# File 'lib/zm/client/signature/signature.rb', line 53

def content
  html || txt
end

#create!Object



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

def create!
  rep = @parent.sacc.create_signature(@parent.token, as_jsns)
  @id = rep[:Body][:CreateSignatureResponse][:signature].first[:id]
end

#delete!Object



36
37
38
# File 'lib/zm/client/signature/signature.rb', line 36

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

#html?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/zm/client/signature/signature.rb', line 45

def html?
  type == TYPE_HTML
end

#init_from_json(json) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/zm/client/signature/signature.rb', line 18

def init_from_json(json)
  @id      = json[:id]
  @name    = json[:name]
  json[:content].each do |c|
    @txt = c[:_content] if c[:type] == TYPE_TXT
    @html = c[:_content] if c[:type] == TYPE_HTML
  end if json[:content].is_a?(Array)
end

#modify!Object



32
33
34
# File 'lib/zm/client/signature/signature.rb', line 32

def modify!
  @parent.sacc.modify_signature(@parent.token, as_jsns)
end

#txt?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/zm/client/signature/signature.rb', line 49

def txt?
  type == TYPE_TXT
end

#typeObject



40
41
42
43
# File 'lib/zm/client/signature/signature.rb', line 40

def type
  return TYPE_HTML unless html.nil?
  TYPE_TXT
end