Class: Pushr::MessageFcm

Inherits:
Message
  • Object
show all
Defined in:
lib/pushr/message_fcm.rb

Constant Summary collapse

POSTFIX =
'fcm'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#androidObject

Returns the value of attribute android.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def android
  @android
end

#apnsObject

Returns the value of attribute apns.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def apns
  @apns
end

#conditionObject

Returns the value of attribute condition.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def condition
  @condition
end

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def data
  @data
end

#fcm_optionsObject

Returns the value of attribute fcm_options.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def fcm_options
  @fcm_options
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def name
  @name
end

#notificationObject

Returns the value of attribute notification.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def notification
  @notification
end

#tokenObject

Returns the value of attribute token.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def token
  @token
end

#topicObject

Returns the value of attribute topic.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def topic
  @topic
end

#webpushObject

Returns the value of attribute webpush.



5
6
7
# File 'lib/pushr/message_fcm.rb', line 5

def webpush
  @webpush
end

Instance Method Details

#to_hashObject



44
45
46
47
48
49
# File 'lib/pushr/message_fcm.rb', line 44

def to_hash
  hsh = { type: self.class.to_s, app: app, name: name, data: data, notification: notification, android: android,
          webpush: webpush, apns: apns, fcm_options: fcm_options, token: token, topic: topic, condition: condition }
  hsh[Pushr::Core.external_id_tag] = external_id if external_id
  hsh
end

#to_messageObject

{

"name": string,
"data": {
  string: string,
  ...
},
"notification": {
  object(Notification)
},
"android": {
  object(AndroidConfig)
},
"webpush": {
  object(WebpushConfig)
},
"apns": {
  object(ApnsConfig)
},
"fcm_options": {
  object (FcmOptions)
},

// Union field target can be only one of the following:
"token": string,
"topic": string,
"condition": string
// End of list of possible types for union field target.

}



36
37
38
39
40
41
42
# File 'lib/pushr/message_fcm.rb', line 36

def to_message
  hsh = {}
  %w[name data notification android webpush apns fcm_options token topic condition].each do |variable|
    hsh[variable] = send(variable) if send(variable)
  end
  MultiJson.dump(message: hsh)
end