Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Merge pull request #17 from integration-os/feature/add-error-type
Browse files Browse the repository at this point in the history
feat: add response error type
  • Loading branch information
paulkr authored Oct 16, 2024
2 parents 95ff019 + 404f42c commit c19c968
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 116 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ yarn add @integrationos/node
To use the library you must provide an API key and Connection key. Both are located in the IntegrationOS dashboard.

```jsx
import { IntegrationOS } from "@integrationOS/node";
import { IntegrationOS } from "@integrationos/node";

const integrate = new IntegrationOS("sk_live_1234");

Expand Down
6 changes: 3 additions & 3 deletions generator/templates/index.handlebars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios, { AxiosInstance, Method } from 'axios';
import { UnifiedOptions, Response, ListFilter, ListResponse, Count, DeleteOptions, HttpStatusCode } from './types/';
import { UnifiedOptions, Response, ListFilter, ListResponse, Count, DeleteOptions, HttpStatusCode, ResponseError } from './types/';
import { convertFilterToQueryParams } from './utils';

export * from './types/generic';
Expand Down Expand Up @@ -82,7 +82,7 @@ export class Resource {

return output;
} catch (error: any) {
throw error.response?.data;
throw error.response?.data as ResponseError;
}
}

Expand Down Expand Up @@ -111,7 +111,7 @@ export class Resource {

return output;
} catch (error: any) {
throw error.response?.data;
throw error.response?.data as ResponseError;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@integrationos/node",
"version": "4.1.8",
"version": "4.1.9",
"description": "Node SDK for the IntegrationOS Unified API",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios, { AxiosInstance, Method } from 'axios';
import { UnifiedOptions, Response, ListFilter, ListResponse, Count, DeleteOptions, HttpStatusCode } from './types/';
import { UnifiedOptions, Response, ListFilter, ListResponse, Count, DeleteOptions, HttpStatusCode, ResponseError } from './types/';
import { convertFilterToQueryParams } from './utils';

export * from './types/generic';
Expand Down Expand Up @@ -130,7 +130,7 @@ export class Resource {

return output;
} catch (error: any) {
throw error.response?.data;
throw error.response?.data as ResponseError;
}
}

Expand Down Expand Up @@ -159,7 +159,7 @@ export class Resource {

return output;
} catch (error: any) {
throw error.response?.data;
throw error.response?.data as ResponseError;
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/types/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ export interface Response<Type> {
statusCode: number;
}

export interface ResponseError {
type: string;
code: number;
status: number;
key: string;
message: string;
meta: object | null;
}

export enum HttpStatusCode {
// 1xx Informational
Continue = 100,
Expand Down
216 changes: 108 additions & 108 deletions src/types/models.ts

Large diffs are not rendered by default.

0 comments on commit c19c968

Please sign in to comment.