Class: Dor::Services::Client
- Inherits:
-
Object
- Object
- Dor::Services::Client
- Includes:
- Singleton
- Defined in:
- lib/dor/services/client.rb,
lib/dor/services/client/sdr.rb,
lib/dor/services/client/files.rb,
lib/dor/services/client/object.rb,
lib/dor/services/client/embargo.rb,
lib/dor/services/client/objects.rb,
lib/dor/services/client/version.rb,
lib/dor/services/client/metadata.rb,
lib/dor/services/client/workspace.rb,
lib/dor/services/client/collections.rb,
lib/dor/services/client/release_tags.rb,
lib/dor/services/client/object_version.rb,
lib/dor/services/client/versioned_service.rb,
lib/dor/services/client/error_faraday_middleware.rb,
lib/dor/services/client/response_error_formatter.rb
Defined Under Namespace
Classes: Collections, ConnectionFailed, Embargo, Error, ErrorFaradayMiddleware, Files, MalformedResponse, Metadata, NotFoundResponse, Object, ObjectVersion, Objects, ReleaseTags, ResponseErrorFormatter, SDR, UnexpectedResponse, VersionedService, Workspace
Constant Summary collapse
- DEFAULT_VERSION =
'v1'- VERSION =
'2.5.0'
Instance Attribute Summary collapse
-
#connection ⇒ Object
writeonly
Sets the attribute connection.
-
#token ⇒ Object
writeonly
Sets the attribute token.
-
#token_header ⇒ Object
writeonly
Sets the attribute token_header.
-
#url ⇒ Object
writeonly
Sets the attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#object(object_identifier) ⇒ Dor::Services::Client::Object
An instance of the ‘Client::Object` class.
-
#objects ⇒ Dor::Services::Client::Objects
An instance of the ‘Client::Objects` class.
Instance Attribute Details
#connection=(value) ⇒ Object
Sets the attribute connection
88 89 90 |
# File 'lib/dor/services/client.rb', line 88 def connection=(value) @connection = value end |
#token=(value) ⇒ Object
Sets the attribute token
88 89 90 |
# File 'lib/dor/services/client.rb', line 88 def token=(value) @token = value end |
#token_header=(value) ⇒ Object
Sets the attribute token_header
88 89 90 |
# File 'lib/dor/services/client.rb', line 88 def token_header=(value) @token_header = value end |
#url=(value) ⇒ Object
Sets the attribute url
88 89 90 |
# File 'lib/dor/services/client.rb', line 88 def url=(value) @url = value end |
Class Method Details
.configure(url:, token: nil, token_header: 'Authorization') ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/dor/services/client.rb', line 74 def configure(url:, token: nil, token_header: 'Authorization') instance.url = url instance.token = token instance.token_header = token_header # Force connection to be re-established when `.configure` is called instance.connection = nil self end |
Instance Method Details
#object(object_identifier) ⇒ Dor::Services::Client::Object
Returns an instance of the ‘Client::Object` class.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dor/services/client.rb', line 53 def object(object_identifier) raise ArgumentError, '`object_identifier` argument cannot be `nil` in call to `#object(object_identifier)' if object_identifier.nil? # Return memoized object instance if object identifier value is the same # This allows us to test the client more easily in downstream codebases, # opening up stubbing without requiring `any_instance_of` return @object if @object&.object_identifier == object_identifier @object = Object.new(connection: connection, version: DEFAULT_VERSION, object_identifier: object_identifier) end |
#objects ⇒ Dor::Services::Client::Objects
Returns an instance of the ‘Client::Objects` class.
65 66 67 |
# File 'lib/dor/services/client.rb', line 65 def objects @objects ||= Objects.new(connection: connection, version: DEFAULT_VERSION) end |