Public/Get-ShellPhishSongs.ps1
|
function Get-ShellPhishSongs { <# .SYNOPSIS Retrieve song records from Phish.net. .DESCRIPTION Returns all songs, or a single song by ID or slug. .PARAMETER ApiKey Your Phish.net API key. Defaults to $env:PHISH_KEY. .PARAMETER Id Numeric song ID. .PARAMETER Slug URL slug of the song. .EXAMPLE PS C:\> Get-ShellPhishSongs .EXAMPLE PS C:\> Get-ShellPhishSongs -Slug tweezer #> [CmdletBinding(DefaultParameterSetName = 'Default')] param ( [Parameter(Position=0)] [string]$ApiKey = $env:PHISH_KEY, [Parameter()] [ValidateSet('json','xml','html')] [string]$Format = 'json', [Parameter(ParameterSetName='ById', Mandatory=$true)] [string]$Id, [Parameter(ParameterSetName='BySlug', Mandatory=$true)] [string]$Slug, [Parameter()][string]$OrderBy, [Parameter()][ValidateSet('asc','desc')][string]$Direction, [Parameter()][int]$Limit, [Parameter()][switch]$NoHeader ) switch ($PSCmdlet.ParameterSetName) { 'ById' { $endpoint = "songs/$Id.$Format" } 'BySlug' { $endpoint = "songs/slug/$Slug.$Format" } default { $endpoint = "songs.$Format" } } $qp = Get-CommonQueryParams -OrderBy $OrderBy -Direction $Direction -Limit $Limit -NoHeader:$NoHeader Invoke-ShellPhishApi -Endpoint $endpoint -QueryParams $qp -ApiKey $ApiKey } |