Class: PushMore

Inherits:
Object
  • Object
show all
Defined in:
lib/push_more.rb

Constant Summary collapse

WEBHOOK_BASE_URL =
"https://pushmore.io/webhook/"

Instance Method Summary collapse

Constructor Details

#initialize(body, key: ENV.fetch("PUSH_MORE_KEY")) ⇒ PushMore

Returns a new instance of PushMore.



8
9
10
11
# File 'lib/push_more.rb', line 8

def initialize(body, key: ENV.fetch("PUSH_MORE_KEY"))
  @body = body
  @key = key
end

Instance Method Details

#deliverObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/push_more.rb', line 13

def deliver
  http = Net::HTTP.new(webhook_uri.host, webhook_uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER

  request = Net::HTTP::Post.new(webhook_uri.request_uri)
  request.body = @body

  response = http.request(request)

  if response.body.include? "Error"
    raise response.body
  else
    true
  end
end