Class: BMO::GCM::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/bmo/gcm/connection.rb

Overview

Handle the connection state SSL or Pure TCP

Instance Method Summary collapse

Constructor Details

#initialize(gateway_url, api_key) ⇒ Connection

Returns a new instance of Connection.



6
7
8
9
10
# File 'lib/bmo/gcm/connection.rb', line 6

def initialize(gateway_url, api_key)
  @gateway_url        = gateway_url
  @faraday_connection = Faraday::Connection.new(gateway_url)
  @api_key            = api_key
end

Instance Method Details

#connect(&block) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/bmo/gcm/connection.rb', line 12

def connect(&block)
  faraday_connection.post(gateway_url) do |request|
    request.headers.merge!(content_type: 'application/json',
                           authorization: "key=#{api_key}")
    yield request
  end
end