Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

degiro-api

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

degiro-api - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

src/lib/enums/DeGiroEnums.ts

9

package.json
{
"name": "degiro-api",
"version": "0.0.5",
"version": "0.0.6",
"public": true,

@@ -22,2 +22,7 @@ "description": "Degiro test scripts",

"devDependencies": {
"@types/cookie": "^0.4.0",
"@types/node": "^13.13.5",
"@types/node-fetch": "^2.5.7",
"install": "^0.13.0",
"npm": "^6.14.5",
"tslint": "^6.1.2",

@@ -28,4 +33,4 @@ "tslint-config-airbnb": "^5.11.2",

"dependencies": {
"@types/node": "^13.13.5"
"node-fetch": "^2.6.0"
}
}

@@ -5,4 +5,10 @@ // Import interfaces

// Import types
import { DeGiroSettupType, PortfolioPositionType } from './types'
import { DeGiroSettupType, LoginResponseType, AccountConfigType, AccountDataType } from './types'
// Import requests
import { loginRequest, getAccountConfigRequest, getAccountDataRequest } from './requests'
// Import debug console log
import { debug } from './utils'
/**

@@ -16,6 +22,14 @@ * @class DeGiro

private readonly pwd: string
private loginResponse: LoginResponseType | undefined
private accountConfig: AccountConfigType | undefined
private accountData: AccountDataType | undefined
constructor(params: DeGiroSettupType) {
this.username = params.username
this.pwd = params.pwd
const { username, pwd } = params
if (!username) throw new Error('DeGiro api needs an username to access')
if (!pwd) throw new Error('DeGiro api needs an password to access')
this.username = username
this.pwd = pwd
}

@@ -27,6 +41,49 @@

login(): never {
throw new Error('Method not implemented.')
login(): Promise<void> {
return new Promise((resolve, reject) => {
loginRequest({ username: this.username, pwd: this.pwd })
.then((loginResponse: LoginResponseType) => {
this.loginResponse = loginResponse
return this.getAccountConfig()
})
.then(() => this.getAccountData())
.then((accountData) => {
resolve()
})
.catch(reject)
})
}
getAccountConfig(): Promise<AccountConfigType> {
return new Promise((resolve, reject) => {
if (!this.loginResponse || !this.loginResponse.sessionId) {
return reject('No session id found.')
}
getAccountConfigRequest(this.loginResponse.sessionId)
.then((accountConfig: AccountConfigType) => {
this.accountConfig = accountConfig
resolve(accountConfig)
})
.catch(reject)
})
}
getAccountData(): Promise<AccountDataType> {
return new Promise((resolve, reject) => {
if (!this.loginResponse || !this.loginResponse.sessionId || !this.accountConfig) {
return reject('No session id found.')
}
getAccountDataRequest(this.loginResponse.sessionId, this.accountConfig)
.then((accountData: AccountDataType) => {
this.accountData = accountData
resolve(accountData)
})
.catch(reject)
})
}
hasLogin(): boolean {
return this.loginResponse !== undefined
}
getCashFunds(): import('./types/CashFoundType').CashFoundType[] {

@@ -33,0 +90,0 @@ throw new Error('Method not implemented.')

@@ -1,3 +0,2 @@

import { CashFoundType, DeGiroSettupType, PortfolioPositionType } from '../types'
import { DeGiro } from '../DeGiro'
import { CashFoundType, AccountConfigType, PortfolioPositionType, AccountDataType } from '../types'

@@ -9,4 +8,10 @@ /**

login(): never
login(): Promise<void>
hasLogin(): boolean
getAccountConfig(): Promise<AccountConfigType>
getAccountData(): Promise<AccountDataType>
getCashFunds(): CashFoundType[]

@@ -13,0 +18,0 @@

import { CashFoundType } from './CashFoundType'
import { DeGiroSettupType } from './DeGiroSettupType'
import { PortfolioPositionType } from './PortfolioPositionType'
import { LoginResponseType } from './LoginResponseType'
import { LoginRequestParamsType } from './LoginRequestParamsType'
import { LoginRequestBodyType } from './LoginRequestBodyType'
import { AccountConfigType } from './AccountConfigType'
import { AccountDataType } from './AccountDataType'

@@ -9,2 +14,7 @@ export {

PortfolioPositionType,
LoginResponseType,
LoginRequestParamsType,
LoginRequestBodyType,
AccountConfigType,
AccountDataType,
}
import DeGiro from './../main'
const degiro: DeGiro = new DeGiro({
username: 'nachoogoomezomg',
pwd: '**********',
username: 'arganzana',
pwd: <string>process.env.DEGIRO_PWD,
})
degiro.printConfig()
degiro.login()
.then(() => {
console.log('Loggin success')
})
.catch((error) => {
throw new Error(error)
})

@@ -8,5 +8,14 @@ {

"semicolon":false,
"import-name": [false, "ignore-modules"]
"import-name": [false, "ignore-modules"],
"max-line-length": [
true,
{
"limit": 150,
"ignore-pattern": "^import |^export {(.*?)}",
"check-strings": true,
"check-regex": true
}
]
},
"rulesDirectory": []
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc