...
Expand |
---|
title | The API does not expose timestamps |
---|
|
If the API does not allow filtering on timestamps or does not expose them, there is no way to filter only updated entities during a synchronization process. In this case, all entities will be re-imported which may impact performances. |
Entities shared and naming conventions
When creating your files, some guidelines can be followed in order to keep consistency and avoid confusion.
Expand |
---|
|
When naming your ruby files, the convention is to use the Connec! endpoint name. I.e. if you are mapping People (Connec!) to Contacts (YourApplication) the ruby file will be named person.rb following Rails conventions. Your class skeleton would then look like this: Code Block |
---|
| class Entities::Person < Maestrano::Connector::Rails::Entity
def self.connec_entity_name
'Person'
end
def self.external_entity_name
'Contact'
end
def self.mapper_class
PersonMapper
end
# Rest of the code
end
| Please refer to Maestrano's open source repositories for more examples. Snippets are taken from the BaseCRM repository
If you need to implement complex entities in YourApplication, you can follow a similar process. I.e. if you are mapping People and Organizations (Connec!) to Contacts (YourApplication) the ruby file for the complex entity would be named person_and_organization.rb . Code Block |
---|
| class Entities::PersonAndOrganization < Maestrano::Connector::Rails::ComplexEntity def self.connec_entities_names
%w(Person Organization)
end
def self.external_entities_names
%w(Contact)
end
# Rest of the code
end
|
You will then have three sub-entities named person.rb , organization.rb and contact.rb respectively. The two mapper files for sub-entities will be named person_mapper.rb and organization_mapper.rb Code Block |
---|
|
class Entities::SubEntities::Person < Maestrano::Connector::Rails::SubEntityBase
def self.external?
false
end
def self.entity_name
'Person'
end
# Rest of the code
end
|
Code Block |
---|
| class Entities::SubEntities::Organization < Maestrano::Connector::Rails::SubEntityBase
def self.external?
false
end
def self.entity_name
'Organization'
end
# Rest of the code
end |
Code Block |
---|
| class Entities::SubEntities::Contact < Maestrano::Connector::Rails::SubEntityBase
def self.external?
true
end
def self.entity_name
'Contact'
end
def self.mapper_classes
{
'Person' => Entities::SubEntities::PersonMapper,
'Organization' => Entities::SubEntities::OrganizationMapper
}
end
def self.references
{
'Person' => Entities::SubEntities::PersonMapper.person_references,
'Organization' => Entities::SubEntities::OrganizationMapper.organization_references
}
end
def self.object_name_from_external_entity_hash(entity)
if entity['is_organization']
entity['name']
else
"#{entity['first_name']} #{entity['last_name']}"
end
end
end |
|
API Client
If YourApp does not provide a Gem to query the API you would need to create your own.
...