-
Notifications
You must be signed in to change notification settings - Fork 1
/
swaper.lua
57 lines (49 loc) · 1.56 KB
/
swaper.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
WebBanking {
version = 0.1,
url = "https://www.swaper.com",
services = { "Swaper" }
}
local connection
function SupportsBank (protocol, bankCode)
return protocol == ProtocolWebBanking and bankCode == "Swaper"
end
function InitializeSession (protocol, bankCode, username, username2, password, username3)
connection = Connection()
content, charset, mimeType, filename, headers = connection:request("POST",
"https://www.swaper.com/rest/public/login", '{"name":"' .. username .. '", "password":"' .. password .. '"}', "application/json;charset=UTF-8")
local token = headers["_csrf"]
headers = {accept = "application/json",Referer="https://www.swaper.com/"}
headers["X-XSRF-TOKEN"]=token
connection:request("GET","https://www.swaper.com/rest/public/logged-in","","",headers)
end
function ListAccounts (knownAccounts)
-- Return array of accounts.
local account = {
name = "Swaper Account",
owner = "",
accountNumber = "1",
bankCode = "1",
currency = "EUR",
type = AccountTypeGiro
}
return {account}
end
function RefreshAccount (account, since)
local s = {}
summary = AccountSummary()
return {balance=tonumber(summary.accountValue) ,transactions={}}
end
function AccountSummary ()
local content = connection:request(
"GET",
"https://www.swaper.com/rest/public/profile/overview",
"",
"application/x-www-form-urlencoded; charset=UTF-8",
headers
)
return JSON(content):dictionary()
end
function EndSession ()
connection:request("GET","https://www.swaper.com/rest/public/logout","","",headers)
return nil
end