class Crusade::GCM::Connection

Attributes

configuration[RW]

Public Class Methods

new(configuration) click to toggle source
# File lib/crusade/gcm/connection.rb, line 10
def initialize(configuration)
  self.configuration = configuration
end

Public Instance Methods

send(payload, access_token) click to toggle source
# File lib/crusade/gcm/connection.rb, line 14
def send(payload, access_token)
  connection.post do |req|
    req.url '/gcm_for_chrome/v1/messages'
    req.headers['Content-Type'] = 'application/json'
    req.headers['Authorization'] = "Bearer #{access_token}"
    req.body = payload
  end
end

Private Instance Methods

connection() click to toggle source
# File lib/crusade/gcm/connection.rb, line 27
def connection
  Faraday.new(:url => 'https://www.googleapis.com') do |faraday|
    faraday.use Faraday::Response::Logger, logger
    faraday.adapter  Faraday.default_adapter
  end
end
logger() click to toggle source
# File lib/crusade/gcm/connection.rb, line 34
def logger
  Crusade::Logger.logger
end