def make
uri = URI.parse([Point.site, @path].join('/'))
http_request = http_class.new(uri.request_uri)
http_request.basic_auth(Point.username, Point.apitoken)
http_request.add_field("Accept", "application/json")
http_request.add_field("Content-type", "application/json")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
data = self.data.to_json if self.data.is_a?(Hash) && self.data.respond_to?(:to_json)
http_result = http.request(http_request, data)
@output = http_result.body
@success = case http_result
when Net::HTTPSuccess
true
when Net::HTTPServiceUnavailable
raise Point::Errors::ServiceUnavailable
when Net::HTTPForbidden, Net::HTTPUnauthorized
raise Point::Errors::AccessDenied, "Access Denied for '#{Point.username}'"
when Net::HTTPNotFound
raise Point::Errors::CommunicationError, "Not Found at #{uri.to_s}"
when Net::HTTPPaymentRequired
raise Point::Errors::AccessDenied, JSON.parse(output)['message']
when Net::HTTPClientError
false
else
raise Point::Errors::CommunicationError, http_result.body
end
self
end