lib/panoptes/client.rb in panoptes-client-0.2.5 vs lib/panoptes/client.rb in panoptes-client-0.2.6
- old
+ new
@@ -4,11 +4,13 @@
require "panoptes/client/version"
require "panoptes/client/me"
require "panoptes/client/projects"
require "panoptes/client/subjects"
+require "panoptes/client/subject_sets"
require "panoptes/client/user_groups"
+require "panoptes/client/workflows"
module Panoptes
class Client
class GenericError < StandardError; end
class ConnectionFailed < GenericError; end
@@ -16,11 +18,13 @@
class ServerError < GenericError; end
include Panoptes::Client::Me
include Panoptes::Client::Projects
include Panoptes::Client::Subjects
+ include Panoptes::Client::SubjectSets
include Panoptes::Client::UserGroups
+ include Panoptes::Client::Workflows
# A client is the main interface to the API.
#
# @param auth [Hash] Authentication details
# * either nothing,
@@ -51,17 +55,23 @@
def post(path, body = {})
response = conn.post("/api" + path, body)
handle_response(response)
end
- def put(path, body = {})
- response = conn.put("/api" + path, body)
+ def put(path, body = {}, etag: nil)
+ headers = {}
+ headers["If-Match"] = etag if etag
+
+ response = conn.put("/api" + path, body, headers)
handle_response(response)
end
- def patch(path, body = {})
- response = conn.patch("/api" + path, body)
+ def patch(path, body = {}, etag: nil)
+ headers = {}
+ headers["If-Match"] = etag if etag
+
+ response = conn.patch("/api" + path, body, headers)
handle_response(response)
end
def delete(path, query = {}, etag: nil)
headers = {}
@@ -99,10 +109,10 @@
def handle_response(response)
case response.status
when 404
raise ResourceNotFound, status: response.status, body: response.body
when 400..600
- raise ServerError.new(response)
+ raise ServerError.new(response.body)
else
response.body
end
end
end