Class: Preservation::Client
- Inherits:
-
Object
- Object
- Preservation::Client
- Includes:
- Singleton
- Defined in:
- lib/preservation/client.rb,
lib/preservation/client/catalog.rb,
lib/preservation/client/objects.rb,
lib/preservation/client/version.rb,
lib/preservation/client/versioned_api_service.rb,
lib/preservation/client/error_faraday_middleware.rb,
lib/preservation/client/response_error_formatter.rb
Overview
REST API client wrapper for PreservationCatalog with error handling
Defined Under Namespace
Classes: Catalog, ConflictError, ConnectionFailedError, Error, ErrorFaradayMiddleware, LockedError, NotFoundError, Objects, ResponseErrorFormatter, UnexpectedResponseError, VersionedApiService
Constant Summary collapse
- DEFAULT_API_VERSION =
'v1'
- DEFAULT_TIMEOUT =
300
- TOKEN_HEADER =
'Authorization'
- VERSION =
'7.0.1'
Instance Attribute Summary collapse
-
#connection ⇒ Object
writeonly
Sets the attribute connection.
-
#read_timeout ⇒ Object
writeonly
Sets the attribute read_timeout.
-
#token ⇒ Object
writeonly
Sets the attribute token.
-
#url ⇒ Object
writeonly
Sets the attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#catalog ⇒ Preservation::Client::Catalog
An instance of the ‘Client::Catalog` class.
-
#objects ⇒ Preservation::Client::Objects
An instance of the ‘Client::Objects` class.
Instance Attribute Details
#connection=(value) ⇒ Object
Sets the attribute connection
71 72 73 |
# File 'lib/preservation/client.rb', line 71 def connection=(value) @connection = value end |
#read_timeout=(value) ⇒ Object
Sets the attribute read_timeout
71 72 73 |
# File 'lib/preservation/client.rb', line 71 def read_timeout=(value) @read_timeout = value end |
#token=(value) ⇒ Object
Sets the attribute token
71 72 73 |
# File 'lib/preservation/client.rb', line 71 def token=(value) @token = value end |
#url=(value) ⇒ Object
Sets the attribute url
71 72 73 |
# File 'lib/preservation/client.rb', line 71 def url=(value) @url = value end |
Class Method Details
.configure(url:, token:, read_timeout: DEFAULT_TIMEOUT) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/preservation/client.rb', line 57 def configure(url:, token:, read_timeout: DEFAULT_TIMEOUT) instance.url = url instance.token = token instance.read_timeout = read_timeout # Force connection to be re-established when `.configure` is called instance.connection = nil self end |
Instance Method Details
#catalog ⇒ Preservation::Client::Catalog
Returns an instance of the ‘Client::Catalog` class.
49 50 51 |
# File 'lib/preservation/client.rb', line 49 def catalog @catalog ||= Catalog.new(connection: connection, api_version: DEFAULT_API_VERSION) end |
#objects ⇒ Preservation::Client::Objects
Returns an instance of the ‘Client::Objects` class.
44 45 46 |
# File 'lib/preservation/client.rb', line 44 def objects @objects ||= Objects.new(connection: connection, api_version: DEFAULT_API_VERSION) end |