Class: EmailCenterApi::Nodes::TemplateNode

Inherits:
Object
  • Object
show all
Defined in:
lib/email_center_api/nodes/template_node.rb

Constant Summary collapse

TREE_ROOT =
'email_template'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, node_id) ⇒ TemplateNode

Returns a new instance of TemplateNode.



7
8
9
10
# File 'lib/email_center_api/nodes/template_node.rb', line 7

def initialize(name, node_id)
  @name = name
  @node_id = node_id.to_i
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/email_center_api/nodes/template_node.rb', line 5

def name
  @name
end

#node_idObject (readonly)

Returns the value of attribute node_id.



5
6
7
# File 'lib/email_center_api/nodes/template_node.rb', line 5

def node_id
  @node_id
end

Class Method Details

.allObject



12
13
14
15
16
17
18
19
20
# File 'lib/email_center_api/nodes/template_node.rb', line 12

def self.all
  response = EmailCenterApi::Query.new(TREE_ROOT).root
  response.first['children'].map do |template|
    self.new(
      template['text'],
      template['nodeId']
    )
  end
end