feat: add new organization trigger in GitHub

This commit is contained in:
Ali BARIN
2022-04-20 00:32:42 +02:00
committed by Ömer Faruk Aydın
parent 96ede071cf
commit 6bee6bafa8
4 changed files with 56 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
import { Octokit } from 'octokit';
import { IJSONObject } from '@automatisch/types';
export default class NewOrganization {
client?: Octokit;
baseOptions = {
per_page: 100,
};
constructor(connectionData: IJSONObject) {
if (
connectionData.consumerKey &&
connectionData.consumerSecret &&
connectionData.accessToken
) {
this.client = new Octokit({
auth: connectionData.accessToken as string,
});
}
}
async run() {
// TODO: implement pagination on undated entires
return await this.client.paginate(this.client.rest.orgs.listForAuthenticatedUser);
}
async testRun() {
const { data: orgs } = await this.client.rest.orgs.listForAuthenticatedUser({ per_page: 1 });
return orgs;
}
}