mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 04:06:39 +00:00
Split tagsList and tagsStats methods in ShlinkApiClient for clarity
This commit is contained in:
@@ -86,14 +86,15 @@ export class ShlinkApiClient {
|
||||
): Promise<ShortUrl> =>
|
||||
this.performRequest<ShortUrl>(`/short-urls/${shortCode}`, 'PATCH', { domain }, edit);
|
||||
|
||||
public readonly listTags = async (useTagsStatsEndpoint: boolean): Promise<ShlinkTags> =>
|
||||
(useTagsStatsEndpoint
|
||||
? this.performRequest<{ tags: ShlinkTagsStatsResponse }>('/tags/stats', 'GET')
|
||||
.then(({ tags }) => tags)
|
||||
.then(({ data }) => ({ tags: data.map(({ tag }) => tag), stats: data }))
|
||||
: this.performRequest<{ tags: ShlinkTagsResponse }>('/tags', 'GET', { withStats: 'true' })
|
||||
.then(({ tags }) => tags)
|
||||
.then(({ data, stats }) => ({ tags: data, stats })));
|
||||
public readonly listTags = async (): Promise<ShlinkTags> =>
|
||||
this.performRequest<{ tags: ShlinkTagsResponse }>('/tags', 'GET', { withStats: 'true' })
|
||||
.then(({ tags }) => tags)
|
||||
.then(({ data, stats }) => ({ tags: data, stats }));
|
||||
|
||||
public readonly tagsStats = async (): Promise<ShlinkTags> =>
|
||||
this.performRequest<{ tags: ShlinkTagsStatsResponse }>('/tags/stats', 'GET')
|
||||
.then(({ tags }) => tags)
|
||||
.then(({ data }) => ({ tags: data.map(({ tag }) => tag), stats: data }));
|
||||
|
||||
public readonly deleteTags = async (tags: string[]): Promise<{ tags: string[] }> =>
|
||||
this.performEmptyRequest('/tags', 'DELETE', { tags }).then(() => ({ tags }));
|
||||
|
||||
Reference in New Issue
Block a user