Class: Spire::API::Notification
Instance Attribute Summary
Attributes inherited from Resource
#capabilities, #properties, #url
Instance Method Summary
collapse
Methods inherited from Resource
#[], #delete, #get, #initialize, #key, #media_type, #method_missing, #respond_to?, #schema, #update
included
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Spire::API::Resource
Instance Method Details
#devices ⇒ Object
93
94
95
|
# File 'lib/spire/api/notification.rb', line 93
def devices
@devices ||= {}
end
|
#devices! ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/spire/api/notification.rb', line 76
def devices!
response = request(:devices)
unless response.status == 200
raise "Error getting device list #{self.class.name}: (#{response.status}) #{response.body}"
end
response.data["devices"]
end
|
#register_device(device_token) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/spire/api/notification.rb', line 84
def register_device(device_token)
response = request(:register_device, :token => device_token)
unless response.status == 200
raise "Error adding device #{self.class.name}: (#{response.status}) #{response.body}"
end
token = response.data["token"]
devices[token] = response.data
end
|
#resource_name ⇒ Object
5
6
7
|
# File 'lib/spire/api/notification.rb', line 5
def resource_name
"notification"
end
|
#send_notification(options = {}) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/spire/api/notification.rb', line 68
def send_notification(options={})
response = request(:push, options)
unless response.status == 200
raise "Error sending push notification #{self.class.name}: (#{response.status}) #{response.body}"
end
response.data
end
|