Class: Pushbots::Request
- Inherits:
-
Object
- Object
- Pushbots::Request
- Defined in:
- lib/pushbots/request.rb
Overview
Request class
Class Method Summary collapse
- .delete(body) ⇒ Object
- .header_base ⇒ Object
- .header_info(token) ⇒ Object
- .header_push ⇒ Object
- .info(token) ⇒ Object
- .register(body) ⇒ Object
- .register_batch(body) ⇒ Object
- .send(type, body) ⇒ Object
Class Method Details
.delete(body) ⇒ Object
24 25 26 27 |
# File 'lib/pushbots/request.rb', line 24 def self.delete(body) url = 'https://api.pushbots.com/deviceToken/del' HTTP.headers(header_base).put(url, json: body) end |
.header_base ⇒ Object
35 36 37 38 39 40 |
# File 'lib/pushbots/request.rb', line 35 def self.header_base { :'X-PushBots-AppID' => Config.config.application_id, :'Content-Type' => 'application/json' } end |
.header_info(token) ⇒ Object
48 49 50 51 52 |
# File 'lib/pushbots/request.rb', line 48 def self.header_info(token) { token: token } end |
.header_push ⇒ Object
42 43 44 45 46 |
# File 'lib/pushbots/request.rb', line 42 def self.header_push { :'X-PushBots-Secret' => Config.config.application_secret } end |
.info(token) ⇒ Object
13 14 15 16 17 |
# File 'lib/pushbots/request.rb', line 13 def self.info(token) url = 'https://api.pushbots.com/deviceToken/one' header = header_base.merge(header_info(token)) HTTP.headers(header).get(url) end |
.register(body) ⇒ Object
19 20 21 22 |
# File 'lib/pushbots/request.rb', line 19 def self.register(body) url = 'https://api.pushbots.com/deviceToken' HTTP.headers(header_base).put(url, json: body) end |
.register_batch(body) ⇒ Object
29 30 31 32 33 |
# File 'lib/pushbots/request.rb', line 29 def self.register_batch(body) url = 'https://api.pushbots.com/deviceToken/batch' header = header_base.merge(header_push) HTTP.headers(header).put(url, json: body) end |
.send(type, body) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/pushbots/request.rb', line 6 def self.send(type, body) url = "https://api.pushbots.com/push/#{type}" header = header_base.merge(header_push) response = HTTP.headers(header).post(url, json: body) Response.new(response) end |