Class: Talis::Resource
- Includes:
- HTTParty
- Defined in:
- lib/talis/resource.rb
Overview
Extend this class when in order to interact with Talis HTTP APIs. Each sub class should set base_uri to whatever Talis primitive it needs to talk to.
Direct Known Subclasses
Analytics::Event, Authentication::PublicKey, Authentication::Token, Bibliography::EBook, Bibliography::Manifestation, Bibliography::Work, Feeds::Annotation, Feeds::Feed, Hierarchy::Asset, Hierarchy::Node, User
Class Method Summary collapse
Class Method Details
.handle_response(response, expected_status_code = 200) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/talis/resource.rb', line 16 def handle_response(response, expected_status_code = 200) if response.code == expected_status_code response.parsed_response elsif response.code >= 400 && response.code < 500 build_client_error(response) elsif response.code >= 500 raise Talis::ServerError else raise Talis::ServerCommunicationError end end |
.new_req_id ⇒ Object
28 29 30 |
# File 'lib/talis/resource.rb', line 28 def new_req_id SecureRandom.hex(13) end |