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 #4 from integration-os/feat/upsert
Browse files Browse the repository at this point in the history
feat: add upsert support
  • Loading branch information
paulkr authored Sep 13, 2024
2 parents 0759467 + e58df9d commit 6bb854d
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 103 deletions.
4 changes: 4 additions & 0 deletions generator/templates/index.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export class Resource<T> implements UnifiedApi<T> {
return this.makeRequestSingle<T>('POST', `/${this.resourceName}`, object, options, undefined, HttpStatusCode.Created);
}

async upsert(object: T, options?: UnifiedOptions): Promise<Response<T>> {
return this.makeRequestSingle<T>('PUT', `/${this.resourceName}`, object, options, undefined, HttpStatusCode.OK);
}

async list(filter?: ListFilter, options?: UnifiedOptions): Promise<ListResponse<T>> {
const queryParams = convertFilterToQueryParams(filter);
return this.makeRequestList<T>('GET', `/${this.resourceName}`, undefined, options, queryParams, HttpStatusCode.OK);
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.0.2",
"version": "4.0.3",
"description": "Node SDK for the IntegrationOS Unified API",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
20 changes: 20 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export * from './types/generic';
export * from './types/models';

import {
Events,
Calendars,
Threads,
Drafts,
Drives,
Folders,
Files,
Expand Down Expand Up @@ -153,6 +157,10 @@ export class Resource<T> implements UnifiedApi<T> {
return this.makeRequestSingle<T>('POST', `/${this.resourceName}`, object, options, undefined, HttpStatusCode.Created);
}

async upsert(object: T, options?: UnifiedOptions): Promise<Response<T>> {
return this.makeRequestSingle<T>('PUT', `/${this.resourceName}`, object, options, undefined, HttpStatusCode.OK);
}

async list(filter?: ListFilter, options?: UnifiedOptions): Promise<ListResponse<T>> {
const queryParams = convertFilterToQueryParams(filter);
return this.makeRequestList<T>('GET', `/${this.resourceName}`, undefined, options, queryParams, HttpStatusCode.OK);
Expand Down Expand Up @@ -194,6 +202,18 @@ export class IntegrationOS {
});
}

events(connectionKey: string) {
return new Resource<Events>(this.axiosInstance, connectionKey, 'events');
}
calendars(connectionKey: string) {
return new Resource<Calendars>(this.axiosInstance, connectionKey, 'calendars');
}
threads(connectionKey: string) {
return new Resource<Threads>(this.axiosInstance, connectionKey, 'threads');
}
drafts(connectionKey: string) {
return new Resource<Drafts>(this.axiosInstance, connectionKey, 'drafts');
}
drives(connectionKey: string) {
return new Resource<Drives>(this.axiosInstance, connectionKey, 'drives');
}
Expand Down
Loading

0 comments on commit 6bb854d

Please sign in to comment.