All files / src/controllers oauth.controller.ts

95.83% Statements 23/24
100% Branches 6/6
100% Functions 3/3
95.45% Lines 21/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45  1x 1x 1x 1x 1x 1x   1x   3x 3x           1x 3x 3x 2x 2x 2x 1x 1x   1x     1x               1x 1x            
"use strict";
import {inject} from '@loopback/core';
import {get, Request, Response, RestBindings} from '@loopback/rest';
import errorMessages from '../utils/errorMessages';
import {log} from "../utils/logMethod";
import {failureHandler, successHandler} from './components';
import {estibotApprasisalDetails} from './components/estibotIntegrations';
 
export class OauthController {
  constructor(
    @inject(RestBindings.Http.RESPONSE) protected res: Response,
    @inject(RestBindings.Http.REQUEST) protected req: Request,
 
  ) { }
 
  @get('/appraisalDetails')
  @log()
  async appraisalDetails(): Promise<Response> {
    try {
      if (this.req.query.domainName) {
        let domainName = this.req.query.domainName.toString()
        let response = await estibotApprasisalDetails(domainName)
        if (response.success === true) {
          let data = response.results.data
          return successHandler(this.res, 200, data)
        } else {
          return successHandler(this.res, 202, response.message)
        }
      } else {
        return this.failureHandler(this.res, 422, errorMessages.requiredFieldIsMissing)
      }
    } catch (error) {
      return this.failureHandler(this.res, 422, error)
    }
  }
 
  private failureHandler(res: Response, code: number, error: any): Promise<Response> {
    let className = error.className || OauthController.name
    return failureHandler(res, code, error, className)
  }
 
}