Versions Compared

Key

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

...

Expand
titleHow to use Connec!™ filtering capabilities?

Connec! has a built in filter that can be used to query for a specific subset of entities on a given endpoint. Please refer to:

http://maestrano.github.io/connec/#api-|-querying-filtering-get


I.e. In the entity below ('contact.rb'), you want to fetch only the entities that are leads. In order to maintain a consistent workflow (including web-hooks), a method to override is provided (to be used in conjunction with the filtering):

Code Block
languageruby
def get_connec_entities(last_synchronization_date)
  @opts.merge!(:$filter => "is_lead eq true")
  super
end  
      
def filter_connec_entities(entities)
  entities.select{|e| e['is_lead']}
end

...

Code Block
languageruby
class ExternalWebhooksController < ApplicationController
  def notification
    organization = # find organization from webhook params
	# The second argument should be a hash: {"external_entity_name1" => [entity1, entity2], "external_entity_name2" => []}
    Maestrano::Connector::Rails::PushToConnecJob.perform_later(current_organization, entities_hash)
  end
end

...