Artikelstamm, EZA Vorlagen XLS, WiseApi
This commit is contained in:
46
VERAG_PROG_ALLGEMEIN/Schnittstellen/WISE/cWiseBankApi.vb
Normal file
46
VERAG_PROG_ALLGEMEIN/Schnittstellen/WISE/cWiseBankApi.vb
Normal file
@@ -0,0 +1,46 @@
|
||||
Imports System.Net
|
||||
Imports System.IO
|
||||
Imports System.Text
|
||||
Imports Newtonsoft.Json
|
||||
|
||||
Public Class cWiseBankApi
|
||||
|
||||
Private ReadOnly apiToken As String
|
||||
Private ReadOnly profileId As String
|
||||
Private ReadOnly balanceId As String
|
||||
|
||||
Public Sub New(token As String, profile As String, balance As String)
|
||||
apiToken = token
|
||||
profileId = profile
|
||||
balanceId = balance
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Ruft die Kontoumsätze der letzten 7 Tage ab.
|
||||
''' </summary>
|
||||
Public Function GetLast7DaysStatement() As String
|
||||
Dim fromDate As String = DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd")
|
||||
Dim toDate As String = DateTime.UtcNow.ToString("yyyy-MM-dd")
|
||||
|
||||
Dim url As String =
|
||||
$"https://api.wise.com/v4/profiles/{profileId}/balance-statements/{balanceId}/statement.json?intervalStart={fromDate}&intervalEnd={toDate}"
|
||||
|
||||
Dim request As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
|
||||
request.Method = "GET"
|
||||
request.Headers.Add("Authorization", "Bearer " & apiToken)
|
||||
|
||||
Try
|
||||
Using response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
|
||||
Using reader As New StreamReader(response.GetResponseStream())
|
||||
Return reader.ReadToEnd()
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As WebException
|
||||
Using sr As New StreamReader(ex.Response.GetResponseStream())
|
||||
Dim errorText = sr.ReadToEnd()
|
||||
Throw New Exception("Wise API Fehler: " & errorText)
|
||||
End Using
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user