class Markety::CustomObject

Attributes

attributes[RW]
keys[RW]
object_type_name[RW]

Public Class Methods

from_marketo_hash(object_type_name, marketo_hash) click to toggle source
# File lib/markety/custom_object.rb, line 23
def self.from_marketo_hash(object_type_name, marketo_hash)
  keys = {}
  attributes = {}
  marketo_hash[:custom_obj_key_list][:attribute].each{|attribute| keys[attribute[:attr_name]] = attribute[:attr_value]}
  marketo_hash[:custom_obj_attribute_list][:attribute].each{|attribute| attributes[attribute[:attr_name]] = attribute[:attr_value]} if marketo_hash[:custom_obj_attribute_list]
  new(object_type_name: object_type_name, keys: keys, attributes: attributes)
end
new(object_type_name: "", keys: {}, attributes: {}) click to toggle source
# File lib/markety/custom_object.rb, line 6
def initialize(object_type_name: "", keys: {}, attributes: {})
  @object_type_name = object_type_name
  @keys = keys
  @attributes = attributes
end

Public Instance Methods

get_key(key_name) click to toggle source
# File lib/markety/custom_object.rb, line 12
def get_key(key_name)
  @keys[key_name]
end
to_sync_custom_object_hash() click to toggle source
# File lib/markety/custom_object.rb, line 16
def to_sync_custom_object_hash
  {
    "customObjKeyList" => key_list,
    "customObjAttributeList" => attribute_list
  }
end

Private Instance Methods

attribute_list() click to toggle source
# File lib/markety/custom_object.rb, line 37
def attribute_list
  attributes_hash(attributes)
end
attributes_hash(attributes) click to toggle source
# File lib/markety/custom_object.rb, line 41
def attributes_hash(attributes)
  {"attribute" => attributes.map{|key, value| {"attrName" => key, "attrValue" => value}}}
end
key_list() click to toggle source
# File lib/markety/custom_object.rb, line 33
def key_list
  attributes_hash(keys)
end