Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
refactor(custom apis): updated entries to use id instead of slug (#933)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: changed the endpoint in entries and it now uses customApiId instead of
customApiSlug
  • Loading branch information
sarawasim1 authored Jun 3, 2024
1 parent bb83044 commit 284c3bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
21 changes: 10 additions & 11 deletions src/endpoints/custom-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class CustomApisEndpoint extends CRUDExtend {
super(endpoint)

this.endpoint = 'settings/extensions/custom-apis'
this.entriesEndpoint = 'extensions'
}

Create(body) {
Expand Down Expand Up @@ -69,11 +68,11 @@ class CustomApisEndpoint extends CRUDExtend {
)
}

GetEntries(customApiSlug) {
GetEntries(customApiId) {
const { limit, offset, sort, filter } = this

return this.request.send(
buildURL(`${this.entriesEndpoint}/${customApiSlug}`, {
buildURL(`${this.endpoint}/${customApiId}/entries`, {
limit,
offset,
sort,
Expand All @@ -83,32 +82,32 @@ class CustomApisEndpoint extends CRUDExtend {
)
}

GetEntry(customApiSlug, customApiEntryId) {
GetEntry(customApiId, customApiEntryId) {
return this.request.send(
`${this.entriesEndpoint}/${customApiSlug}/${customApiEntryId}`,
`${this.endpoint}/${customApiId}/entries/${customApiEntryId}`,
'GET'
)
}

CreateEntry(customApiSlug, body) {
CreateEntry(customApiId, body) {
return this.request.send(
`${this.entriesEndpoint}/${customApiSlug}`,
`${this.endpoint}/${customApiId}/entries`,
'POST',
body
)
}

UpdateEntry(customApiSlug, customApiEntryId, body) {
UpdateEntry(customApiId, customApiEntryId, body) {
return this.request.send(
`${this.entriesEndpoint}/${customApiSlug}/${customApiEntryId}`,
`${this.endpoint}/${customApiId}/entries/${customApiEntryId}`,
'PUT',
body
)
}

DeleteEntry(customApiSlug, customApiEntryId) {
DeleteEntry(customApiId, customApiEntryId) {
return this.request.send(
`${this.entriesEndpoint}/${customApiSlug}/${customApiEntryId}`,
`${this.endpoint}/${customApiId}/entries/${customApiEntryId}`,
'DELETE'
)
}
Expand Down
10 changes: 5 additions & 5 deletions src/types/custom-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ export interface CustomApisEndpoint {

DeleteField<T = any>(customApiId: string, customApiFieldId: string): Promise<T>

GetEntries<T = any>(customApiSlug: string): Promise<T>
GetEntries<T = any>(customApiId: string): Promise<T>

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

CreateEntry<RequestBody = any, ResponseBody = any>(
customApiSlug: string,
customApiId: string,
body: RequestBody
): Promise<ResponseBody>

UpdateEntry<RequestBody = any, ResponseBody = any>(
customApiSlug: string,
customApiId: string,
customApiEntryId: string,
body: RequestBody
): Promise<ResponseBody>

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

}

0 comments on commit 284c3bf

Please sign in to comment.