Class: Agilibox::FCM::Notifier

Inherits:
Service
  • Object
show all
Defined in:
app/libs/agilibox/fcm/notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to:, title: nil, body:, badge: 0, sound: "default", data: {}) ⇒ Notifier

rubocop:disable Metrics/ParameterLists



5
6
7
8
9
10
11
12
13
# File 'app/libs/agilibox/fcm/notifier.rb', line 5

def initialize(to:, title: nil, body:, badge: 0, sound: "default", data: {})
  super()
  @to    = to
  @title = title
  @body  = body
  @badge = badge
  @sound = sound
  @data  = data
end

Instance Attribute Details

#badgeObject (readonly)

Returns the value of attribute badge.



2
3
4
# File 'app/libs/agilibox/fcm/notifier.rb', line 2

def badge
  @badge
end

#bodyObject (readonly)

Returns the value of attribute body.



2
3
4
# File 'app/libs/agilibox/fcm/notifier.rb', line 2

def body
  @body
end

#dataObject (readonly)

Returns the value of attribute data.



2
3
4
# File 'app/libs/agilibox/fcm/notifier.rb', line 2

def data
  @data
end

#soundObject (readonly)

Returns the value of attribute sound.



2
3
4
# File 'app/libs/agilibox/fcm/notifier.rb', line 2

def sound
  @sound
end

#titleObject (readonly)

Returns the value of attribute title.



2
3
4
# File 'app/libs/agilibox/fcm/notifier.rb', line 2

def title
  @title
end

#toObject (readonly)

Returns the value of attribute to.



2
3
4
# File 'app/libs/agilibox/fcm/notifier.rb', line 2

def to
  @to
end

Instance Method Details

#callObject

rubocop:enable Metrics/ParameterLists



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/libs/agilibox/fcm/notifier.rb', line 16

def call
  Agilibox::FCM::Request.call(
    :to => to,
    :notification => {
      :title => title,
      :body  => body,
      :badge => badge,
      :sound => sound,
    },
    :data => data,
  )
end