Class: Google::Apis::Messages::MessageObject

Inherits:
Object
  • Object
show all
Includes:
Core::Hashable, Core::JsonObjectSupport
Defined in:
lib/google/apis/messages/classes.rb,
lib/google/apis/messages/representations.rb,
lib/google/apis/messages/representations.rb

Defined Under Namespace

Classes: Representation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ MessageObject

Returns a new instance of MessageObject.



79
80
81
# File 'lib/google/apis/messages/classes.rb', line 79

def initialize(**args)
  update!(**args)
end

Instance Attribute Details

#androidObject

Returns the value of attribute android.



74
75
76
# File 'lib/google/apis/messages/classes.rb', line 74

def android
  @android
end

#apnsObject

Returns the value of attribute apns.



75
76
77
# File 'lib/google/apis/messages/classes.rb', line 75

def apns
  @apns
end

#dataObject

Returns the value of attribute data.



73
74
75
# File 'lib/google/apis/messages/classes.rb', line 73

def data
  @data
end

#fcm_optionsObject

Returns the value of attribute fcm_options.



77
78
79
# File 'lib/google/apis/messages/classes.rb', line 77

def fcm_options
  @fcm_options
end

#notificationObject

Returns the value of attribute notification.



72
73
74
# File 'lib/google/apis/messages/classes.rb', line 72

def notification
  @notification
end

#tokenObject

Returns the value of attribute token.



71
72
73
# File 'lib/google/apis/messages/classes.rb', line 71

def token
  @token
end

#topicObject

Returns the value of attribute topic.



70
71
72
# File 'lib/google/apis/messages/classes.rb', line 70

def topic
  @topic
end

#webpushObject

Returns the value of attribute webpush.



76
77
78
# File 'lib/google/apis/messages/classes.rb', line 76

def webpush
  @webpush
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/google/apis/messages/classes.rb', line 84

def update!(**args)
  @topic = args[:topic] if args.key?(:topic)
  @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