class MarketoAPI::MObjects
MarketoAPI
operations on Marketo objects (MObject).
Public Instance Methods
delete(mobject, mobject, ...) → status_list
click to toggle source
Implements {deleteMObjects
}, returning the deletion success status for each object provided.
Only works with Opportunity or OpportunityPersonRole MObjects
.
To delete an Opportunity:
marketo.mobjects.delete MarketoAPI::MObject.opportunity(75)
# File lib/marketo_api/mobjects.rb, line 19 def delete(*mobjects) if mobjects.empty? raise ArgumentError, "must provide one or more MObjects to delete" end response = call( :delete_m_objects, mObjectList: transform_param_list(__method__, mobjects) ) extract_mobject_status_list(response) end
describe(name)
click to toggle source
Implements {describeMObject
}, returning the description of the Marketo object.
# File lib/marketo_api/mobjects.rb, line 44 def describe(name) unless MarketoAPI::MObject::DESCRIBE_TYPES.include?(name.to_sym) raise ArgumentError, "invalid type #{name} to describe" end extract_from_response( call(:describe_m_object, objectName: name), :metadata ) end
get(mobject)
click to toggle source
Implements {getMObjects
}, returning one or more Marketo objects, up to 100 in a page. It also returns the current current stream position to continue working with the pages on subsequent calls to get
.
See MObject#criteria and MObject#association on how to build criteria and association filters for get
queries.
# File lib/marketo_api/mobjects.rb, line 63 def get(mobject) call(:get_m_objects, transform_param(__method__, mobject)) { |list| Get.new(list) } end
Private Instance Methods
extract_mobject_status_list(response)
click to toggle source
# File lib/marketo_api/mobjects.rb, line 109 def extract_mobject_status_list(response) response = extract_from_response(response, :m_obj_status_list) { |resp| resp.map { |e| e[:m_object_status].values_at(:id, :status) } }.flatten Hash[*response] end