Class: Maia::FCM::Serializer

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

Instance Method Summary collapse

Constructor Details

#initialize(message, target) ⇒ Serializer

Returns a new instance of Serializer.



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

def initialize(message, target)
  @message = message
  @target  = target
end

Instance Method Details

#to_hObject



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

def to_h
  {
    message: {
      data: @message.data.to_h,
      notification: notification.to_h,
      android: android.to_h,
      apns: apns.to_h
    }.merge(@target.to_h)
  }
end

#to_jsonObject



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

def to_json
  to_h.to_json
end