Sha256: 4b16461798607568b9f030620aeaa56a3801d5de79e1d9f8240d4be5f003859d
Contents?: true
Size: 1.23 KB
Versions: 21
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module Dor module Services class Client # API calls that are about a repository objects class Objects < VersionedService # Creates a new object in DOR # @return [HashWithIndifferentAccess] the response, which includes a :pid def register(params:) json = register_response(params: params) JSON.parse(json).with_indifferent_access end private # make the registration request to the server # @param params [Hash] optional params (see dor-services-app) # @raises [UnexpectedResponse] on an unsuccessful response from the server # @returns [String] the raw JSON from the server def register_response(params:) 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.body = params.to_json end return resp.body if resp.success? raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})" end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems
Version | Path |
---|---|
dor-services-client-1.0.0 | lib/dor/services/client/objects.rb |