panoptes-client 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9093577357d957e9de91f8cf05a4bc4a545ae13
4
- data.tar.gz: f9be472c1e3558ef8d8f2d380f715b22a968fd0b
3
+ metadata.gz: e96fa7b8f5e137b8dc426c6f119587471fcc9189
4
+ data.tar.gz: 41794d9a41090bf7fc1c3d87ef8e46ffadd5e0fe
5
5
  SHA512:
6
- metadata.gz: 0adbd891e129ceacbc55b061e65cc5c63d532e0647d0fc6250c76d52a2a635c5aa7431ca5994bf34b1220417f530288306ccc3f25dcbedb92d3ed0dee522eec8
7
- data.tar.gz: 70b9a45e53f6788fcfb47948800cd4861cd0996935036012a031bb8fda2cb90c3d44f64e76a801f0de0973b910fe89e2d9cae8be558e84d20ab121be0b966d9d
6
+ metadata.gz: fa3d24cb731c90c486c313c46c33d0ae4f8ba833e995c6515bfd1035e9477cc358ae4002d7380d6bf2d7060bcd13b02706fda799982196f5cddda5d3524ebf40
7
+ data.tar.gz: ccae89f05b4129fac56897aa0a823d9d23e4e2670629d7b24ad3dad3de9c709becfda07b2829eb46f3152a71a04e4c49ba2d16ec62b8c3836bfc979f1e88cf29
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # 0.2.6
2
+
3
+ * Add `client.workflow` to fetch a specific workflow.
4
+ * Add `client.create_workflow`
5
+ * Add `client.subjects` to fetch a list of subjects given filters
6
+ * Add `client.subject_set` to fetch a specific subject set
7
+ * Add `client.create_subject_set`
8
+ * Add `client.update_subject_set`
9
+ * Add `client.add_subjects_to_subject_set`
10
+ * ServerErrors will now have the error message in the exception message
11
+
1
12
  # 0.2.5
2
13
 
3
14
  * Add `client.remove_user_from_user_group` that can be used by group admins to remove some other user from a group.
@@ -6,7 +6,9 @@ require "panoptes/client/version"
6
6
  require "panoptes/client/me"
7
7
  require "panoptes/client/projects"
8
8
  require "panoptes/client/subjects"
9
+ require "panoptes/client/subject_sets"
9
10
  require "panoptes/client/user_groups"
11
+ require "panoptes/client/workflows"
10
12
 
11
13
  module Panoptes
12
14
  class Client
@@ -18,7 +20,9 @@ module Panoptes
18
20
  include Panoptes::Client::Me
19
21
  include Panoptes::Client::Projects
20
22
  include Panoptes::Client::Subjects
23
+ include Panoptes::Client::SubjectSets
21
24
  include Panoptes::Client::UserGroups
25
+ include Panoptes::Client::Workflows
22
26
 
23
27
  # A client is the main interface to the API.
24
28
  #
@@ -53,13 +57,19 @@ module Panoptes
53
57
  handle_response(response)
54
58
  end
55
59
 
56
- def put(path, body = {})
57
- response = conn.put("/api" + path, body)
60
+ def put(path, body = {}, etag: nil)
61
+ headers = {}
62
+ headers["If-Match"] = etag if etag
63
+
64
+ response = conn.put("/api" + path, body, headers)
58
65
  handle_response(response)
59
66
  end
60
67
 
61
- def patch(path, body = {})
62
- response = conn.patch("/api" + path, body)
68
+ def patch(path, body = {}, etag: nil)
69
+ headers = {}
70
+ headers["If-Match"] = etag if etag
71
+
72
+ response = conn.patch("/api" + path, body, headers)
63
73
  handle_response(response)
64
74
  end
65
75
 
@@ -101,7 +111,7 @@ module Panoptes
101
111
  when 404
102
112
  raise ResourceNotFound, status: response.status, body: response.body
103
113
  when 400..600
104
- raise ServerError.new(response)
114
+ raise ServerError.new(response.body)
105
115
  else
106
116
  response.body
107
117
  end
@@ -0,0 +1,28 @@
1
+ module Panoptes
2
+ class Client
3
+ module SubjectSets
4
+ def subject_set(subject_set_id)
5
+ response = get("/subject_sets/#{subject_set_id}")
6
+ response.fetch("subject_sets").find {|i| i.fetch("id").to_s == subject_set_id.to_s }
7
+ end
8
+
9
+ def create_subject_set(attributes)
10
+ response = post("/subject_sets", subject_sets: attributes)
11
+ response.fetch("subject_sets").first
12
+ end
13
+
14
+ def update_subject_set(subject_set_id, attributes)
15
+ response = conn.get("/api/subject_sets/#{subject_set_id}")
16
+ etag = response.headers["ETag"]
17
+
18
+ response = put("/subject_sets/#{subject_set_id}", {subject_sets: attributes}, etag: etag)
19
+ response.fetch("subject_sets").first
20
+ end
21
+
22
+ def add_subjects_to_subject_set(subject_set_id, subject_ids)
23
+ response = post("/subject_sets/#{subject_set_id}/links/subjects", subjects: subject_ids)
24
+ true
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,6 +1,18 @@
1
1
  module Panoptes
2
2
  class Client
3
3
  module Subjects
4
+ # Get list of subjects
5
+ #
6
+ # @param subject_set_id [Integer] filter by subject set
7
+ # @return list of subjects
8
+ def subjects(subject_set_id:)
9
+ query = {}
10
+ query[:subject_set_id] = subject_set_id
11
+
12
+ response = get("/subjects", query)
13
+ response.fetch("subjects")
14
+ end
15
+
4
16
  # Retire a subject for a workflow
5
17
  #
6
18
  # @todo Add this endpoint to the Apiary docs and add a see-reference here.
@@ -1,5 +1,5 @@
1
1
  module Panoptes
2
2
  class Client
3
- VERSION = "0.2.5"
3
+ VERSION = "0.2.6"
4
4
  end
5
5
  end
@@ -0,0 +1,15 @@
1
+ module Panoptes
2
+ class Client
3
+ module Workflows
4
+ def workflow(workflow_id)
5
+ response = get("/workflows/#{workflow_id}")
6
+ response.fetch("workflows").find {|i| i.fetch("id").to_s == workflow_id.to_s }
7
+ end
8
+
9
+ def create_workflow(attributes)
10
+ response = post("/workflows", workflows: attributes)
11
+ response.fetch("workflows").first
12
+ end
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panoptes-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -116,9 +116,11 @@ files:
116
116
  - lib/panoptes/client.rb
117
117
  - lib/panoptes/client/me.rb
118
118
  - lib/panoptes/client/projects.rb
119
+ - lib/panoptes/client/subject_sets.rb
119
120
  - lib/panoptes/client/subjects.rb
120
121
  - lib/panoptes/client/user_groups.rb
121
122
  - lib/panoptes/client/version.rb
123
+ - lib/panoptes/client/workflows.rb
122
124
  - panoptes-client.gemspec
123
125
  homepage: https://github.com/zooniverse/panoptes-client.rb
124
126
  licenses: