Sha256: 1537e0fbd545fc5fae705f9f501d6b52666e207a6c7c68c7ea20c37071be8162
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module ArchivesSpace class Client include Pagination include Task attr_accessor :token attr_reader :config NAME = "ArchivesSpaceClient" def initialize(config = Configuration.new) raise "Invalid configuration object" unless config.is_a? ArchivesSpace::Configuration @config = config @token = nil end def backend_version get "version" end def get(path, options = {}) request "GET", path, options end def post(path, payload, params = {}) request "POST", path, {body: payload, query: params} end def put(path, payload, params = {}) request "PUT", path, {body: payload, query: params} end def delete(path) request "DELETE", path end # Scoping requests def repository(id) if id.nil? use_global_repository return end begin Integer(id) rescue raise RepositoryIdError, "Invalid Repository id: #{id}" end @config.base_repo = "repositories/#{id}" end def use_global_repository @config.base_repo = "" end private def request(method, path, options = {}) sleep config.throttle options[:headers] = {"X-ArchivesSpace-Session" => token} if token result = Request.new(config, method, path, options).execute Response.new result end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
archivesspace-client-0.4.0 | lib/archivesspace/client/client.rb |
archivesspace-client-0.3.0 | lib/archivesspace/client/client.rb |