Wdrożenie API do komunikacji z InterCARS z AUTOSTACJA

W celu komunikacji z API InterCARS – pobieranie faktur z InterCars do programu AutoStacja utworzyłem prosty skrypt w powershell:

$dzisiejszydzien = (Get-Date).ToString(’yyyyMMdd’)

Get-ChildItem -Path D:\SOFTVIG\PROGRAM\AUTOSTACJA3\import-ic\SKRYPT -Include . -File -Recurse | foreach { $_.Delete()}

D:\CURL\curl-7.66.0_2-win64-mingw\curl-7.66.0-win64-mingw\bin\curl.exe –location -o „getinvoices.txt” –request GET „https://katalog.intercars.com.pl/api/v2/External/GetInvoices?from=20200401&to=$dzisiejszydzien” –header „kh_kod: xxxx” –header „token: xxxx”

Get-Content getinvoices.txt | Select-String -Pattern „” | Out-File id-faktur.txt (Get-Content id-faktur.txt).replace(”, ”) | Out-File test2.txt (Get-Content test2.txt).replace(”, ”) | Out-File test3.txt
(Get-Content test3.txt).replace(’ ’, ”) | Out-File test4.txt
(Get-Content test4.txt | Select-Object -Skip 1) | Out-File wynik-id.txt

foreach($line in Get-Content wynik-id.txt) {
if($line -match $regex){

D:\CURL\curl-7.66.0_2-win64-mingw\curl-7.66.0-win64-mingw\bin\curl.exe –location -o „D:\SOFTVIG\PROGRAM\AUTOSTACJA3\import-ic\FV_$line.XML” –request GET „https://katalog.intercars.com.pl/api/v2/External/GetInvoice?id=$line” –header „kh_kod: xxxx” –header „token: xxxx”

}

}

Dodaj komentarz