Sha256: e9133f3addfc8fba70ab25b9456e4cd446134dc39f56dc70a9e2d59894f52e1f
Contents?: true
Size: 1.21 KB
Versions: 5
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require 'deprecation' module Dor module Services class Client # API calls that are about a repository objects class Objects < VersionedService # Creates a new object in DOR # @param params [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAdminPolicy] # @param assign_doi [Boolean] # @param [boolean] validate validate the response object # @return [Cocina::Models::DROWithMetadata,Cocina::Models::CollectionWithMetadata,Cocina::Models::AdminPolicyWithMetadata] the returned model def register(params:, assign_doi: false, validate: false) resp = connection.post do |req| req.url "#{api_version}/objects" req.headers['Content-Type'] = 'application/json' # asking the service to return JSON (else it'll be plain text) req.headers['Accept'] = 'application/json' req.params[:assign_doi] = true if assign_doi req.body = params.to_json end raise_exception_based_on_response!(resp) unless resp.success? build_cocina_from_response(resp, validate: validate) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems