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
36
37
38
39
40
41
42
43
44
45
46
47
# 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?(:android)
    message_object_args[:android] = args[:android]
  end

  if args.key?(:apns)
    message_object_args[:apns] = args[:apns]
  end

  if args.key?(:webpush)
    message_object_args[:webpush] = args[:webpush]
  end

  if args.key?(:extra)
    message_object_args[:extra] = args[:extra]
  end

  @message_object = MessageObject.new(message_object_args)
end

#update!(**args) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/google/apis/messages/classes.rb', line 49

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