mirror of
https://github.com/modrinth/code.git
synced 2026-08-26 17:44: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:
@@ -0,0 +1,72 @@
|
||||
import { AbstractModule } from '../../../core/abstract-module'
|
||||
import type { Labrinth } from '../types'
|
||||
|
||||
export class LabrinthAffiliateInternalModule extends AbstractModule {
|
||||
public getModuleID(): string {
|
||||
return 'labrinth_affiliate_internal'
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all affiliate codes for the authenticated user (or all if admin)
|
||||
* GET /_internal/affiliate
|
||||
*/
|
||||
public async getAll(): Promise<Labrinth.Affiliate.Internal.AffiliateCode[]> {
|
||||
return this.client.request<Labrinth.Affiliate.Internal.AffiliateCode[]>('/affiliate', {
|
||||
api: 'labrinth',
|
||||
version: 'internal',
|
||||
method: 'GET',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new affiliate code
|
||||
* PUT /_internal/affiliate
|
||||
*/
|
||||
public async create(
|
||||
data: Labrinth.Affiliate.Internal.CreateRequest,
|
||||
): Promise<Labrinth.Affiliate.Internal.AffiliateCode> {
|
||||
return this.client.request<Labrinth.Affiliate.Internal.AffiliateCode>('/affiliate', {
|
||||
api: 'labrinth',
|
||||
version: 'internal',
|
||||
method: 'PUT',
|
||||
body: data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific affiliate code by ID
|
||||
* GET /_internal/affiliate/{id}
|
||||
*/
|
||||
public async get(id: string): Promise<Labrinth.Affiliate.Internal.AffiliateCode> {
|
||||
return this.client.request<Labrinth.Affiliate.Internal.AffiliateCode>(`/affiliate/${id}`, {
|
||||
api: 'labrinth',
|
||||
version: 'internal',
|
||||
method: 'GET',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an affiliate code
|
||||
* DELETE /_internal/affiliate/{id}
|
||||
*/
|
||||
public async delete(id: string): Promise<void> {
|
||||
return this.client.request<void>(`/affiliate/${id}`, {
|
||||
api: 'labrinth',
|
||||
version: 'internal',
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an affiliate code's source name
|
||||
* PATCH /_internal/affiliate/{id}
|
||||
*/
|
||||
public async patch(id: string, data: Labrinth.Affiliate.Internal.PatchRequest): Promise<void> {
|
||||
return this.client.request<void>(`/affiliate/${id}`, {
|
||||
api: 'labrinth',
|
||||
version: 'internal',
|
||||
method: 'PATCH',
|
||||
body: data,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user