Class: Pokey::Sendgrid::Hook

Inherits:
Hook
  • Object
show all
Includes:
MockData
Defined in:
lib/pokey/sendgrid/hook.rb

Overview

Instance Method Summary collapse

Methods included from MockData

#smtp_id, #user_agents

Instance Method Details

#categoriesObject



43
44
45
# File 'lib/pokey/sendgrid/hook.rb', line 43

def categories
  []
end

#dataObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/pokey/sendgrid/hook.rb', line 22

def data
  data = base_data

  case data["event"]
  # Delivery events
  when "bounce", "deferred", "delivered", "dropped", "processed"
    data.merge!({
      "smtp-id" => smtp_id
    })
  # Engagement events
  when "click", "open", "spamreport", "unsubscribe"
    data.merge!({
      "useragent" => user_agents.sample,
      "ip" => Faker::Internet.ip_v4_address
    })
  end

  data.merge!(unique_args)
  data
end

#destinationObject



10
11
12
# File 'lib/pokey/sendgrid/hook.rb', line 10

def destination
  "http://localhost:3000/api/sendgrid/events"
end

#http_methodObject



18
19
20
# File 'lib/pokey/sendgrid/hook.rb', line 18

def http_method
  :post
end

#intervalObject



14
15
16
# File 'lib/pokey/sendgrid/hook.rb', line 14

def interval
  5
end

#unique_argsObject



47
48
49
# File 'lib/pokey/sendgrid/hook.rb', line 47

def unique_args
  {}
end