src/Cmdlets/Test-ApiKey.psm1
|
using namespace System.Net.Http using module ../Blog.psm1 using module ../Client.psm1 <# .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 $_.Exception } } } |