class Moromi::Aws::Sns::Message::Fcm
Attributes
android_channel_id[R]
body[R]
body_loc_args[R]
body_loc_key[R]
click_action[R]
color[R]
icon[R]
sound[R]
tag[R]
title[R]
title_loc_args[R]
title_loc_key[R]
Public Class Methods
new(title: nil, body: nil, android_channel_id: nil, icon: nil, sound: nil, tag: nil, color: nil, click_action: nil, body_loc_key: nil, body_loc_args: nil, title_loc_key: nil, title_loc_args: nil, type: nil, custom_data: {})
click to toggle source
# File lib/moromi/aws/sns/message/fcm.rb, line 20 def initialize(title: nil, body: nil, android_channel_id: nil, icon: nil, sound: nil, tag: nil, color: nil, click_action: nil, body_loc_key: nil, body_loc_args: nil, title_loc_key: nil, title_loc_args: nil, type: nil, custom_data: {}) @title = title @body = body @android_channel_id = android_channel_id @icon = icon @sound = sound @tag = tag @color = color @click_action = click_action @body_loc_key = body_loc_key @body_loc_args = body_loc_args @title_loc_key = title_loc_key @title_loc_args = title_loc_args @type = type || self.class.name @custom_data = setup_initial_custom_data({type: @type}.merge(custom_data)) end
Public Instance Methods
to_data_hash()
click to toggle source
# File lib/moromi/aws/sns/message/fcm.rb, line 60 def to_data_hash base = { title: @title, body: @body, android_channel_id: @android_channel_id, icon: @icon, sound: @sound, tag: @tag, color: @color, click_action: @click_action, body_loc_key: @body_loc_key, body_loc_args: @body_loc_args, title_loc_key: @title_loc_key, title_loc_args: @title_loc_args, type: @type } flatten_hash(@custom_data).merge(base) end
to_hash()
click to toggle source
# File lib/moromi/aws/sns/message/fcm.rb, line 41 def to_hash { title: @title, body: @body, android_channel_id: @android_channel_id, icon: @icon, sound: @sound, tag: @tag, color: @color, click_action: @click_action, body_loc_key: @body_loc_key, body_loc_args: @body_loc_args, title_loc_key: @title_loc_key, title_loc_args: @title_loc_args, type: @type, custom_data: @custom_data } end
to_message_json()
click to toggle source
# File lib/moromi/aws/sns/message/fcm.rb, line 79 def to_message_json {data: to_data_hash}.to_json end
Private Instance Methods
flatten_hash(hash)
click to toggle source
# File lib/moromi/aws/sns/message/fcm.rb, line 89 def flatten_hash(hash) hash.each_with_object({}) do |(k, v), h| if v.is_a? Hash flatten_hash(v).map do |h_k, h_v| h["#{k}_#{h_k}".to_sym] = h_v end else h[k] = v end end end
setup_initial_custom_data(custom_data)
click to toggle source
# File lib/moromi/aws/sns/message/fcm.rb, line 85 def setup_initial_custom_data(custom_data) custom_data end