module Dirigible::Request
Public Instance Methods
delete(path, options = {}, headers = {})
click to toggle source
# File lib/dirigible/request.rb, line 15 def delete(path, options = {}, headers = {}) request(:delete, path, options, headers) end
get(path, options = {}, headers = {})
click to toggle source
# File lib/dirigible/request.rb, line 3 def get(path, options = {}, headers = {}) request(:get, path, options, headers) end
post(path, options = {}, headers = {})
click to toggle source
# File lib/dirigible/request.rb, line 7 def post(path, options = {}, headers = {}) request(:post, path, options, headers) end
put(path, options = {}, headers = {})
click to toggle source
# File lib/dirigible/request.rb, line 11 def put(path, options = {}, headers = {}) request(:put, path, options, headers) end
Private Instance Methods
request(method, path, options, headers)
click to toggle source
Perform an HTTP request.
# File lib/dirigible/request.rb, line 21 def request(method, path, options, headers) headers.merge!({ 'User-Agent' => user_agent, 'Accept' => 'application/vnd.urbanairship+json; version=3;', }) response = connection.send(method) do |request| request.url("#{endpoint}#{path}/") if [:post, :put].member?(method) request.body = options.to_json else request.params.merge!(options) end request.headers.merge!(headers) end Utils.handle_api_error(response) unless (200..399).include?(response.status) Utils.parse_message(response) end