Merge branch 'master' of https://verag.visualstudio.com/SDL/_git/SDL
This commit is contained in:
@@ -3,6 +3,7 @@ Imports System.Net
|
||||
Imports System.Text
|
||||
Imports System.Web.UI.WebControls
|
||||
Imports System.Windows.Forms
|
||||
Imports Chilkat
|
||||
Imports Microsoft.Office.Interop.Outlook
|
||||
Imports Newtonsoft.Json
|
||||
Imports Spire.Pdf.Lists
|
||||
@@ -12,10 +13,10 @@ Imports VERAG_PROG_ALLGEMEIN.TESTJSON
|
||||
Public Class cCreditSafeAPI
|
||||
|
||||
'Test
|
||||
Shared API_STRING As String = "https://connect.sandbox.creditsafe.com"
|
||||
'Shared API_STRING As String = "https://connect.sandbox.creditsafe.com"
|
||||
|
||||
'PROD
|
||||
'Shared API_STRING As String = "https://connect.creditsafe.com"
|
||||
Shared API_STRING As String = "https://connect.creditsafe.com"
|
||||
|
||||
Shared token As String = ""
|
||||
Public dataTable As New DataTable()
|
||||
@@ -106,15 +107,32 @@ Public Class cCreditSafeAPI
|
||||
rest.AddHeader("Accept", acceptContentType)
|
||||
|
||||
|
||||
Dim responseJson As String
|
||||
Dim pdfData As New Chilkat.BinData
|
||||
|
||||
Dim responseJson As String = rest.FullRequestNoBody(method, url)
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
MsgBox(rest.LastErrorText)
|
||||
If acceptContentType.Contains("application/pdf") Then
|
||||
|
||||
responseJson = rest.FullRequestNoBodyBd(method, url, pdfData)
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
MsgBox(rest.LastErrorText)
|
||||
Else
|
||||
Return pdfData.ToString
|
||||
End If
|
||||
|
||||
Else
|
||||
|
||||
responseJson = rest.FullRequestNoBody(method, url)
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
MsgBox(rest.LastErrorText)
|
||||
|
||||
Else
|
||||
Return responseJson
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Return responseJson
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
@@ -144,9 +162,6 @@ Public Class cCreditSafeAPI
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, company, "application/json", "GET", token)
|
||||
|
||||
|
||||
'Dim test As String = "{""correlationId"":""9194edd0-1a4a-4520-a332-7306b7c027ca"",""totalSize"":1,""companies"":[{""id"":""AT-X-7256130"",""country"":""AT"",""regNo"":""FN 410356 s"",""vatNo"":[""ATU 68490714""],""safeNo"":""AT05607514"",""name"":""Imex Customs Service GmbH"",""address"":{""simpleValue"":""Autobahngrenze 15, 4975, Suben"",""street"":""Autobahngrenze 15"",""city"":""Suben"",""postCode"":""4975""},""status"":""active"",""officeType"":""headOffice"",""type"":""Ltd"",""dateOfLatestAccounts"":""2021-12-31T00:00:00.000000Z"",""dateOfLatestChange"":""2023-03-03T02:38:30.000Z""}]}"
|
||||
'jsonRespString = test
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
Dim success As Boolean = json.Load(jsonRespString)
|
||||
If (success <> True) Then
|
||||
@@ -207,12 +222,24 @@ Public Class cCreditSafeAPI
|
||||
|
||||
End Function
|
||||
|
||||
Shared Function getReport(company As Company, withPDF As Boolean) As String
|
||||
Dim myUrl As String = API_STRING & "/v1/companies/" & company.creditSafeId
|
||||
Dim acceptContentType = "application/json"
|
||||
If withPDF Then
|
||||
acceptContentType &= "+pdf"
|
||||
Shared Function getReport(ByRef company As Company, withPDF As Boolean) As String 'Shared Function getReport(ByRef company As Company, withPDF As Boolean, ByRef bytes As Byte()) As String
|
||||
Dim myUrl As String = API_STRING & "/v1/companies/" & company.creditSafeId & "/"
|
||||
If company.country = "DE" Then
|
||||
'Abfragen für DE benötigen einen Reason-Code
|
||||
myUrl &= "?customData=de_reason_code::2"
|
||||
myUrl &= "&?language=DE&?template=full"
|
||||
Else
|
||||
|
||||
myUrl &= "?language=DE&?template=full"
|
||||
End If
|
||||
|
||||
Dim acceptContentType = "application/json"
|
||||
'If withPDF Then
|
||||
' acceptContentType &= "+pdf"
|
||||
'End If
|
||||
|
||||
|
||||
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, Nothing, acceptContentType, "GET", token)
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
@@ -222,16 +249,143 @@ Public Class cCreditSafeAPI
|
||||
Return "Verbindungsfehler"
|
||||
End If
|
||||
|
||||
Dim num As Integer = json.SizeOfArray("companies")
|
||||
If num = -1 Then
|
||||
Return json.StringOf("details")
|
||||
|
||||
'Aubbau JSON Object
|
||||
|
||||
' "report" {
|
||||
' "companyIdentification" : {
|
||||
' "basicInformation" : {
|
||||
' "companyRegistrationDate" : "01.01.2022",
|
||||
' "creditScore" : {
|
||||
' "currentCreditRating" : {
|
||||
' "commonValue" : "A",
|
||||
' "providerValue" : {
|
||||
' "value" : "350",
|
||||
'....}
|
||||
' "pdfReportStream": "base64"
|
||||
'},
|
||||
|
||||
|
||||
|
||||
Dim reportObj As Chilkat.JsonObject = json.ObjectOf("report")
|
||||
If (json.LastMethodSuccess = True) Then
|
||||
|
||||
Dim companyIDObj As Chilkat.JsonObject = reportObj.ObjectOf("companyIdentification")
|
||||
If (reportObj.LastMethodSuccess = True) Then
|
||||
|
||||
Dim basicInfoObj As Chilkat.JsonObject = companyIDObj.ObjectOf("basicInformation")
|
||||
If (companyIDObj.LastMethodSuccess = True) Then
|
||||
|
||||
Dim dateTime As New Chilkat.CkDateTime
|
||||
Dim getAsLocal As Boolean = False
|
||||
basicInfoObj.DateOf("companyRegistrationDate", dateTime)
|
||||
company.csDFoundingDate = dateTime.GetAsTimestamp(getAsLocal)
|
||||
Debug.WriteLine(dateTime)
|
||||
|
||||
Else
|
||||
|
||||
Debug.WriteLine("basicInfoObj object not found.")
|
||||
End If
|
||||
|
||||
Else
|
||||
Debug.WriteLine("companyIDObj object not found.")
|
||||
End If
|
||||
|
||||
|
||||
Dim creditScoreObj As Chilkat.JsonObject = reportObj.ObjectOf("creditScore")
|
||||
If (reportObj.LastMethodSuccess = True) Then
|
||||
|
||||
|
||||
Dim creditRatingObj As Chilkat.JsonObject = creditScoreObj.ObjectOf("currentCreditRating")
|
||||
If (creditScoreObj.LastMethodSuccess = True) Then
|
||||
|
||||
company.csRiskclass = creditRatingObj.StringOf("commonValue")
|
||||
|
||||
Dim creditLimitObj As Chilkat.JsonObject = creditRatingObj.ObjectOf("creditLimit")
|
||||
If (creditRatingObj.LastMethodSuccess = True) Then
|
||||
company.csMaxCreditAmount = creditLimitObj.StringOf("value")
|
||||
Else
|
||||
Debug.WriteLine("creditRating object not found.")
|
||||
End If
|
||||
|
||||
Dim providerValueObj As Chilkat.JsonObject = creditRatingObj.ObjectOf("providerValue")
|
||||
If (creditRatingObj.LastMethodSuccess = True) Then
|
||||
company.csIndex = providerValueObj.StringOf("value")
|
||||
Else
|
||||
Debug.WriteLine("providerValue object not found.")
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
|
||||
Debug.WriteLine("currentCreditRating object not found.")
|
||||
End If
|
||||
|
||||
|
||||
Else
|
||||
Debug.WriteLine("creditScore object not found.")
|
||||
Return "creditScore object not found"
|
||||
End If
|
||||
|
||||
Else
|
||||
company.csFailure = json.StringOf("details")
|
||||
End If
|
||||
|
||||
Return "test"
|
||||
'If withPDF Then
|
||||
' Dim sb As New Chilkat.StringBuilder
|
||||
' json.StringOfSb("pdfReportStream", sb)
|
||||
|
||||
' Dim bd As New Chilkat.BinData
|
||||
' bd.AppendEncodedSb(sb, "base64")
|
||||
|
||||
' bytes = Convert.FromBase64String(sb.ToString)
|
||||
|
||||
' Return "mitPDF"
|
||||
|
||||
'End If
|
||||
|
||||
Return "ohnePDF"
|
||||
|
||||
End Function
|
||||
|
||||
Shared Function getPDF(ByRef company As Company) As Byte()
|
||||
|
||||
Dim myUrl As String = API_STRING & "/v1/companies/" & company.creditSafeId & "/"
|
||||
If company.country = "DE" Then
|
||||
'Abfragen für DE benötigen einen Reason-Code
|
||||
myUrl &= "?customData=de_reason_code::2"
|
||||
myUrl &= "&?language=DE"
|
||||
Else
|
||||
|
||||
myUrl &= "?language=DE"
|
||||
End If
|
||||
|
||||
Dim acceptContentType = "application/pdf"
|
||||
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, Nothing, acceptContentType, "GET", token)
|
||||
|
||||
'Dim json As New Chilkat.JsonObject
|
||||
'Dim success As Boolean = json.Load(jsonRespString)
|
||||
'If (success <> True) Then
|
||||
' Debug.WriteLine(json.LastErrorText)
|
||||
|
||||
'End If
|
||||
|
||||
'Dim sb As New Chilkat.StringBuilder
|
||||
'json.StringOfSb("pdfReportStream", sb)
|
||||
|
||||
'Dim bd As New Chilkat.BinData
|
||||
'bd.AppendEncodedSb(sb, "base64")
|
||||
|
||||
'Return Convert.FromBase64String(sb.ToString)
|
||||
If jsonRespString IsNot Nothing Then
|
||||
Return Convert.FromBase64String(jsonRespString)
|
||||
End If
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Shared Sub setSearchParam(ByRef rest As Chilkat.Rest, ByRef company As Company)
|
||||
|
||||
|
||||
@@ -307,6 +461,12 @@ Public Class cCreditSafeAPI
|
||||
Public Property country As String
|
||||
Public Property creditsafeNo As String
|
||||
Public Property lastChecked As Date
|
||||
Public Property csIndex As String
|
||||
Public Property csRiskclass As String
|
||||
Public Property csMaxCreditAmount As String
|
||||
Public Property csDFoundingDate As Date
|
||||
Public Property csPDF As String
|
||||
Public Property csFailure As String
|
||||
|
||||
|
||||
Public Sub New(_name As String, _vatNo As String, _country As String, _creditsafeNo As String, _creditSafeId As String, _lastChecked As Date)
|
||||
|
||||
Reference in New Issue
Block a user