Module: Panoptes::Client::Subjects
- Included in:
- Panoptes::Client
- Defined in:
- lib/panoptes/client/subjects.rb
Instance Method Summary collapse
-
#retire_subject(workflow_id, subject_id, reason: nil) ⇒ Object
Retire a subject for a workflow.
-
#subject(subject_id, project_id: nil) ⇒ Object
Fetch a subject given filters (including permissions).
-
#subjects(subject_set_id: nil, workflow_id: nil) ⇒ Object
Get list of subjects.
Instance Method Details
#retire_subject(workflow_id, subject_id, reason: nil) ⇒ Object
TODO:
Add this endpoint to the Apiary docs and add a see-reference here.
Retire a subject for a workflow
44 45 46 47 48 49 50 |
# File 'lib/panoptes/client/subjects.rb', line 44 def retire_subject(workflow_id, subject_id, reason: nil) panoptes.post("/workflows/#{workflow_id}/retired_subjects", admin: true, subject_id: subject_id, retirement_reason: reason) true end |
#subject(subject_id, project_id: nil) ⇒ Object
Fetch a subject given filters (including permissions)
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/panoptes/client/subjects.rb', line 26 def subject(subject_id, project_id: nil) query = {} query[:project_id] = project_id if project_id response = panoptes.get("/subjects/#{subject_id}", query) if response.fetch('subjects', []).count > 1 raise StandardError, 'Unexpectedly many subjects returned' end response.fetch('subjects', []).fetch(0, nil) end |
#subjects(subject_set_id: nil, workflow_id: nil) ⇒ Object
Get list of subjects
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/panoptes/client/subjects.rb', line 10 def subjects(subject_set_id: nil, workflow_id: nil) query = {} query[:subject_set_id] = subject_set_id if subject_set_id query[:workflow_id] = workflow_id if workflow_id raise 'Must filter on at least one of subject_set_id, workflow_id' if query.empty? response = panoptes.paginate('/subjects', query) response.fetch('subjects') end |