-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBondora.lua
85 lines (67 loc) · 1.94 KB
/
Bondora.lua
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
WebBanking {
version = 0.1,
url = "https://www.bondora.com",
services = { "Bondora Account" }
}
local connection
function SupportsBank (protocol, bankCode)
return protocol == ProtocolWebBanking and bankCode == "Bondora Account"
end
function InitializeSession (protocol, bankCode, username, username2, password, username3)
connection = Connection()
html = HTML(connection:get(url))
html:xpath("//input[@name='Email']"):attr("value", username)
html:xpath("//input[@name='Password']"):attr("value", password)
connection:request(html:xpath("//form[@action='/login']//button[@type='submit']"):click())
if string.match(connection:getBaseURL(), 'login') then
return LoginFailed
end
end
function ListAccounts (knownAccounts)
local account = {
name = "Bondora Summary",
accountNumber = "Bondora Summary",
currency = currency,
portfolio = true,
type = "AccountTypePortfolio"
}
return {account}
end
function AccountSummary ()
local headers = {accept = "application/json"}
local content = connection:request(
"GET",
"https://www.bondora.com/de/dashboard/overviewnumbers/",
"",
"application/json",
headers
)
return JSON(content):dictionary()
end
function RefreshAccount (account, since)
local s = {}
summary = AccountSummary()
print(summary.Stats[1].Value)
print(summary.Stats[2].Value)
local value = summary.Stats[1].Value
local profit = summary.Stats[2].Value
profit = string.gsub(profit, "€", "")
value = string.gsub(value, "€", "")
profit = string.gsub(profit, "%.", "")
value = string.gsub(value, "%.", "")
print(value)
print(profit)
local security = {
name = "Account",
price = tonumber(value),
quantity = 1,
purchasePrice = tonumber(value) - tonumber(profit),
curreny = nil,
}
table.insert(s, security)
return {securities = s}
end
function EndSession ()
connection:get("https://www.bondora.com/de/authorize/logout/")
return nil
end