RandomTesting/oldutils.ps1
$Relics = Import-CliXML $PSScriptRoot\data\RelicsData.xml $ItemData = Import-CliXML $PSScriptRoot\data\ItemData.xml Function Get-AveragePrice { param( [string]$partName ) #TODO add in an if for spaces to decide if the conversion is needed? $headers = @{"Accept-Language" = "en"} $url = "https://api.warframe.market/v1/items/$partName/statistics" $response = Invoke-RestMethod -Uri $url -Method Get -Headers $headers $liveData = $response.payload.statistics_live $closedData = $response.payload.statistics_closed $ListedAvg48Hours = [math]::round((($liveData."48hours" | where { $_.order_type -eq "sell" }) | measure avg_price -Average).Average) #$live90d = [math]::round((($liveData."90days" | where { $_.order_type -eq "sell" }) | measure avg_price -Average).Average) $ClosedAvg48Hours = [math]::round((($closedData."48hours" | measure avg_price -Average).Average)) #$closed90d = [math]::round((($closedData."90days" | measure avg_price -Average).Average)) $ListedAvg48Hours, $ClosedAvg48Hours } #this function takes in a part and converts the name to the format that the API uses function Convert-PartName { param( [string]$partName ) $partName = $partName -replace " ", "_" $partName = $partName.ToLower() return $partName } |