class TXTextControl::ReportingCloud::TemplateInfo

Holds information about the merge blocks and merge fields in a template

in the template storage.

@attr_reader template_name [String] The template file name. @attr_reader merge_blocks [Array<MergeBlock>] Contains all top level merge

blocks in the template.

@attr_reader merge_fields [Array<MergeField>] Contains all top level merge

fields in the template.

@author Thorsten Kummerow (@thomerow)

Attributes

merge_blocks[R]
merge_fields[R]
template_name[R]

Public Class Methods

from_camelized_hash(hash) click to toggle source

Creates a TemplateInfo instance from a hash. @param hash [Hash] The hash to try and create a TemplateInfo instance from. @return [TemplateInfo] A newly created TemplateInfo instance.

# File lib/txtextcontrol/reportingcloud/template_info.rb, line 50
def self.from_camelized_hash(hash)
  # Parameter validation
  raise ArgumentError, "Parameter must be a Hash." if !hash.kind_of? Hash

  name = hash["templateName"]
  blocks = Array.new
  hash["mergeBlocks"].each do |elem|
    blocks.push(MergeBlock.from_camelized_hash(elem))
  end
  fields = Array.new 
  hash["mergeFields"].each do |elem|
    fields.push(MergeField.from_camelized_hash(elem))
  end
  return TemplateInfo.new(name, blocks, fields)
end
new(template_name, merge_blocks, merge_fields) click to toggle source

@param template_name [String] The template file name. @param merge_blocks [Array<MergeBlock>] The top level merge blocks in the template. @param merge_fields [Array<MergeField>] The top level merge fields in the template.

# File lib/txtextcontrol/reportingcloud/template_info.rb, line 36
def initialize(template_name, merge_blocks, merge_fields)
  # Parameter validation
  raise ArgumentError, "Block name must be a string." if !template_name.kind_of? String
  raise ArgumentError, "Parameter merge_blocks must be an array." if !merge_blocks.kind_of? Array
  raise ArgumentError, "Parameter merge_fields must be an array." if !merge_fields.kind_of? Array

  @template_name = template_name
  @merge_blocks = merge_blocks
  @merge_fields = merge_fields
end