Class: Moromi::Aws::Sns::Message::Fcm

Inherits:
Base
  • Object
show all
Defined in:
lib/moromi/aws/sns/message/fcm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, build_from_hash

Constructor Details

#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: {}) ⇒ Fcm

Returns a new instance of Fcm.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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

Instance Attribute Details

#android_channel_idObject (readonly)

Returns the value of attribute android_channel_id.



9
10
11
# File 'lib/moromi/aws/sns/message/fcm.rb', line 9

def android_channel_id
  @android_channel_id
end

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/moromi/aws/sns/message/fcm.rb', line 8

def body
  @body
end

#body_loc_argsObject (readonly)

Returns the value of attribute body_loc_args.



16
17
18
# File 'lib/moromi/aws/sns/message/fcm.rb', line 16

def body_loc_args
  @body_loc_args
end

#body_loc_keyObject (readonly)

Returns the value of attribute body_loc_key.



15
16
17
# File 'lib/moromi/aws/sns/message/fcm.rb', line 15

def body_loc_key
  @body_loc_key
end

#click_actionObject (readonly)

Returns the value of attribute click_action.



14
15
16
# File 'lib/moromi/aws/sns/message/fcm.rb', line 14

def click_action
  @click_action
end

#colorObject (readonly)

Returns the value of attribute color.



13
14
15
# File 'lib/moromi/aws/sns/message/fcm.rb', line 13

def color
  @color
end

#iconObject (readonly)

Returns the value of attribute icon.



10
11
12
# File 'lib/moromi/aws/sns/message/fcm.rb', line 10

def icon
  @icon
end

#soundObject (readonly)

Returns the value of attribute sound.



11
12
13
# File 'lib/moromi/aws/sns/message/fcm.rb', line 11

def sound
  @sound
end

#tagObject (readonly)

Returns the value of attribute tag.



12
13
14
# File 'lib/moromi/aws/sns/message/fcm.rb', line 12

def tag
  @tag
end

#titleObject (readonly)



7
8
9
# File 'lib/moromi/aws/sns/message/fcm.rb', line 7

def title
  @title
end

#title_loc_argsObject (readonly)

Returns the value of attribute title_loc_args.



18
19
20
# File 'lib/moromi/aws/sns/message/fcm.rb', line 18

def title_loc_args
  @title_loc_args
end

#title_loc_keyObject (readonly)

Returns the value of attribute title_loc_key.



17
18
19
# File 'lib/moromi/aws/sns/message/fcm.rb', line 17

def title_loc_key
  @title_loc_key
end

Instance Method Details

#to_hashObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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_jsonObject



60
61
62
63
64
# File 'lib/moromi/aws/sns/message/fcm.rb', line 60

def to_message_json
  notification = to_hash
  %i[custom_data type].each { |k| notification.delete(k) }
  {notification: notification, data: @custom_data}.to_json
end