Skip to content

Commit

Permalink
Fixed api limiting saving for #13 to avoid problems with PSCore
Browse files Browse the repository at this point in the history
  • Loading branch information
gitfvb committed Jul 15, 2024
1 parent 5b5cc02 commit 6c9768d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions AptecoPSFramework/plugins/InxmailPro/Public/XPro/Invoke-XPro.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function Invoke-XPro {
If ( $Paging -eq $true ) {

Write-Verbose "Jumping into next page"
$Script:pluginDebug = $wr
#$Script:pluginDebug = $wr

# If the result equals the pagesize, try it one more time with the next page
If ( $null -ne $wr."_links".next ) {
Expand Down Expand Up @@ -241,10 +241,10 @@ function Invoke-XPro {
# SAVE CURRENT RATE
#-----------------------------------------------

#$Script:pluginDebug = $req
$apiRateLimit = $req.OriginalResponse.Headers."X-RateLimit-Limit"
$apiRateRemaining = $req.OriginalResponse.Headers."X-RateLimit-Remaining"
$apiRateReset = ( Get-Unixtime ) + $req.OriginalResponse.Headers."X-RateLimit-Reset"
#$Script:pluginDebug = $req.OriginalResponse.Headers
$apiRateLimit = [UInt64]( $req.OriginalResponse.Headers."X-RateLimit-Limit".trim() )
$apiRateRemaining = [UInt64]( $req.OriginalResponse.Headers."X-RateLimit-Remaining".trim() )
$apiRateReset = ( Get-Unixtime ) + [UInt64]( $req.OriginalResponse.Headers."X-RateLimit-Reset".trim() )
If ( $Script:variableCache.Keys -contains "api_rate_remaining" ) {
$Script:variableCache."api_rate_limit" = $apiRateLimit # Request limit per minute
$Script:variableCache."api_rate_remaining" = $apiRateRemaining # The number of requests left for the time window
Expand Down

0 comments on commit 6c9768d

Please sign in to comment.