Files
kittycad.ts/src/api/file/create_file_surface_area.ts
Kurt Hutten adb5278325 generate examples (#5)
* 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
2022-08-12 19:25:16 +10:00

39 lines
1.0 KiB
TypeScript

import fetch from 'node-fetch';
import {
FileSurfaceArea_type,
Error_type,
FileSourceFormat_type,
} from '../../models.js';
import { Client } from '../../client.js';
interface Create_file_surface_area_params {
client?: Client;
src_format: FileSourceFormat_type;
body: string;
}
type Create_file_surface_area_return = FileSurfaceArea_type | Error_type;
export default async function create_file_surface_area({
client,
src_format,
body,
}: Create_file_surface_area_params): Promise<Create_file_surface_area_return> {
const url = `/file/surface-area?src_format=${src_format}`;
const fullUrl = 'https://api.kittycad.io' + url;
const kittycadToken = client
? client.token
: process.env.KITTYCAD_TOKEN || '';
const headers = {
Authorization: `Bearer ${kittycadToken}`,
};
const fetchOptions = {
method: 'POST',
headers,
body,
};
const response = await fetch(fullUrl, fetchOptions);
const result = (await response.json()) as Create_file_surface_area_return;
return result;
}