mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 17:14:50 +00:00
refactor: remove useBaseFetch for @modrinth/api-client (#5596)
* Reapply "fix: start swapping useBaseFetch usages to api-client"
This reverts commit f4f33db701.
* fix: bugs
* fix: analytics
* fix: lint
This commit is contained in:
@@ -49,4 +49,74 @@ export class LabrinthOrganizationsV3Module extends AbstractModule {
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get multiple organizations by their IDs
|
||||
*
|
||||
* @param ids - Array of organization IDs
|
||||
* @returns Promise resolving to an array of organizations
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const orgs = await client.labrinth.organizations_v3.getMultiple(['id1', 'id2'])
|
||||
* ```
|
||||
*/
|
||||
public async getMultiple(ids: string[]): Promise<Labrinth.Organizations.v3.Organization[]> {
|
||||
return this.client.request<Labrinth.Organizations.v3.Organization[]>(
|
||||
`/organizations?ids=${encodeURIComponent(JSON.stringify(ids))}`,
|
||||
{
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'GET',
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a project to an organization
|
||||
*
|
||||
* @param idOrSlug - Organization ID or slug
|
||||
* @param request - The project to add
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* await client.labrinth.organizations_v3.addProject('my-org', { project_id: 'AABBCCDD' })
|
||||
* ```
|
||||
*/
|
||||
public async addProject(
|
||||
idOrSlug: string,
|
||||
request: Labrinth.Organizations.v3.AddProjectRequest,
|
||||
): Promise<void> {
|
||||
return this.client.request(`/organization/${idOrSlug}/projects`, {
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'POST',
|
||||
body: request,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a project from an organization
|
||||
*
|
||||
* @param idOrSlug - Organization ID or slug
|
||||
* @param projectId - Project ID to remove
|
||||
* @param data - Request body containing the new_owner user ID
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* await client.labrinth.organizations_v3.removeProject('my-org', 'proj123', { new_owner: 'user456' })
|
||||
* ```
|
||||
*/
|
||||
public async removeProject(
|
||||
idOrSlug: string,
|
||||
projectId: string,
|
||||
data: Labrinth.Organizations.v3.RemoveProjectRequest,
|
||||
): Promise<void> {
|
||||
return this.client.request(`/organization/${idOrSlug}/projects/${projectId}`, {
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'DELETE',
|
||||
body: data,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user