test code that turned prod...
This commit is contained in:
parent
543d570024
commit
15ca98ef23
@ -1,4 +1,4 @@
|
|||||||
$APIToken = 'szjxBgQNQSW1xq2ByjKB'
|
$APIToken = 'iXZU8DNKth2qWaDjDck9'
|
||||||
$APIUrl = 'https://app3.archisnapper.com/api/public/v1/'
|
$APIUrl = 'https://app3.archisnapper.com/api/public/v1/'
|
||||||
|
|
||||||
$url_APIToken = '?auth_token=' + $APIToken
|
$url_APIToken = '?auth_token=' + $APIToken
|
||||||
@ -7,11 +7,62 @@ $header = @{
|
|||||||
auth_token = $APIToken
|
auth_token = $APIToken
|
||||||
} | ConvertTo-Json
|
} | ConvertTo-Json
|
||||||
|
|
||||||
|
$OutputPathBase = "M:\N-Data\FieldReports\TestPath"
|
||||||
|
|
||||||
# get list of projects
|
# get list of projects
|
||||||
$URI = $APIUrl+'sites.json'+$url_APIToken
|
# https://docs.archisnapper.com/reference/retrieving-your-projects
|
||||||
|
$page = 1 # init counter
|
||||||
|
|
||||||
|
do {
|
||||||
|
$URI = $APIUrl + 'sites.json' + $url_APIToken + '&page=' + $page
|
||||||
$response = Invoke-WebRequest -Uri $URI -Method Get
|
$response = Invoke-WebRequest -Uri $URI -Method Get
|
||||||
|
|
||||||
|
|
||||||
$ProjectList = $response.Content | convertfrom-json
|
$ProjectList = $response.Content | convertfrom-json
|
||||||
|
|
||||||
|
foreach ($project in $ProjectList) {
|
||||||
|
|
||||||
|
$project_Name = $Project.name
|
||||||
|
$project_number = $project.unique_id
|
||||||
|
$OutputPathBase_Project = $OutputPathBase + '\' + $project_number + '-' + $project_Name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$project.visits | foreach -Parallel {
|
||||||
|
$pathExist = Test-Path $USING:OutputPathBase_Project -ErrorAction SilentlyContinue
|
||||||
|
if (!($pathExist)) {
|
||||||
|
New-Item -Path $USING:OutputPathBase_Project -ItemType Directory
|
||||||
|
}
|
||||||
|
if ($_) {
|
||||||
|
$testURI = $_.pdf_link + '&auth_token=' + $USING:APIToken
|
||||||
|
$Outfile = $USING:OutputPathBase_Project + '\' + $_.unique_id + ".pdf"
|
||||||
|
Invoke-WebRequest -Uri $testURI -OutFile $Outfile
|
||||||
|
}
|
||||||
|
} -ThrottleLimit 10
|
||||||
|
# foreach ($visit in $Project.visits) {
|
||||||
|
# $pathExist = Test-Path $OutputPathBase_Project -ErrorAction SilentlyContinue
|
||||||
|
# if (!($pathExist)) {
|
||||||
|
# New-Item -Path $OutputPathBase_Project -ItemType Directory
|
||||||
|
# }
|
||||||
|
# if ($visit) {
|
||||||
|
# $testURI = $visit.pdf_link + '&auth_token=' + $APIToken
|
||||||
|
# $Outfile = $OutputPathBase_Project + '\' + $visit.unique_id + ".pdf"
|
||||||
|
# Invoke-WebRequest -Uri $testURI -OutFile $Outfile
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
$page++
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} until (
|
||||||
|
$response.Content -eq $null
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user