Class: ActionPushWeb::Pusher

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

Instance Method Summary collapse

Constructor Details

#initialize(config, notification) ⇒ Pusher

Returns a new instance of Pusher.



3
4
5
6
# File 'lib/action_push_web/pusher.rb', line 3

def initialize(config, notification)
  @config = config
  @notification = notification
end

Instance Method Details

#push(connection:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/action_push_web/pusher.rb', line 8

def push(connection:)
  request = Net::HTTP::Post.new(uri.request_uri, headers).tap do
    it.body = payload
  end

  if resolved_endpoint_ip
    pinned_connection.request(request)
  else
    connection.request(uri, request)
  end.tap { handle_response(it) }
rescue OpenSSL::OpenSSLError
  raise TokenError.new
end