Sha256: b1a141d206cdaec4224c0488e2c91d484866adc870c4c5b1669788ad8fe255c2

Contents?: true

Size: 775 Bytes

Versions: 10

Compression:

Stored size: 775 Bytes

Contents

module Services
  module Hubspot
    module Webhooks
      class Handle
        def initialize(webhook)
          @webhook = webhook
        end

        def call
          create_event
        end

        private

        def create_event
          event = Event.new(
            event_type: @webhook['subscriptionType'].split('.').last,
            object_id: @webhook['objectId'],
            event_id: @webhook['eventId'],
            occured_at: @webhook['occurredAt']
          )

          if event.event_type == 'propertyChange'
            event.assign_attributes(
              property_name: @webhook['propertyName'],
              property_value: @webhook['propertyValue']
            )
          end
          event.save!
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hubspot-api-client-3.2.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb
hubspot-api-client-3.1.1 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb
hubspot-api-client-3.1.0.pre.beta sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb
hubspot-api-client-3.0.0.pre.beta sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb
hubspot-api-client-2.3.2 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb
hubspot-api-client-2.3.1 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb
hubspot-api-client-2.2.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb
hubspot-api-client-2.1.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb
hubspot-api-client-2.0.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb
hubspot-api-client-1.0.1 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb