class MarketoAPI::MObject

A representation of Marketo object (MObject) records as well as key representations for getting, syncing, or deleting those records.

Attributes

associations[R]

Associated objects.

attributes[R]

The detailed attributes of the Marketo object.

id[RW]

The ID of the Marketo object.

include_details[RW]

When getting a Marketo Program, the details will be included if this is true.

stream_position[RW]

The stream position for paged queries.

type[R]

The type of Marketo object. Will be one of:

  • Opportunity

  • OpportunityPersonRole

  • Program

  • ActivityRecord

  • LeadRecord

In general, only the first three can be interacted with through the SOAP API.

types[R]

The detailed types of the Marketo object.

Public Class Methods

new(type, id = nil) { |self| ... } click to toggle source
# File lib/marketo_api/mobject.rb, line 42
def initialize(type, id = nil)
  @type                = ensure_valid_type!(type)
  @id                  = id
  @attributes          = {}
  @criteria            = []
  @associations        = []
  @stream_position     = nil
  @include_details     = false
  @types               = Hash.new { |h, k| h[k] = {} }
  yield self if block_given?
end

Public Instance Methods

==(other) click to toggle source
# File lib/marketo_api/mobject.rb, line 134
def ==(other)
  type == other.type &&
    include_details == other.include_details &&
    id == other.id &&
    stream_position == other.stream_position &&
    attributes == other.attributes &&
    types == other.types &&
    criteria == other.criteria &&
    associations == other.associations
end
association(type, options = {}) click to toggle source

Add association criteria for use with MarketoAPI::MObjects#get or MarketoAPI::MOBjects#sync (not yet implemented).

Type type must be one of Lead, Company, or Opportunity. It must be accompanied with one of the following parameters:

id

The Marketo ID of the associated object.

external

The custom attribute value of the associated object. Can also be accessed as external_key.

# File lib/marketo_api/mobject.rb, line 110
def association(type, options = {})
  @associations << Association.new(type, options)
  @associations
end
criteria(name = nil, value = nil, comparison = nil) click to toggle source

Adds query criteria for use with MarketoAPI::MObjects#get.

Name

Name

Name of the MObject

Role

The role associated with an OpportunityPersonRole object

Type

The type of an Opportunity object

Stage

The stage of an Opportunity object

CRM Id: The CRM ID could refer to the ID of the

Salesforce campaign connected to a Marketo
program
Created At

The date the MObject was created. Can be used with the comparisons EQ, NE, LT, LE, GT, and GE. Two “created dates” can be specified to create a date range.

Updated At or Tag Type

(Only one can be specified) Can be used with the comparisons EQ, NE, LT, LE, GT, and GE. Two “updated dates” can be specified to create a date range.

Tag Value: (Only one can be specified) Workspace Name: (Only one can be specified) Workspace Id: (Only one can be specified) Include Archive: Applicable only with Program MObject. Set it to

true if you wish to include archived programs.

Comparison

EQ

Equals

NE

Not Equals

LT

Less Than

LE

Less Than or Equals

GT

Greater Than

GE

Greater Than or Equals

# File lib/marketo_api/mobject.rb, line 96
def criteria(name = nil, value = nil, comparison = nil)
  @criteria << Criteria.new(name, value, comparison) if name
  @criteria
end

Private Instance Methods

ensure_valid_type!(type, list = ALL_TYPES) click to toggle source
# File lib/marketo_api/mobject.rb, line 267
def ensure_valid_type!(type, list = ALL_TYPES)
  unless list.include? type.to_sym
    raise ArgumentError, ":type must be one of #{list.join(", ")}"
  end
  type.to_sym
end