Sha256: 0bc1e931217aa013c372d8ae0a69356a89ffb8ad18e972915c4ea8a2b6a13a17

Contents?: true

Size: 704 Bytes

Versions: 1

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

module Dor
  module Services
    class Client
      # API calls relating to files
      class Files < VersionedService
        def retrieve(object:, filename:)
          resp = connection.get do |req|
            req.url "#{version}/objects/#{object}/contents/#{filename}"
          end
          return unless resp.success?

          resp.body
        end

        def list(object:)
          resp = connection.get do |req|
            req.url "#{version}/objects/#{object}/contents"
          end
          return [] unless resp.success?

          json = JSON.parse(resp.body)
          json['items'].map { |item| item['name'] }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dor-services-client-0.4.0 lib/dor/services/client/files.rb