Class: Maestrano::Connector::Rails::Entity

Inherits:
Object
  • Object
show all
Includes:
Concerns::Entity
Defined in:
lib/generators/connector/templates/entity.rb,
app/models/maestrano/connector/rails/entity.rb

Direct Known Subclasses

SubEntityBase

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.entities_listObject

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

Instance Method Details

#create_entity_to_external(client, mapped_connec_entity, external_entity_name, organization) ⇒ Object



24
25
26
27
28
# File 'lib/generators/connector/templates/entity.rb', line 24

def create_entity_to_external(client, mapped_connec_entity, external_entity_name, organization)
  Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending create #{external_entity_name}: #{mapped_connec_entity} to #{@@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
# File 'lib/generators/connector/templates/entity.rb', line 16

def get_external_entities(client, last_synchronization, organization, opts={})
  Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Fetching #{@@external_name} #{self.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=#{@@external_name}, Entity=#{self.external_entity_name}, Response=#{entities}")
end

#get_id_from_external_entity_hash(entity) ⇒ Object



36
37
38
39
40
# File 'lib/generators/connector/templates/entity.rb', line 36

def get_id_from_external_entity_hash(entity)
  # TODO
  # This method return the id from an external_entity_hash
  # e.g entity['id']
end

#get_last_update_date_from_external_entity_hash(entity) ⇒ Object



42
43
44
45
46
# File 'lib/generators/connector/templates/entity.rb', line 42

def get_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

#update_entity_to_external(client, mapped_connec_entity, external_id, external_entity_name) ⇒ Object



30
31
32
33
34
# File 'lib/generators/connector/templates/entity.rb', line 30

def update_entity_to_external(client, mapped_connec_entity, external_id, external_entity_name)
  Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending update #{external_entity_name} (id=#{external_id}): #{mapped_connec_entity} to #{@@external_name}")
  # TODO
  # This method updates the entity with the given id in the external app
end