Sha256: e3452005f2be7f717a96dc7bcfad01e9719ede33dde0ecc4b3cd9343bdd07253
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module AtlasRb class Community < Resource ROUTE = "/communities/" def self.find(id) JSON.parse(connection({}).get(ROUTE + id)&.body)["community"] end def self.create(id = nil, xml_path = nil) result = JSON.parse(connection({ parent_id: id }).post(ROUTE)&.body)["community"] return unless xml_path.present? update(result["id"], xml_path) find(result["id"]) 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 def self.metadata(id, values) JSON.parse(connection({ metadata: values }).patch(ROUTE + id)&.body) end def self.mods(id, kind = nil) # json default, html, xml connection({}).get( ROUTE + id + '/mods' + (kind.present? ? ".#{kind}" : '') )&.body end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
atlas_rb-0.0.54 | lib/atlas_rb/community.rb |
atlas_rb-0.0.53 | lib/atlas_rb/community.rb |
atlas_rb-0.0.52 | lib/atlas_rb/community.rb |