Class: AtlasRb::Collection
- Defined in:
- lib/atlas_rb/collection.rb
Constant Summary collapse
- ROUTE =
"/collections/"
Class Method Summary collapse
- .children(id) ⇒ Object
- .create(id) ⇒ Object
- .destroy(id) ⇒ Object
- .find(id) ⇒ Object
- .update(id, xml_path) ⇒ Object
Methods included from FaradayHelper
Class Method Details
.children(id) ⇒ Object
20 21 22 |
# File 'lib/atlas_rb/collection.rb', line 20 def self.children(id) JSON.parse(connection({}).get(ROUTE + id + '/children')&.body) end |
.create(id) ⇒ Object
11 12 13 14 |
# File 'lib/atlas_rb/collection.rb', line 11 def self.create(id) # params[:parent_id] JSON.parse(connection({ parent_id: id }).post(ROUTE)&.body)["collection"] end |
.destroy(id) ⇒ Object
16 17 18 |
# File 'lib/atlas_rb/collection.rb', line 16 def self.destroy(id) connection({}).delete(ROUTE + id) end |
.find(id) ⇒ Object
7 8 9 |
# File 'lib/atlas_rb/collection.rb', line 7 def self.find(id) JSON.parse(connection({}).get(ROUTE + id)&.body)["collection"] end |
.update(id, xml_path) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/atlas_rb/collection.rb', line 24 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 |