Class: MaisPersonClient
- Inherits:
-
Object
- Object
- MaisPersonClient
- Includes:
- Singleton
- Defined in:
- lib/mais_person_client.rb,
lib/mais_person_client/person.rb,
lib/mais_person_client/version.rb,
lib/mais_person_client/affiliations.rb,
lib/mais_person_client/unexpected_response.rb
Overview
Client for interacting with MAIS's Person API
Defined Under Namespace
Classes: Affiliations, Person, UnexpectedResponse
Constant Summary collapse
- ALLOWED_TAGS =
Allowed tag values that can be requested from the API
%w[ name title email url location affiliation identifier privgroup profile visibility ].freeze
- VERSION =
'1.0.0'
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
-
#fetch_user(sunetid, tags: nil) ⇒ <Person>?
Fetch a user details Fetch user details.
-
#fetch_user_affiliations(sunetid) ⇒ Array<Affiliation>?
Fetch a user's affiliations.
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
55 56 57 |
# File 'lib/mais_person_client.rb', line 55 def config @config end |
Class Method Details
.configure(api_key:, api_cert:, base_url:, user_agent: 'stanford-library') ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mais_person_client.rb', line 39 def configure(api_key:, api_cert:, base_url:, user_agent: 'stanford-library') # rubocop:disable Style/OpenStructUse instance.config = OpenStruct.new( api_key:, api_cert:, base_url:, user_agent: ) # rubocop:enable Style/OpenStructUse self end |
Instance Method Details
#fetch_user(sunetid, tags: nil) ⇒ <Person>?
Fetch a user details
Fetch user details. Optionally accepts tags: which may be a String (comma
separated) or an Array of tag names. Only tags listed in ALLOWED_TAGS are
permitted; otherwise an ArgumentError is raised.
63 64 65 66 67 |
# File 'lib/mais_person_client.rb', line 63 def fetch_user(sunetid, tags: nil) params = build_tag_params() get_response("/doc/person/#{sunetid}", allow404: true, params: params) end |
#fetch_user_affiliations(sunetid) ⇒ Array<Affiliation>?
Fetch a user's affiliations
72 73 74 |
# File 'lib/mais_person_client.rb', line 72 def fetch_user_affiliations(sunetid) get_response("/doc/person/#{sunetid}/affiliation", allow404: true) end |