Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The connector engine is thought to be able to use oauth authentication processes, and an oauth_controller.rb is provided as an example. Please note that it is only an example and you will have to implements most of it, as well as create the needed routes, and use them in the provided view.

  For more detailed information, visit:

If all went well, you should now be able to use the 'Link this company to...' link on the home page. Congrats!

...

Expand
titleFiles and Classes

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
languageruby
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

Status
colourBlue
titleGitHub
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
languageruby
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
languageruby

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
languageruby
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
languageruby
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

...