Class: MarketoAPI::MObjects

Inherits:
ClientProxy show all
Defined in:
lib/marketo_api/mobjects.rb

Overview

MarketoAPI operations on Marketo objects (MObject).

Defined Under Namespace

Classes: Get

Instance Method Summary collapse

Methods inherited from ClientProxy

inherited, #initialize

Constructor Details

This class inherits a constructor from MarketoAPI::ClientProxy

Instance Method Details

#delete(*mobjects) ⇒ Object

:call-seq:

delete(mobject, mobject, ...) -> status_list

Implements href="http://developers.marketo.com/documentation/soap/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)


19
20
21
22
23
24
25
26
27
28
# 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) ⇒ Object

Implements href="http://developers.marketo.com/documentation/soap/describemobject/">, returning the description of the Marketo object.



44
45
46
47
48
49
50
51
52
53
# 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) ⇒ Object

Implements href="http://developers.marketo.com/documentation/soap/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.



63
64
65
66
67
# File 'lib/marketo_api/mobjects.rb', line 63

def get(mobject)
  call(:get_m_objects, transform_param(__method__, mobject)) { |list|
    Get.new(list)
  }
end

#listObject

Implements href="http://developers.marketo.com/documentation/soap/listmobjects/">, returning the type names of the available Marketo objects. The type names can be passed to #describe.



34
35
36
37
38
39
# File 'lib/marketo_api/mobjects.rb', line 34

def list
  extract_from_response(
    call(:list_m_objects, nil),
    :objects
  )
end

#sync(operation, *mobjects) ⇒ Object

:nodoc:

Raises:

  • (NotImplementedError)


69
70
71
72
73
74
75
76
77
78
# File 'lib/marketo_api/mobjects.rb', line 69

def sync(operation, *mobjects) #:nodoc:
  # http://developers.marketo.com/documentation/soap/sync-mobjects/
  raise NotImplementedError,
    ":syncMObjects is not implemented in this version."
  response = call(
    :sync_m_objects,
    transform_param_list(__method__, mobjects)
  )
  extract_mobject_status_list(response)
end