Skip to content

Commit

Permalink
[CHANGE] Fixed some eslint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvandenberg95 committed Jul 16, 2022
1 parent 26749c1 commit ec76f20
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 58 deletions.
78 changes: 39 additions & 39 deletions src/api/getTransactionsRequest.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { DEGIRO_API_PATHS } from "../enums";
import { AccountConfigType, AccountDataType, GetTransactionsOptionsType, TransactionType } from "../types"
import { debug } from "../utils";
import { DEGIRO_API_PATHS } from '../enums';
import { AccountConfigType, AccountDataType, GetTransactionsOptionsType, TransactionType } from '../types'
import { debug } from '../utils';
const { GET_TRANSACTIONS_PATH } = DEGIRO_API_PATHS;

export function getTransactionsRequest(accountData: AccountDataType, accountConfig: AccountConfigType, config: GetTransactionsOptionsType): Promise<TransactionType[]> {
return new Promise((resolve, reject) => {
// Create params to get orders by types
let params = ''
params += `fromDate=${encodeURIComponent(config.fromDate)}&`
params += `toDate=${encodeURIComponent(config.toDate)}&`
params += `groupTransactionsByOrder`
params += `intAccount=${accountData.data.intAccount}&`
params += `sessionId=${accountConfig.data.sessionId}`
const requestOptions: {
method?: string,
body?: string,
headers: {
[key: string]: string,
},
credentials: 'include',
referer: string,
} = {
headers: {
Cookie: `JSESSIONID=${accountConfig.data.sessionId};`,
},
credentials: 'include',
referer: 'https://trader.degiro.nl/trader/',
}
// Do the request to get a account config data
const uri = `${accountConfig.data.reportingUrl}${GET_TRANSACTIONS_PATH}?${params}`
debug(`Making request to ${uri}`)
fetch(uri, requestOptions)
.then(res => res.json())
.then((res) => {
resolve(res.data);
})
.catch(reject)
})
}
return new Promise((resolve, reject) => {
// Create params to get orders by types
let params = ''
params += `fromDate=${encodeURIComponent(config.fromDate)}&`
params += `toDate=${encodeURIComponent(config.toDate)}&`
params += `groupTransactionsByOrder`
params += `intAccount=${accountData.data.intAccount}&`
params += `sessionId=${accountConfig.data.sessionId}`

const requestOptions: {
method?: string,
body?: string,
headers: {
[key: string]: string,
},
credentials: 'include',
referer: string,
} = {
headers: {
Cookie: `JSESSIONID=${accountConfig.data.sessionId};`,
},
credentials: 'include',
referer: 'https://trader.degiro.nl/trader/',
}

// Do the request to get a account config data
const uri = `${accountConfig.data.reportingUrl}${GET_TRANSACTIONS_PATH}?${params}`
debug(`Making request to ${uri}`)
fetch(uri, requestOptions)
.then(res => res.json())
.then((res) => {
resolve(res.data);
})
.catch(reject)
})
}
6 changes: 3 additions & 3 deletions src/types/GetTransactionsOptionsType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type GetTransactionsOptionsType = {
fromDate: string,
toDate: string,
groupTransactionsByOrder: boolean
fromDate: string,
toDate: string,
groupTransactionsByOrder: boolean,
}
28 changes: 14 additions & 14 deletions src/types/TransactionType.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export type TransactionType = {
buysell: string,
counterParty: string,
date: string,
id: number,
orderTypeId: number,
price: number,
productId: number,
quantity: number,
total: number,
totalInBaseCurrency: number,
totalPlusFeeInBaseCurrency: number,
tradingVenue: string,
transactionTypeId: number,
transfered: boolean
buysell: string,
counterParty: string,
date: string,
id: number,
orderTypeId: number,
price: number,
productId: number,
quantity: number,
total: number,
totalInBaseCurrency: number,
totalPlusFeeInBaseCurrency: number,
tradingVenue: string,
transactionTypeId: number,
transfered: boolean,
}
1 change: 0 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
Country,
} from './ConfigDictionaryType'


export {
CashFoundType,
DeGiroSettupType,
Expand Down
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"check-strings": true,
"check-regex": true
}
]
],
"quotemark":["true", "tick", "backtick"]
},
"rulesDirectory": []
}

0 comments on commit ec76f20

Please sign in to comment.