Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Aug 26, 2023
1 parent 48f471a commit 9025c0a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typehub-javascript-sdk",
"version": "1.1.5",
"version": "1.1.6",
"description": "SDK to talk to the TypeHub API",
"keywords": [
"TypeHub",
Expand Down
13 changes: 13 additions & 0 deletions src/DocumentMeta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* DocumentMeta automatically generated by SDKgen please do not edit this file manually
* {@link https://sdkgen.app}
*/

export interface DocumentMeta {
description?: string
baseUrl?: string
baseVersion?: string
keywords?: string
homepage?: string
license?: string
}
45 changes: 45 additions & 0 deletions src/DocumentTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,58 @@ import {DocumentCollection} from "./DocumentCollection";
import {DocumentCreate} from "./DocumentCreate";
import {DocumentExportRequest} from "./DocumentExportRequest";
import {DocumentExportResponse} from "./DocumentExportResponse";
import {DocumentMeta} from "./DocumentMeta";
import {DocumentPreview} from "./DocumentPreview";
import {DocumentUpdate} from "./DocumentUpdate";
import {Message} from "./Message";
import {MessageException} from "./MessageException";
import {Passthru} from "./Passthru";

export class DocumentTag extends TagAbstract {
/**
* Updates the meta data of an document
*
* @returns {Promise<Message>}
* @throws {MessageException}
* @throws {ClientException}
*/
public async meta(user: string, document: string, payload: DocumentMeta): Promise<Message> {
const url = this.parser.url('/document/:user/:document/meta', {
'user': user,
'document': document,
});

let params: AxiosRequestConfig = {
url: url,
method: 'PUT',
params: this.parser.query({
}),
data: payload
};

try {
const response = await this.httpClient.request<Message>(params);
return response.data;
} catch (error) {
if (error instanceof ClientException) {
throw error;
} else if (axios.isAxiosError(error) && error.response) {
switch (error.response.status) {
case 400:
throw new MessageException(error.response.data);
case 404:
throw new MessageException(error.response.data);
case 500:
throw new MessageException(error.response.data);
default:
throw new UnknownStatusCodeException('The server returned an unknown status code');
}
} else {
throw new ClientException('An unknown error occurred: ' + String(error));
}
}
}

/**
* Reverts your document to this commit
*
Expand Down

0 comments on commit 9025c0a

Please sign in to comment.