Class: IonicNotification::PushService

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/ionic_notification/push_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(notification) ⇒ PushService

Returns a new instance of PushService.



8
9
10
# File 'lib/ionic_notification/push_service.rb', line 8

def initialize(notification)
  @notification = notification
end

Instance Attribute Details

#body=(value) ⇒ Object

Sets the attribute body

Parameters:

  • value

    the value to set the attribute body to.



6
7
8
# File 'lib/ionic_notification/push_service.rb', line 6

def body=(value)
  @body = value
end

Instance Method Details

#notify!Object



12
13
14
15
# File 'lib/ionic_notification/push_service.rb', line 12

def notify!
  resp = self.class.post("/api/v1/push", payload)
  IonicNotification.store(sent_notification(resp))
end

#payloadObject



17
18
19
20
21
22
# File 'lib/ionic_notification/push_service.rb', line 17

def payload
  options = {}
  options.merge!(body: body).
    merge!(basic_auth: auth).
    merge!(headers: headers)
end