class Google::Apis::Messages::MessageObject

Attributes

android[RW]
apns[RW]
condition[RW]
data[RW]
fcm_options[RW]
notification[RW]
token[RW]
topic[RW]
webpush[RW]

Public Class Methods

new(**args) click to toggle source
# File lib/google/apis/messages/classes.rb, line 81
def initialize(**args)
  update!(**args)
end

Public Instance Methods

update!(**args) click to toggle source

Update properties of this object

# File lib/google/apis/messages/classes.rb, line 86
def update!(**args)
  @topic = args[:topic] if args.key?(:topic)
  @condition = args[:condition] if args.key?(:condition)
  @token = args[:token] if args.key?(:token)
  @notification = args[:notification] if args.key?(:notification)
  if args.key?(:data) && args[:data].is_a?(Hash)
    @data = { 'payload' => JSON.dump(args[:data]) }
  end

  if args.key?(:extra) && args[:extra].is_a?(Hash)
    args[:extra].each do |key, value|
      @data[key] = value.to_s
    end
  end

  @android = args[:android] if args.key?(:android)
  @apns = args[:apns] if args.key?(:apns)
  @webpush = args[:webpush] if args.key?(:webpush)
  @fcm_options = args[:fcm_options] if args.key?(:fcm_options)
end