class Pushbots::Request

Request class

Public Class Methods

delete(body) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# File lib/pushbots/request.rb, line 48
def self.header_info(token)
  {
    token: token
  }
end
header_push() click to toggle source
# File lib/pushbots/request.rb, line 42
def self.header_push
  {
    :'X-PushBots-Secret' => Config.config.application_secret
  }
end
info(token) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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