Class: Maestrano::Connector::Rails::Entity
- Inherits:
-
Object
- Object
- Maestrano::Connector::Rails::Entity
- Includes:
- Concerns::Entity
- Defined in:
- lib/generators/connector/templates/entity.rb,
app/models/maestrano/connector/rails/entity.rb
Direct Known Subclasses
Class Method Summary collapse
-
.entities_list ⇒ Object
Return an array of all the entities that the connector can synchronize If you add new entities, you need to generate a migration to add them to existing organizations.
- .id_from_external_entity_hash(entity) ⇒ Object
- .last_update_date_from_external_entity_hash(entity) ⇒ Object
Instance Method Summary collapse
- #create_external_entity(client, mapped_connec_entity, external_entity_name, organization) ⇒ Object
-
#get_external_entities(client, last_synchronization, organization, opts = {}) ⇒ Object
Return an array of entities from the external app.
- #update_external_entity(client, mapped_connec_entity, external_id, external_entity_name, organization) ⇒ Object
Class Method Details
.entities_list ⇒ Object
Return an array of all the entities that the connector can synchronize If you add new entities, you need to generate a migration to add them to existing organizations
7 8 9 10 11 12 13 |
# File 'lib/generators/connector/templates/entity.rb', line 7 def self.entities_list # TODO # The names in this list should match the names of your entities class # e.g %w(person, tasks_list) # will synchronized Entities::Person and Entities::TasksList [] end |
.id_from_external_entity_hash(entity) ⇒ Object
37 38 39 40 41 |
# File 'lib/generators/connector/templates/entity.rb', line 37 def self.id_from_external_entity_hash(entity) # TODO # This method return the id from an external_entity_hash # e.g entity['id'] end |
.last_update_date_from_external_entity_hash(entity) ⇒ Object
43 44 45 46 47 |
# File 'lib/generators/connector/templates/entity.rb', line 43 def self.last_update_date_from_external_entity_hash(entity) # TODO # This method return the last update date from an external_entity_hash # e.g entity['last_update'] end |
Instance Method Details
#create_external_entity(client, mapped_connec_entity, external_entity_name, organization) ⇒ Object
25 26 27 28 29 |
# File 'lib/generators/connector/templates/entity.rb', line 25 def create_external_entity(client, mapped_connec_entity, external_entity_name, organization) Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending create #{external_entity_name}: #{mapped_connec_entity} to #{Maestrano::Connector::Rails::External.external_name}") # TODO # This method creates the entity in the external app and returns the external id end |
#get_external_entities(client, last_synchronization, organization, opts = {}) ⇒ Object
Return an array of entities from the external app
16 17 18 19 20 21 22 23 |
# File 'lib/generators/connector/templates/entity.rb', line 16 def get_external_entities(client, last_synchronization, organization, opts={}) return [] unless self.class.can_read_external? Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Fetching #{Maestrano::Connector::Rails::External.external_name} #{self.class.external_entity_name.pluralize}") # TODO # This method should return only entities that have been updated since the last_synchronization # It should also implements an option to do a full synchronization when opts[:full_sync] == true or when there is no last_synchronization # Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Received data: Source=#{Maestrano::Connector::Rails::External.external_name}, Entity=#{self.class.external_entity_name}, Response=#{entities}") end |
#update_external_entity(client, mapped_connec_entity, external_id, external_entity_name, organization) ⇒ Object
31 32 33 34 35 |
# File 'lib/generators/connector/templates/entity.rb', line 31 def update_external_entity(client, mapped_connec_entity, external_id, external_entity_name, organization) Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending update #{external_entity_name} (id=#{external_id}): #{mapped_connec_entity} to #{Maestrano::Connector::Rails::External.external_name}") # TODO # This method updates the entity with the given id in the external app end |