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.



68
69
70
# File 'lib/google/apis/messages/classes.rb', line 68

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

Instance Attribute Details

#androidObject

Returns the value of attribute android.



64
65
66
# File 'lib/google/apis/messages/classes.rb', line 64

def android
  @android
end

#apnsObject

Returns the value of attribute apns.



65
66
67
# File 'lib/google/apis/messages/classes.rb', line 65

def apns
  @apns
end

#dataObject

Returns the value of attribute data.



63
64
65
# File 'lib/google/apis/messages/classes.rb', line 63

def data
  @data
end

#notificationObject

Returns the value of attribute notification.



62
63
64
# File 'lib/google/apis/messages/classes.rb', line 62

def notification
  @notification
end

#topicObject

Returns the value of attribute topic.



61
62
63
# File 'lib/google/apis/messages/classes.rb', line 61

def topic
  @topic
end

#webpushObject

Returns the value of attribute webpush.



66
67
68
# File 'lib/google/apis/messages/classes.rb', line 66

def webpush
  @webpush
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/google/apis/messages/classes.rb', line 73

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