Class: BupBupRB::Resource::Device
- Inherits:
-
Object
- Object
- BupBupRB::Resource::Device
- Defined in:
- lib/bup_bup_rb/resources/device.rb
Class Method Summary collapse
Class Method Details
.registration(uuid, platform, gcm_token) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bup_bup_rb/resources/device.rb', line 4 def self.registration(uuid, platform, gcm_token) = Time.now.getutc.to_i signature = Digest::MD5.hexdigest("#{ }-#{ config.app_secret }") response = connection.post do |req| req.url '/api/devices' req.body = '{ "uuid": uuid, "platform": platform, "gcm_token": gcm_token }' req.headers['Content-Type'] = 'application/json' req.headers['Authorization-Signature'] = signature req.headers['Authorization-App-Id'] = config.app_id req.headers['Authorization-Timestamp'] = .to_s end result = JSON.parse(response.body) return result["result"] if result["status"] raise BupbupError, result["message"] end |
.remove(key) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bup_bup_rb/resources/device.rb', line 22 def self.remove(key) = Time.now.getutc.to_i signature = Digest::MD5.hexdigest("#{ }-#{ config.app_secret }") response = connection.delete do |req| req.url "/api/devices/#{ key }" req.headers['Content-Type'] = 'application/json' req.headers['Authorization-Signature'] = signature req.headers['Authorization-App-Id'] = config.app_id req.headers['Authorization-Timestamp'] = .to_s end result = JSON.parse(response.body) return result["result"] if result["status"] raise BupbupError, result["message"] end |