Skip to content

Commit

Permalink
Fleshing out file and file set CRUD
Browse files Browse the repository at this point in the history
  • Loading branch information
dgcliff committed Sep 29, 2023
1 parent da80584 commit 05a4d1d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.9
0.0.10
5 changes: 3 additions & 2 deletions lib/atlas_rb/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ def self.find(id)
connection({}).get(ROUTE + id)&.body
end

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

def self.destroy(id)
Expand Down
4 changes: 2 additions & 2 deletions lib/atlas_rb/community.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def self.find(id)
connection({}).get(ROUTE + id)&.body
end

def self.create
connection({}).post(ROUTE)&.body
def self.create(id = nil)
connection({ parent_id: id }).post(ROUTE)&.body
end

def self.destroy(id)
Expand Down
23 changes: 23 additions & 0 deletions lib/atlas_rb/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,27 @@ module AtlasRb
class File < Resource
ROUTE = "/files/"
end

def self.find(id)
connection({}).get(ROUTE + id)&.body
end

def self.create(id, blob_path)
payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path),
"application/octet-stream",
File.basename(blob_path)) }

multipart({ work_id: id }).post(ROUTE, payload)&.body
end

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

def self.update(id, blob_path)
payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path),
"application/octet-stream",
File.basename(blob_path)) }
multipart({}).patch(ROUTE + id, payload)&.body
end
end
20 changes: 20 additions & 0 deletions lib/atlas_rb/file_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,24 @@ module AtlasRb
class FileSet < Resource
ROUTE = "/file_sets/"
end

def self.find(id)
connection({}).get(ROUTE + id)&.body
end

def self.create(id, classification)
connection({ work_id: id, classification: classification }).post(ROUTE)&.body
end

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

def self.update(id, blob_path)
# Need to figure out blob vs XML
payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path),
"application/octet-stream",
File.basename(blob_path)) }
multipart({}).patch(ROUTE + id, payload)&.body
end
end
5 changes: 3 additions & 2 deletions lib/atlas_rb/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ def self.find(id)
connection({}).get(ROUTE + id)&.body
end

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

def self.destroy(id)
Expand Down

0 comments on commit 05a4d1d

Please sign in to comment.