Class: Maia::FCM::Gateway

Inherits:
Object
  • Object
show all
Defined in:
lib/maia/fcm/gateway.rb

Instance Method Summary collapse

Constructor Details

#initialize(auth = Maia::FCM::Credentials.new) ⇒ Gateway

Returns a new instance of Gateway.



4
5
6
# File 'lib/maia/fcm/gateway.rb', line 4

def initialize(auth = Maia::FCM::Credentials.new)
  @auth = auth
end

Instance Method Details

#deliver(payload) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/maia/fcm/gateway.rb', line 8

def deliver(payload)
  response = Maia::FCM::Response.new connection.write(payload)

  if response.fail?
    error = response.error
    error.payload = payload
    raise error
  end

  response
end

#serialize(message, target) ⇒ Object



20
21
22
# File 'lib/maia/fcm/gateway.rb', line 20

def serialize(message, target)
  Maia::FCM::Serializer.new(message, target).to_json
end