Class: Markety::CustomObject

Inherits:
Object
  • Object
show all
Defined in:
lib/markety/custom_object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_type_name: "", keys: {}, attributes: {}) ⇒ CustomObject

Returns a new instance of CustomObject.



6
7
8
9
10
# 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

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



4
5
6
# File 'lib/markety/custom_object.rb', line 4

def attributes
  @attributes
end

#keysObject

Returns the value of attribute keys.



4
5
6
# File 'lib/markety/custom_object.rb', line 4

def keys
  @keys
end

#object_type_nameObject

Returns the value of attribute object_type_name.



4
5
6
# File 'lib/markety/custom_object.rb', line 4

def object_type_name
  @object_type_name
end

Class Method Details

.from_marketo_hash(object_type_name, marketo_hash) ⇒ Object



23
24
25
26
27
28
29
# 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

Instance Method Details

#get_key(key_name) ⇒ Object



12
13
14
# File 'lib/markety/custom_object.rb', line 12

def get_key(key_name)
  @keys[key_name]
end

#to_sync_custom_object_hashObject



16
17
18
19
20
21
# File 'lib/markety/custom_object.rb', line 16

def to_sync_custom_object_hash
  {
    "customObjKeyList" => key_list,
    "customObjAttributeList" => attribute_list
  }
end