Sha256: 8007fba326307ebcc10ff7617114c9145ead8d9eddc7145f00517b422e946404

Contents?: true

Size: 870 Bytes

Versions: 6

Compression:

Stored size: 870 Bytes

Contents

# frozen_string_literal: true

module AtlasRb
  class Collection < Resource
    ROUTE = "/collections/"

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

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

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

    def self.children(id)
      JSON.parse(connection({}).get(ROUTE + id + '/children')&.body)
    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
atlas_rb-0.0.31 lib/atlas_rb/collection.rb
atlas_rb-0.0.30 lib/atlas_rb/collection.rb
atlas_rb-0.0.29 lib/atlas_rb/collection.rb
atlas_rb-0.0.27 lib/atlas_rb/collection.rb
atlas_rb-0.0.26 lib/atlas_rb/collection.rb
atlas_rb-0.0.21 lib/atlas_rb/collection.rb