Class: Google::Apis::Messages::Message

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) ⇒ Message

Returns a new instance of Message.



9
10
11
# File 'lib/google/apis/messages/classes.rb', line 9

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

Instance Attribute Details

#message_objectObject

Returns the value of attribute message_object.



7
8
9
# File 'lib/google/apis/messages/classes.rb', line 7

def message_object
  @message_object
end

Instance Method Details

#initialize_build(**args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/google/apis/messages/classes.rb', line 13

def initialize_build(**args)
  if args[:notification]
    notification = Notification.new(
      title: args[:notification][:title],
      body: args[:notification][:body]
    )
  end

  message_object_args = {
    topic: args[:topic],
    data: args[:payload]
  }

  if notification
    message_object_args[:notification] = notification
  end

  if args.key?(:webpush) && args[:webpush][:icon]
    message_object_args[:webpush] = Webpush.new(args[:webpush])
  end

  @message_object = MessageObject.new(message_object_args)
end

#update!(**args) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/google/apis/messages/classes.rb', line 37

def update!(**args)
  if args.key?(:message_object)
    @message_object = args[:message_object]
  else
    initialize_build(**args)
  end
end