|
| 1 | +import { AxiosPromise } from 'axios'; |
| 2 | +import * as express from 'express'; |
| 3 | +import * as admin from 'firebase-admin'; |
| 4 | +import { ParamJSON, SDKConfig } from '../src/sdk/const/types'; |
| 5 | + |
| 6 | +declare module 'freee-firebase-sdk' { |
| 7 | + /** |
| 8 | + * Freee Server SDK |
| 9 | + */ |
| 10 | + export class FreeeServerSDK { |
| 11 | + constructor(config: SDKConfig, serviceAccount: { [key: string]: string }) |
| 12 | + |
| 13 | + /** |
| 14 | + * get firebase admin instance |
| 15 | + */ |
| 16 | + firebaseApp(): admin.app.App |
| 17 | + |
| 18 | + /** |
| 19 | + * get freee api client instance |
| 20 | + */ |
| 21 | + api(): FreeeAPIClient |
| 22 | + |
| 23 | + /** |
| 24 | + * get auth client instance |
| 25 | + */ |
| 26 | + auth(): FreeeFirebaseAuthClient |
| 27 | + } |
| 28 | + |
| 29 | + class FreeeAPIClient { |
| 30 | + get<T = any>( |
| 31 | + url: string, |
| 32 | + params: ParamJSON, |
| 33 | + userId: string |
| 34 | + ): AxiosPromise<T> |
| 35 | + post<T = any>(url: string, data: ParamJSON, userId: string): AxiosPromise<T> |
| 36 | + put<T = any>(url: string, data: ParamJSON, userId: string): AxiosPromise<T> |
| 37 | + delete(url: string, data: ParamJSON, userId: string): AxiosPromise |
| 38 | + } |
| 39 | + |
| 40 | + class FreeeFirebaseAuthClient { |
| 41 | + /** |
| 42 | + * Redirect url to authorize |
| 43 | + */ |
| 44 | + redirect(res: express.Response): void |
| 45 | + /** |
| 46 | + * Get token with authorized code from freee, save it to firebase and login firebase |
| 47 | + */ |
| 48 | + callback(code: string, res: express.Response): void |
| 49 | + /** |
| 50 | + * path for redirect on freee authorization |
| 51 | + */ |
| 52 | + getRedirectPath(): string |
| 53 | + /** |
| 54 | + * path for callback on freee authorization |
| 55 | + */ |
| 56 | + getCallbackPath(): string |
| 57 | + /** |
| 58 | + * path for callback on freee authorization |
| 59 | + */ |
| 60 | + getCompaniesPath(): string |
| 61 | + |
| 62 | + /** |
| 63 | + * Create crypto key to bucket for it by specified date |
| 64 | + * |
| 65 | + * {@link SDKConfig#firebase#cryptoKeyBucket} must be specified |
| 66 | + */ |
| 67 | + createCryptoKey(date: Date): Promise<void> |
| 68 | + } |
| 69 | +} |
0 commit comments