* update types * more type improvements * fix some gen test types * add body to file gen tests * enable error tests to pass * forget gen tests * split gen tests into throwing and not throwing * remove log noise from gen tests * generate tests and examples patch.json * format examples * add action for updating spec in docs * fmt * tweak token * formating examples * more formatting * update spec.json * add optional client * fix test methods and add client example * re-generate with new spec * fix dir removal
32 lines
899 B
TypeScript
32 lines
899 B
TypeScript
import fetch from 'node-fetch';
|
|
import { ApiCallWithPrice_type, Error_type } from '../../models.js';
|
|
import { Client } from '../../client.js';
|
|
|
|
interface Get_api_call_for_user_params {
|
|
client?: Client;
|
|
id: string;
|
|
}
|
|
|
|
type Get_api_call_for_user_return = ApiCallWithPrice_type | Error_type;
|
|
|
|
export default async function get_api_call_for_user({
|
|
client,
|
|
id,
|
|
}: Get_api_call_for_user_params): Promise<Get_api_call_for_user_return> {
|
|
const url = `/user/api-calls/${id}`;
|
|
const fullUrl = 'https://api.kittycad.io' + 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_api_call_for_user_return;
|
|
return result;
|
|
}
|