class Maia::FCM::Connection
Public Class Methods
new(project, token)
click to toggle source
# File lib/maia/fcm/connection.rb, line 4 def initialize(project, token) @project = project @token = token end
Public Instance Methods
write(payload = {})
click to toggle source
# File lib/maia/fcm/connection.rb, line 9 def write(payload = {}) request = Net::HTTP::Post.new uri, headers request.body = payload http.request request end
Private Instance Methods
headers()
click to toggle source
# File lib/maia/fcm/connection.rb, line 20 def headers { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{@token}" } end
http()
click to toggle source
# File lib/maia/fcm/connection.rb, line 27 def http @_http ||= Net::HTTP.new(uri.host, uri.port).tap do |h| h.use_ssl = true end end
uri()
click to toggle source
# File lib/maia/fcm/connection.rb, line 16 def uri URI("https://fcm.googleapis.com/v1/projects/#{@project}/messages:send") end