Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/endpoints/custom-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,33 @@ class CustomApisEndpoint extends CRUDExtend {
'DELETE'
)
}

GetEntriesBySlug(slug) {
const { limit, offset, sort, filter } = this
return this.request.send(
buildURL(`extensions/${slug}`, { limit, offset, sort, filter }),
'GET',
undefined,
undefined,
this
)
}

GetEntryBySlug(slug, entryId) {
return this.request.send(`extensions/${slug}/${entryId}`, 'GET')
}

CreateEntryBySlug(slug, body) {
return this.request.send(`extensions/${slug}`, 'POST', body)
}

UpdateEntryBySlug(slug, entryId, body) {
return this.request.send(`extensions/${slug}/${entryId}`, 'PUT', body)
}

DeleteEntryBySlug(slug, entryId) {
return this.request.send(`extensions/${slug}/${entryId}`, 'DELETE')
}
}

export default CustomApisEndpoint
22 changes: 22 additions & 0 deletions src/types/custom-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,26 @@ export interface CustomApisEndpoint {
): Promise<ResponseBody>

DeleteEntry<T = any>(customApiId: string, customApiEntryId: string): Promise<T>

GetEntriesBySlug<T = any>(slug: string): Promise<T>

GetEntryBySlug<T = any>(slug: string, entryId: string): Promise<T>

CreateEntryBySlug<RequestBody = any, ResponseBody = any>(
slug: string,
body: RequestBody
): Promise<ResponseBody>

UpdateEntryBySlug<RequestBody = any, ResponseBody = any>(
slug: string,
entryId: string,
body: RequestBody
): Promise<ResponseBody>

DeleteEntryBySlug<T = any>(slug: string, entryId: string): Promise<T>

Filter(filter: any): CustomApisEndpoint
Limit(value: number): CustomApisEndpoint
Offset(value: number): CustomApisEndpoint
Sort(value: string): CustomApisEndpoint
}
2 changes: 1 addition & 1 deletion src/types/extensions.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Extensions = Record<string, Record<string, string | number | boolean>>
export type Extensions = Record<string, Record<string, string | number | boolean>>
Loading