Sources/Test-ApiKey.ps1
|
using namespace Belin.Akismet using namespace System.Net.Http <# .SYNOPSIS Checks the API key against the service database, and returns a value indicating whether it is valid. .INPUTS The Akismet API key. .OUTPUTS `$true` if the specified API key is valid, otherwise `$false`. #> function Test-ApiKey { [CmdletBinding()] [OutputType([bool])] param ( # The Akismet API key. [Parameter(Mandatory, Position = 0, ValueFromPipeline)] [string] $ApiKey, # The front page or home URL of the instance making requests. [Parameter(Mandatory)] [Blog] $Blog ) process { try { [Client]::new($ApiKey, $Blog).VerifyKey() } catch [HttpRequestException] { Write-Error $_ } } } |