creditsafeAPI Monitoring, Kundenuebersicht, Zugferd, etc.

This commit is contained in:
2025-08-29 16:42:15 +02:00
parent fcb243e9a9
commit 1de5f5b8b5
4 changed files with 139 additions and 14 deletions

View File

@@ -96,7 +96,7 @@ Public Class cCreditSafeAPI
Shared Function SendGetRequestWithAuthHeader(url As String, company As Company, acceptContentType As String, method As String, authenticationToken As String, ByRef failureDesc As String) As String
Shared Function SendGetRequestWithAuthHeader(url As String, company As Company, acceptContentType As String, method As String, authenticationToken As String, ByRef failureDesc As String, Optional isMonitoring As Boolean = False) As String
Try
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
@@ -117,7 +117,7 @@ Public Class cCreditSafeAPI
rest.ClearAllQueryParams()
If company IsNot Nothing Then
If company IsNot Nothing AndAlso Not isMonitoring Then
setSearchParam(rest, company)
@@ -131,6 +131,42 @@ Public Class cCreditSafeAPI
Dim responseJson As String
Dim pdfData As New Chilkat.BinData
If isMonitoring Then
Dim json As New Chilkat.JsonObject
success = json.UpdateString("id", company.creditSafeId)
success = json.UpdateString("personalReference", "VERAG AG")
success = json.UpdateString("freeText", "hinzugefügt am " & Today.ToShortDateString)
success = json.UpdateString("personalLimit", "")
Debug.WriteLine(json.Emit())
Dim sbRequestBody As New Chilkat.StringBuilder
json.EmitSb(sbRequestBody)
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestSb(method, url, sbRequestBody, sbResponseBody)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
failureDesc = rest.LastErrorText
Return failureDesc
Else
If (rest.ResponseStatusCode <> 200) Then
failureDesc = rest.ResponseStatusText & IIf(responseJson <> "", vbNewLine & responseJson, "")
Return failureDesc
Else
Return responseJson
End If
End If
End If
If acceptContentType.Contains("application/pdf") Then
responseJson = rest.FullRequestNoBodyBd(method, url, pdfData)
@@ -193,6 +229,10 @@ Public Class cCreditSafeAPI
End Function
Shared Function authenticate(Optional username As String = "", Optional password As String = "") As String
Dim myUri As String = API_STRING & "/v1/authenticate"
@@ -208,6 +248,16 @@ Public Class cCreditSafeAPI
End Function
Shared Function AddCompanyToPortfolio(company As Company, Optional PortfolioID As String = "1662419") As String
Dim myUri As String = API_STRING & "/v1/monitoring/portfolios/" & PortfolioID & "/companies" 'Default
Dim jsonRespString = SendGetRequestWithAuthHeader(myUri, company, "application/json", "POST", token, "", True)
Return jsonRespString
End Function
Shared Function searchCompanies(company As Company, ByRef dataTable As DataTable) As String
@@ -377,8 +427,8 @@ Public Class cCreditSafeAPI
R("ruleName") = compObj.StringOf("ruleName")
R("localEventCode") = compObj.StringOf("localEventCode")
R("globalEventCode") = compObj.StringOf("globalEventCode")
R("newValue") = compObj.StringOf("newValue")
R("oldValue") = compObj.StringOf("oldValue")
R("newValue") = compObj.StringOf("newValue")
R("eventDate") = dateTime.GetAsTimestamp(getAsLocal)
R("createdDate") = dateTime.GetAsTimestamp(getAsLocal)
dtEvents.Rows.Add(R)
@@ -387,6 +437,13 @@ Public Class cCreditSafeAPI
End While
Next
If dtEvents.Rows.Count > 1 Then
dtEvents.DefaultView.Sort = "eventDate ASC"
dtEvents = dtEvents.DefaultView.ToTable
End If
Return "Anzahl gefundener Datensätze: " & numCompanies
End Function