-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: PlainClient docs - task [EXT-4924] (#2181)
* feat: PlainClient docs - task [EXT-4924] * improving examples * jareds nits (ty jared) * cleaning up javascript examples * refactoring create or update * fixing build * fixing build * attempting to fix codeclimate * attempting to fix codeclimate * attempting to fix codeclimate
- Loading branch information
1 parent
9a651ec
commit 9c8603f
Showing
9 changed files
with
179 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { RawAxiosRequestHeaders } from 'axios' | ||
import { OptionalDefaults } from '../wrappers/wrap' | ||
|
||
export type CreateOrUpdate<T, Props, ReturnProps> = ( | ||
params: OptionalDefaults<T>, | ||
rawData: Props, | ||
headers: RawAxiosRequestHeaders | ||
) => Promise<ReturnProps> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { | ||
CreateTaskParams, | ||
DeleteTaskParams, | ||
UpdateTaskParams, | ||
UpdateTaskProps, | ||
} from '../../entities/task' | ||
import { | ||
CollectionProp, | ||
CreateTaskProps, | ||
GetEntryParams, | ||
GetTaskParams, | ||
QueryParams, | ||
TaskProps, | ||
} from '../../export-types' | ||
import { OptionalDefaults } from '../wrappers/wrap' | ||
import { CreateOrUpdate } from './base' | ||
|
||
export type TaskPlainClientAPI = { | ||
/** Fetches a task | ||
* | ||
* @param params Space ID, Entry ID, Environment ID, and Task ID | ||
* @returns the task | ||
* @throws if the request fails or the task is not found | ||
* @example | ||
* ```javascript | ||
* const task = await client.task.get({ | ||
* spaceId: '<space_id>', | ||
* entryId: '<entry_id>', | ||
* environmentId: '<environment_id>', | ||
* taskId: '<task_id>', | ||
* }); | ||
* ``` | ||
*/ | ||
get(params: OptionalDefaults<GetTaskParams>): Promise<TaskProps> | ||
/** Fetches all tasks | ||
* | ||
* @param params Space ID, Entry ID, Environment ID, and query parameters | ||
* @returns a collection of tasks | ||
* @throws if the request fails or the tasks are not found | ||
* @example | ||
* ```javascript | ||
* const tasks = await client.task.getMany({ | ||
* spaceId: '<space_id>', | ||
* entryId: '<entry_id>', | ||
* environmentId: '<environment_id>', | ||
* query: { | ||
* limit: 100, | ||
* } | ||
* }); | ||
* ``` | ||
*/ | ||
getMany( | ||
params: OptionalDefaults<GetEntryParams & QueryParams> | ||
): Promise<CollectionProp<TaskProps>> | ||
/** Creates a task | ||
* | ||
* @param params Space ID, Entry ID, Environment ID, and query parameters | ||
* @param rawData the task | ||
* @returns the task | ||
* @throws if the request fails or the task is not found | ||
* @example | ||
* ```javascript | ||
* const task = await client.task.create( | ||
* { | ||
* spaceId: '<space_id>', | ||
* entryId: '<entry_id>', | ||
* environmentId: '<environment_id>', | ||
* }, | ||
* { | ||
* body: "Review Translation", | ||
* status: "active", | ||
* assignedTo: { | ||
* sys: { | ||
* type: "Link", | ||
* linkType: "User", | ||
* id: <user_id> | ||
* } | ||
* } | ||
* } | ||
* ); | ||
* ``` | ||
*/ | ||
create: CreateOrUpdate<CreateTaskParams, CreateTaskProps, TaskProps> | ||
/** Updates a task | ||
* | ||
* @param params Space ID, Entry ID, Environment ID, and Task ID | ||
* @param rawData the task | ||
* @returns the task | ||
* @throws if the request fails or the task is not found | ||
* @example | ||
* ```javascript | ||
* const task = await client.task.update( | ||
* { | ||
* spaceId: '<space_id>', | ||
* entryId: '<entry_id>', | ||
* environmentId: '<environment_id>', | ||
* taskId: '<task_id>', | ||
* }, | ||
* { | ||
* body: "Review Translation", | ||
* status: "active", | ||
* assignedTo: { | ||
* sys: { | ||
* type: "Link", | ||
* linkType: "User", | ||
* id: <user_id> | ||
* } | ||
* } | ||
* } | ||
* ); | ||
* ``` | ||
*/ | ||
update: CreateOrUpdate<UpdateTaskParams, UpdateTaskProps, TaskProps> | ||
/** Deletes a task | ||
* | ||
* @param params Space ID, Entry ID, Environment ID, and Task ID | ||
* @throws if the request fails or the task is not found | ||
* @example | ||
* ```javascript | ||
* await client.task.delete({ | ||
* spaceId: '<space_id>', | ||
* entryId: '<entry_id>', | ||
* environmentId: '<environment_id>', | ||
* taskId: '<task_id>', | ||
* }); | ||
* ``` | ||
*/ | ||
delete(params: OptionalDefaults<DeleteTaskParams>): Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters