Sha256: 655111e154c328744aa965a7adc84c39c4b8e680d18fedf73a8544e77e478717

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

module FatFreeCRM
  module Cloudfuji
    module EventObservers
      class EventRulesObserver < ::Cloudfuji::EventObserver
        # Fire for all events
        def catch_all
          data  = params['data']
          email = data['email'] || data['recipient']
          # Look up Lead by ido_id, fall back to email address
          lead = if data['customer_ido_id'].present?
            Lead.find_by_ido_id(data['customer_ido_id'])
          else
            Lead.find_by_email(email)
          end
          if lead
            event_name = "#{params['category']}_#{params['event']}"

            EventRule.find_all_by_event_category_and_cloudfuji_event('cloudfuji_event_received', event_name).each do |rule|
              rule.process(lead, params['data'])
            end
          end
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffcrm_cloudfuji-0.2.5 lib/fat_free_crm/cloudfuji/event_observers/event_rules_observer.rb
ffcrm_cloudfuji-0.2.4 lib/fat_free_crm/cloudfuji/event_observers/event_rules_observer.rb
ffcrm_cloudfuji-0.2.3 lib/fat_free_crm/cloudfuji/event_observers/event_rules_observer.rb