Sha256: 51ce5c3feb23190ea69c4b6a12358462dc7503cb9db850c3a7033bf6e607d6e2

Contents?: true

Size: 910 Bytes

Versions: 10

Compression:

Stored size: 910 Bytes

Contents

# frozen_string_literal: true

module AtlasRb
  class Work < Resource
    ROUTE = "/works/"

    def self.find(id)
      JSON.parse(connection({}).get(ROUTE + id)&.body)["work"]
    end

    def self.create(id)
      # params[:collection_id]
      JSON.parse(connection({ collection_id: id }).post(ROUTE)&.body)["work"]
    end

    def self.destroy(id)
      connection({}).delete(ROUTE + id)
    end

    def self.update(id, xml_path)
      payload = { binary: Faraday::Multipart::FilePart.new(File.open(xml_path),
                                                           "application/xml",
                                                           File.basename(xml_path)) }
      JSON.parse(multipart({}).patch(ROUTE + id, payload)&.body)
    end

    def self.mods(id)
      # optional second argument for pure json response?
      connection({}).get(ROUTE + id + '/mods.html')&.body
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
atlas_rb-0.0.41 lib/atlas_rb/work.rb
atlas_rb-0.0.40 lib/atlas_rb/work.rb
atlas_rb-0.0.39 lib/atlas_rb/work.rb
atlas_rb-0.0.38 lib/atlas_rb/work.rb
atlas_rb-0.0.37 lib/atlas_rb/work.rb
atlas_rb-0.0.36 lib/atlas_rb/work.rb
atlas_rb-0.0.35 lib/atlas_rb/work.rb
atlas_rb-0.0.34 lib/atlas_rb/work.rb
atlas_rb-0.0.33 lib/atlas_rb/work.rb
atlas_rb-0.0.32 lib/atlas_rb/work.rb