first commit
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
export function entityObjectPath(typeName, id) {
|
||||
const type = encodeURIComponent(typeName);
|
||||
if (id) {
|
||||
const entityId = id.includes("/") ? id.split("/").pop() : id;
|
||||
return `/V2.0/services/data/objects/${type}/${encodeURIComponent(entityId)}`;
|
||||
}
|
||||
return `/V2.0/services/data/objects/${type}`;
|
||||
}
|
||||
export class EntityObjectsService {
|
||||
http;
|
||||
constructor(http) {
|
||||
this.http = http;
|
||||
}
|
||||
get(typeName, id, options) {
|
||||
const query = {};
|
||||
if (options?.fields?.length) {
|
||||
query.fields = options.fields.join(",");
|
||||
}
|
||||
return this.http.request(entityObjectPath(typeName, id), {
|
||||
method: "GET",
|
||||
query,
|
||||
});
|
||||
}
|
||||
create(typeName, fields) {
|
||||
return this.http.request(entityObjectPath(typeName), {
|
||||
method: "PUT",
|
||||
body: fields,
|
||||
});
|
||||
}
|
||||
update(typeName, id, fields) {
|
||||
return this.http.request(entityObjectPath(typeName, id), {
|
||||
method: "POST",
|
||||
body: fields,
|
||||
});
|
||||
}
|
||||
delete(typeName, id) {
|
||||
return this.http.request(entityObjectPath(typeName, id), {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=objects.js.map
|
||||
Reference in New Issue
Block a user