Class: Panoptes::Client
- Inherits:
-
Object
- Object
- Panoptes::Client
- Includes:
- Cellect, Classifications, Collections, Comments, Discussions, Me, Projects, SubjectSets, Subjects, UserGroups, Workflows
- Defined in:
- lib/panoptes/client.rb,
lib/panoptes/client/me.rb,
lib/panoptes/client/cellect.rb,
lib/panoptes/client/version.rb,
lib/panoptes/client/comments.rb,
lib/panoptes/client/projects.rb,
lib/panoptes/client/subjects.rb,
lib/panoptes/client/workflows.rb,
lib/panoptes/client/collections.rb,
lib/panoptes/client/discussions.rb,
lib/panoptes/client/user_groups.rb,
lib/panoptes/client/subject_sets.rb,
lib/panoptes/client/classifications.rb
Direct Known Subclasses
Defined Under Namespace
Modules: Cellect, Classifications, Collections, Comments, Discussions, Me, Projects, SubjectSets, Subjects, UserGroups, Workflows Classes: ConnectionFailed, GenericError, NotLoggedIn, ResourceNotFound, ServerError
Constant Summary collapse
- VERSION =
"0.3.0".freeze
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#cellect ⇒ Object
readonly
Returns the value of attribute cellect.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#panoptes ⇒ Object
readonly
Returns the value of attribute panoptes.
-
#talk ⇒ Object
readonly
Returns the value of attribute talk.
Instance Method Summary collapse
- #current_user ⇒ Object
-
#initialize(env: :production, auth: {}, public_key_path: nil, params: nil) ⇒ Client
constructor
A new instance of Client.
- #jwt_signing_public_key ⇒ Object
- #panoptes_url ⇒ Object
- #talk_url ⇒ Object
Methods included from Cellect
#cellect_subjects, #cellect_workflows
Methods included from Classifications
Methods included from Collections
Methods included from Comments
Methods included from Discussions
Methods included from Workflows
Methods included from UserGroups
#create_user_group, #delete_user_group, #join_user_group, #remove_user_from_user_group, #user_groups
Methods included from SubjectSets
#add_subjects_to_subject_set, #create_subject_set, #subject_set, #update_subject_set
Methods included from Subjects
Methods included from Projects
#create_aggregations_export, #create_classifications_export, #create_subjects_export, #create_workflow_contents_export, #create_workflows_export, #projects
Methods included from Me
Constructor Details
#initialize(env: :production, auth: {}, public_key_path: nil, params: nil) ⇒ Client
Returns a new instance of Client.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/panoptes/client.rb', line 42 def initialize(env: :production, auth: {}, public_key_path: nil, params: nil) @env = env @auth = auth @public_key_path = public_key_path @panoptes = Panoptes::Endpoints::JsonApiEndpoint.new( auth: auth, url: panoptes_url, prefix: '/api', params: params ) @talk = Panoptes::Endpoints::JsonApiEndpoint.new( auth: auth, url: talk_url ) @cellect = Panoptes::Endpoints::JsonEndpoint.new( url: panoptes_url, prefix: '/cellect' ) end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
40 41 42 |
# File 'lib/panoptes/client.rb', line 40 def auth @auth end |
#cellect ⇒ Object (readonly)
Returns the value of attribute cellect.
40 41 42 |
# File 'lib/panoptes/client.rb', line 40 def cellect @cellect end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
40 41 42 |
# File 'lib/panoptes/client.rb', line 40 def env @env end |
#panoptes ⇒ Object (readonly)
Returns the value of attribute panoptes.
40 41 42 |
# File 'lib/panoptes/client.rb', line 40 def panoptes @panoptes end |
#talk ⇒ Object (readonly)
Returns the value of attribute talk.
40 41 42 |
# File 'lib/panoptes/client.rb', line 40 def talk @talk end |
Instance Method Details
#current_user ⇒ Object
57 58 59 60 61 62 |
# File 'lib/panoptes/client.rb', line 57 def current_user raise NotLoggedIn unless @auth[:token] payload, = JWT.decode @auth[:token], jwt_signing_public_key, algorithm: 'RS512' payload.fetch('data') end |
#jwt_signing_public_key ⇒ Object
64 65 66 |
# File 'lib/panoptes/client.rb', line 64 def jwt_signing_public_key @jwt_signing_public_key ||= OpenSSL::PKey::RSA.new(File.read(@public_key_path)) end |
#panoptes_url ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/panoptes/client.rb', line 68 def panoptes_url case env when :production, 'production'.freeze 'https://panoptes.zooniverse.org'.freeze else 'https://panoptes-staging.zooniverse.org'.freeze end end |
#talk_url ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/panoptes/client.rb', line 77 def talk_url case env when :production, 'production'.freeze 'https://talk.zooniverse.org'.freeze else 'https://talk-staging.zooniverse.org'.freeze end end |