From 5f9bd685cb57b5ac66ab89dc46fa04de3c827bf3 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 8 Mar 2019 21:52:42 +0100 Subject: [PATCH] feat(loan-offer): pre production cleanup --- src/services/BaseService.ts | 7 ++----- src/services/LoanOffer.ts | 15 ++++----------- src/services/LoanRequest.ts | 9 +++------ 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/services/BaseService.ts b/src/services/BaseService.ts index 6e52cb54..3c5c3dc4 100644 --- a/src/services/BaseService.ts +++ b/src/services/BaseService.ts @@ -1,7 +1,6 @@ import axios, { AxiosError, AxiosInstance } from 'axios' import { isValidChecksumAddress } from 'ethereumjs-util' import { ResponseCodes, ServiceErrorInstance, LoanMetadata, LoanAPIInstanceBase } from '../types' -import { Transaction } from 'web3/eth/types'; class ServiceError extends Error implements ServiceErrorInstance { public code: ResponseCodes @@ -15,9 +14,8 @@ export default class BaseService { protected readonly api: AxiosInstance protected readonly serviceUrlRoot: string - constructor(serviceUrlRoot : string, token: string, apiUrl?: string ) { - - this.serviceUrlRoot = serviceUrlRoot; + constructor(serviceUrlRoot: string, token: string, apiUrl?: string) { + this.serviceUrlRoot = serviceUrlRoot this.api = axios.create({ baseURL: apiUrl || 'https://apikovan.aave.com/', headers: { Authorization: `Bearer ${token}` } @@ -65,5 +63,4 @@ export default class BaseService { throw BaseService.errorHandler(e, resourceType, errorParam) } } - } diff --git a/src/services/LoanOffer.ts b/src/services/LoanOffer.ts index a87e3fae..412ada9a 100644 --- a/src/services/LoanOffer.ts +++ b/src/services/LoanOffer.ts @@ -1,12 +1,12 @@ import { Transaction } from 'web3/eth/types' -import { LoanOfferAPIInstance, LoanOfferModel, LoanMetadata, BaseLoanModel } from '../types' +import { LoanOfferAPIInstance, LoanOfferModel } from '../types' import BaseService from './BaseService' -import BaseLoanService from './BaseLoanService'; +import BaseLoanService from './BaseLoanService' export default class LoanOffer extends BaseLoanService implements LoanOfferAPIInstance { constructor(token: string, apiUrl?: string) { - super('/offer',token, apiUrl) + super('/offer', token, apiUrl) } public async create(lenderAddress: string, params: LoanOfferModel): Promise { @@ -33,13 +33,7 @@ export default class LoanOffer extends BaseLoanService implements LoanOfferAPIIn public async takeLoanOffer(loanAddress: string, params: LoanOfferModel): Promise { BaseService.checkAddressChecksum(loanAddress) - return await this.apiRequest( - `/take/${loanAddress}`, - 'placing loan offer funds', - loanAddress, - 'post', - params - ) + return await this.apiRequest(`/take/${loanAddress}`, 'placing loan offer funds', loanAddress, 'post', params) } public async getLoanData(loanAddress: string): Promise { @@ -67,5 +61,4 @@ export default class LoanOffer extends BaseLoanService implements LoanOfferAPIIn return await Promise.all(allDataPromises) } - } diff --git a/src/services/LoanRequest.ts b/src/services/LoanRequest.ts index 9c81fdfe..4ea9897a 100644 --- a/src/services/LoanRequest.ts +++ b/src/services/LoanRequest.ts @@ -1,12 +1,12 @@ import { Transaction } from 'web3/eth/types' -import { LoanRequestAPIInstance, BaseLoanModel, LoanRequestModel, LoanMetadata } from '../types' +import { LoanRequestAPIInstance, LoanRequestModel } from '../types' import BaseService from './BaseService' -import BaseLoanService from './BaseLoanService'; +import BaseLoanService from './BaseLoanService' export default class LoanRequest extends BaseLoanService implements LoanRequestAPIInstance { constructor(token: string, apiUrl?: string) { - super('/request',token, apiUrl) + super('/request', token, apiUrl) } public async create(borrowerWalletAddress: string, params: LoanRequestModel): Promise { @@ -42,7 +42,6 @@ export default class LoanRequest extends BaseLoanService implements LoanRequestA ) } - public async getLoanData(loanAddress: string): Promise { BaseService.checkAddressChecksum(loanAddress) @@ -60,7 +59,6 @@ export default class LoanRequest extends BaseLoanService implements LoanRequestA return await Promise.all(allDataPromises) } - public async getDataAllLoansByBorrower(borrowerAddress: string): Promise { const requestAddressesBorrower = await this.getLoansByBorrower(borrowerAddress) const allDataPromises = requestAddressesBorrower.map(address => this.getLoanData(address)) @@ -74,5 +72,4 @@ export default class LoanRequest extends BaseLoanService implements LoanRequestA return await Promise.all(allDataPromises) } - }