Class: GoodDataMarketo::MObjects
- Inherits:
-
Object
- Object
- GoodDataMarketo::MObjects
- Defined in:
- lib/gooddata_marketo/models/mobjects.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #add_criteria(name, value, comparison) ⇒ Object (also: #add)
- #criteria ⇒ Object
- #get(config = {}) ⇒ Object
-
#initialize(config = {}) ⇒ MObjects
constructor
A new instance of MObjects.
- #remove_criteria(query) ⇒ Object (also: #remove)
Constructor Details
#initialize(config = {}) ⇒ MObjects
Returns a new instance of MObjects.
10 11 12 13 14 15 |
# File 'lib/gooddata_marketo/models/mobjects.rb', line 10 def initialize config = {} @obj_criteria_list = [] @client = config[:client] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/gooddata_marketo/models/mobjects.rb', line 8 def client @client end |
Instance Method Details
#add_criteria(name, value, comparison) ⇒ Object Also known as: add
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/gooddata_marketo/models/mobjects.rb', line 93 def add_criteria name, value, comparison obj = {} obj[:m_obj_criteria] = { :attr_name => name.to_s, :comparison => comparison.to_s, :attr_value => value.to_s } @obj_criteria_list << obj end |
#criteria ⇒ Object
106 107 108 |
# File 'lib/gooddata_marketo/models/mobjects.rb', line 106 def criteria @obj_criteria_list end |
#get(config = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/gooddata_marketo/models/mobjects.rb', line 17 def get config = {} # http://developers.marketo.com/documentation/soap/getcampaignsforsource/ # EXAMPLE CRITERIA # criteria = { # :attr_name => "Id", # See the types of content it can search above. # :comparison => "LE", # :attr_value => "1010" # } # EXAMPLE ASSOCIATED OBJECT # # m_associated_object = { # :m_obj_type => '', # :id=> '', # :external_key => '' <-- Optional # } # EXAMPLE CRITERIA COMPARISONS # EQ - Equals # NE - Not Equals # LT - Less Than # LE - Less Than or Equals # GT - Greater Than # GE - Greater Than or Equals # ACCEPTED ATTRIBUTE VALUE ITEMS # 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. Note: The SFDC Campaign ID needs to be the 18-digit ID. # Created At: Equals, not equals, less than, less than or equal to, greater than, greater than or equal to # Two “created dates” can be specified to create a date range # Updated At or Tag Type (only one can be specified): Equals, not equals, less than, less than or equal to, greater than, greater than or equal to # Two “created 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. # AVAILABLE TYPES # Program # OpportunityPersonRole # Opportunity type = config[:type] || "Program" request = { :type => type } criteria = config[:criteria] || @obj_criteria_list request[:m_obj_criteria_list] = criteria if criteria associate = config[:association] || config[:m_obj_association] || config[:associate] if associate request[:m_obj_association_list] = Hash.new request[:m_obj_association_list][:m_obj_association] = associate end # This field is optional and only present during `type => 'Program'` calls. if type == "Program" request[:include_details] = config[:include_details].to_s || "false" end c = client.stream(:get_m_objects, request) mobjects_from_call = [] c.storage.each do |request| request[:m_object_list][:m_object].each do |mobj| m = GoodDataMarketo::MObject.new mobj mobjects_from_call << m end end binding.pry mobjects_from_call end |
#remove_criteria(query) ⇒ Object Also known as: remove
110 111 112 113 |
# File 'lib/gooddata_marketo/models/mobjects.rb', line 110 def remove_criteria query match = @obj_criteria_list.find {|item| item[:m_obj_criteria][:attr_name] == query } @obj_criteria_list.delete(match) end |