Files
kittycad.ts/src/api/users/get_user_shortlinks.ts
zoo-github-actions-auth[bot] 79b587300a Update api spec (#274)
* YOYO NEW API SPEC!

* Add UserIdentifier test data generator

* Add CodeLanguage test code generator

* Fix up file creation executor test generator

* Add shortlink deletion to expectedToFail

* Whoops, include the new example files

* Generated new lib

* 2.0.8

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: 49lf <ircsurfer33@gmail.com>
2024-10-11 12:45:04 -04:00

40 lines
1.1 KiB
TypeScript

import {
ShortlinkResultsPage_type,
Error_type,
CreatedAtSortMode_type,
} from '../../models.js';
import { Client } from '../../client.js';
interface Get_user_shortlinks_params {
client?: Client;
limit: number;
page_token: string;
sort_by: CreatedAtSortMode_type;
}
type Get_user_shortlinks_return = ShortlinkResultsPage_type | Error_type;
export default async function get_user_shortlinks({
client,
limit,
page_token,
sort_by,
}: Get_user_shortlinks_params): Promise<Get_user_shortlinks_return> {
const url = `/user/shortlinks?limit=${limit}&page_token=${page_token}&sort_by=${sort_by}`;
const urlBase = process?.env?.BASE_URL || 'https://api.zoo.dev';
const fullUrl = urlBase + url;
const kittycadToken = client
? client.token
: process.env.KITTYCAD_TOKEN || '';
const headers = {
Authorization: `Bearer ${kittycadToken}`,
};
const fetchOptions = {
method: 'GET',
headers,
};
const response = await fetch(fullUrl, fetchOptions);
const result = (await response.json()) as Get_user_shortlinks_return;
return result;
}