4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/bup_bup_rb/resources/notification.rb', line 4
def self.send(ids, message)
timestamp = Time.now.getutc.to_i
signature = Digest::MD5.hexdigest("#{ timestamp }-#{ config.app_secret }")
response = connection.post do |req|
req.url '/api/notifications'
req.body = '{ "device_ids": ids, "message": message }'
req.['Content-Type'] = 'application/json'
req.['Authorization-Signature'] = signature
req.['Authorization-App-Id'] = config.app_id
req.['Authorization-Timestamp'] = timestamp.to_s
end
result = JSON.parse(response.body)
return result["status"] if result["status"]
raise BupbupError, result["message"]
end
|