Skip to content

Commit

Permalink
feat: add create object api (#329)
Browse files Browse the repository at this point in the history
Signed-off-by: Prati28 <sankhepratiksha3@gmail.com>
Signed-off-by: Pratiksha Sankhe <sankhepratiksha3@gmail.com>
  • Loading branch information
psankhe28 authored Jul 23, 2024
1 parent a137eb4 commit 5c61280
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/ecc-client-elixir-drs-filer/src/API/Object/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Description

See the human-readable [Reference Documentation](https://ga4gh.github.io/data-repository-service-schemas/docs/).

## postDrsObject

Posts/Create a new object.

**API Request Body**

| Parameter | Type | Description |
| ---------- | ------ | ------------------------------------------------------------------------ |
| `objectData` | object | The data of the object to be posted. |
| | | This should be an object containing the necessary fields for the object. |
| | | Modify the structure according to your object requirements. |


![Logo]('./../../../../images/logo-elixir.svg)
![Logo]('./../../../../images/logo-elixir-cloud-aai.svg)

31 changes: 31 additions & 0 deletions packages/ecc-client-elixir-drs-filer/src/API/Object/drsAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const postObject = async (baseURL: string, objectData: object) => {
const url = `${baseURL}/objects`;

try {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(objectData),
});

if (!response) {
return {
isError: true,
breakpoint: "postObject",
error: "No response from server",
};
}

return await response.json();
} catch (error) {
return {
isError: true,
breakpoint: "postObject",
error,
};
}
};

export { postObject };
1 change: 1 addition & 0 deletions packages/ecc-client-elixir-drs-filer/src/API/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./Object/drsAPI.js";

0 comments on commit 5c61280

Please sign in to comment.