Class: AtlasRb::Resource

Inherits:
Object
  • Object
show all
Extended by:
FaradayHelper
Defined in:
lib/atlas_rb/resource.rb

Direct Known Subclasses

Blob, Collection, Community, FileSet, Work

Class Method Summary collapse

Class Method Details

.find(id) ⇒ Object



7
8
9
10
11
# File 'lib/atlas_rb/resource.rb', line 7

def self.find(id)
  result = JSON.parse(connection({}).get('/resources/' + id)&.body)
  { "klass" => result.first[0].capitalize,
    "resource" => result.first[1] }
end

.preview(xml_path) ⇒ Object



13
14
15
16
17
18
# File 'lib/atlas_rb/resource.rb', line 13

def self.preview(xml_path)
  payload = { binary: Faraday::Multipart::FilePart.new(File.open(xml_path),
                                                       "application/xml",
                                                       File.basename(xml_path)) }
  multipart({}).post('/resources/preview', payload)&.body
end