Class: HeyYouFcmPush::MessageObject::WebPushConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/hey_you_fcm_push/message_object/web_push_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers: nil, data: nil, notification: nil, fcm_options: nil) ⇒ WebPushConfig

Returns a new instance of WebPushConfig.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hey_you_fcm_push/message_object/web_push_config.rb', line 6

def initialize(headers: nil, data: nil, notification: nil, fcm_options: nil)
  notification = notification&.transform_keys(&:to_sym)
  fcm_options = fcm_options&.transform_keys(&:to_sym)

  hash = {
    headers: headers,
    data: data,
    notification: (Notification.new(**notification).to_h if notification),
  }

  if fcm_options
    hash.merge(
      fcm_options: FcmOptions.new(analytics_label: fcm_options[:analytics_label], link: fcm_options[:link]).to_h
    )
  end

  @to_h = hash.compact
end

Instance Attribute Details

#to_hObject (readonly)

Returns the value of attribute to_h.



4
5
6
# File 'lib/hey_you_fcm_push/message_object/web_push_config.rb', line 4

def to_h
  @to_h
end