Sha256: 7ace383e90a39dd7945f02480fcc357f6507acc91aea336f533633a15485d906

Contents?: true

Size: 656 Bytes

Versions: 1

Compression:

Stored size: 656 Bytes

Contents

# frozen_string_literal: true

module AtlasRb
  class Resource
    extend AtlasRb::FaradayHelper

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
atlas_rb-0.0.46 lib/atlas_rb/resource.rb