Class: Eloqua::Entity
- Inherits:
-
RemoteObject
- Object
- RemoteObject
- Eloqua::Entity
- Defined in:
- lib/eloqua/entity.rb
Constant Summary
Constants inherited from RemoteObject
RemoteObject::DIRTY_PRIVATE_METHODS
Instance Attribute Summary
Attributes inherited from RemoteObject
Class Method Summary collapse
-
.list_memberships(id) ⇒ Hash
Returns an :id indexed list of memberships for given contact id.
- .where(conditions = nil, fields = [], limit = 200, page = 1) ⇒ Object
Instance Method Summary collapse
- #add_membership(asset) ⇒ Object
-
#list_memberships ⇒ Hash
Returns an :id indexed list of memberships for contact.
- #remove_membership(asset) ⇒ Object
Methods inherited from RemoteObject
api, attr_checkbox, attr_type_hash, #changed_attributes, #convert_attribute_values, #create, find, #id, #initialize, #is_attribute_method?, #method_missing, #persisted?, #read_attribute, #reload, #respond_to?, #save, #update, #update_attributes, #write_attribute
Constructor Details
This class inherits a constructor from Eloqua::RemoteObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Eloqua::RemoteObject
Class Method Details
.list_memberships(id) ⇒ Hash
Returns an :id indexed list of memberships for given contact id
# Example output
{'1' => {:id => '1', :name => 'Contact Group Name', :type => 'ContactGroup}}
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/eloqua/entity.rb', line 36 def list_memberships(id) memberships = api.list_memberships(remote_type, id) if(memberships && !memberships.empty?) memberships.inject({}) do |map, membership| map[membership[:id]] = membership map end else memberships || {} end end |
.where(conditions = nil, fields = [], limit = 200, page = 1) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/eloqua/entity.rb', line 50 def where(conditions = nil, fields = [], limit = 200, page = 1) if(conditions) query = where conditions.each do |key, value| query.on(key, '=', value) end query.fields(fields) if fields query.limit(limit) query.page(page) results = query.all if(results.blank?) false else results end else Eloqua::Query.new(self) end end |
Instance Method Details
#add_membership(asset) ⇒ Object
19 20 21 |
# File 'lib/eloqua/entity.rb', line 19 def add_membership(asset) asset.add_member(self) end |
#list_memberships ⇒ Hash
Returns an :id indexed list of memberships for contact
# Example output
{'1' => {:id => '1', :name => 'Contact Group Name', :type => 'ContactGroup}}
15 16 17 |
# File 'lib/eloqua/entity.rb', line 15 def list_memberships self.class.list_memberships(id) end |
#remove_membership(asset) ⇒ Object
23 24 25 |
# File 'lib/eloqua/entity.rb', line 23 def remove_membership(asset) asset.remove_member(self) end |