diff --git a/src/index.ts b/src/index.ts index 4a9ba24..d52923f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,59 +1,24 @@ import Scopes from "./constants/Scopes"; import OAuth2, { AuthorizationResponse } from "./libs/OAuth2"; import Contacts from "./resources/Contacts"; -import { ContactsStatic } from './interfaces/ContactsStatic'; -import ContactTypes from './resources/ContactTypes'; -import ContactSectors from './resources/ContactSectors'; -import ContactGroups from './resources/ContactGroups'; -import ContactRelations from './resources/ContactRelations'; -import Expenses from './resources/Expenses' +import { ContactsStatic } from "./interfaces/ContactsStatic"; +import ContactTypes from "./resources/ContactTypes"; +import ContactSectors from "./resources/ContactSectors"; +import ContactGroups from "./resources/ContactGroups"; +import ContactRelations from "./resources/ContactRelations"; +import Expenses from "./resources/Expenses"; import Bills from "./resources/Bills"; -import Orders from './resources/Orders'; -import request from 'request-promise-native' -import { CookieJar } from 'request'; +import Orders from "./resources/Orders"; +import request from "request-promise-native"; +import { CookieJar } from "request"; export { ContactsStatic, Scopes }; export default class Bexio { - private clientId: string - private clientSecret: string - private redirectUri: string - private scopes: Array - - private bexioAuth: OAuth2 - - // Resources - // Contacts - public contacts: Contacts - public contactTypes: ContactTypes - public contactSectors: ContactSectors - public contactGroups: ContactGroups - public contactRelations: ContactRelations - - // Sales Order Management - public orders: Orders - public expenses: Expenses - - constructor(clientId: string, clientSecret: string, redirectUri: string, scopes: Array) { - this.clientId = clientId - this.clientSecret = clientSecret - this.redirectUri = redirectUri - this.scopes = scopes - - // add general scope to the request list - this.scopes.push(Scopes.GENERAL) - - this.bexioAuth = new OAuth2(this.clientId, this.clientSecret, this.redirectUri, this.scopes) - - // Init resources - this.contacts = new Contacts(this.bexioAuth) - this.contactTypes = new ContactTypes(this.bexioAuth) - this.contactSectors = new ContactSectors(this.bexioAuth) - this.contactGroups = new ContactGroups(this.bexioAuth) - this.contactRelations = new ContactRelations(this.bexioAuth) - this.orders = new Orders(this.bexioAuth) - this.expenses = new Expenses(this.bexioAuth) - } + private clientId: string; + private clientSecret: string; + private redirectUri: string; + private scopes: Array; private bexioAuth: OAuth2; @@ -67,6 +32,7 @@ export default class Bexio { // Sales Order Management public orders: Orders; + public expenses: Expenses; public bills: Bills; constructor( @@ -97,6 +63,7 @@ export default class Bexio { this.contactGroups = new ContactGroups(this.bexioAuth); this.contactRelations = new ContactRelations(this.bexioAuth); this.orders = new Orders(this.bexioAuth); + this.expenses = new Expenses(this.bexioAuth); this.bills = new Bills(this.bexioAuth); }