Class: Dor::Services::Client::ReleaseTags
- Inherits:
-
VersionedService
- Object
- VersionedService
- Dor::Services::Client::ReleaseTags
- Defined in:
- lib/dor/services/client/release_tags.rb
Overview
Interact with release tags endpoint for a given object
Constant Summary
Constants inherited from VersionedService
VersionedService::EXCEPTION_CLASS, VersionedService::JSON_API_MIME_TYPE
Instance Method Summary collapse
-
#create(tag:) ⇒ Boolean
Create a release tag for an object.
-
#initialize(connection:, version:, object_identifier:) ⇒ ReleaseTags
constructor
A new instance of ReleaseTags.
-
#list ⇒ Array<Cocina::Models::ReleaseTag>
List release tags for an object.
Methods inherited from VersionedService
#async_result, #with_querystring
Constructor Details
#initialize(connection:, version:, object_identifier:) ⇒ ReleaseTags
Returns a new instance of ReleaseTags.
9 10 11 12 |
# File 'lib/dor/services/client/release_tags.rb', line 9 def initialize(connection:, version:, object_identifier:) super(connection: connection, version: version) @object_identifier = object_identifier end |
Instance Method Details
#create(tag:) ⇒ Boolean
Create a release tag for an object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dor/services/client/release_tags.rb', line 20 def create(tag:) resp = connection.post do |req| req.url "#{api_version}/objects/#{object_identifier}/release_tags" req.headers['Content-Type'] = 'application/json' req.body = tag.to_json end raise_exception_based_on_response!(resp, object_identifier) unless resp.success? true end |
#list ⇒ Array<Cocina::Models::ReleaseTag>
List release tags for an object
36 37 38 39 40 41 42 43 44 |
# File 'lib/dor/services/client/release_tags.rb', line 36 def list resp = connection.get do |req| req.url "#{api_version}/objects/#{object_identifier}/release_tags" end raise_exception_based_on_response!(resp, object_identifier) unless resp.success? JSON.parse(resp.body).map { |tag_data| Cocina::Models::ReleaseTag.new(tag_data) } end |