Public/Get-ShellPhishShows.ps1
|
function Get-ShellPhishShows { <# .SYNOPSIS Retrieve show records from Phish.net. .DESCRIPTION Returns shows filtered by ID, artist, artist ID, year, month, day, or date. Called without a filter it returns all shows. .PARAMETER ApiKey Your Phish.net API key. Defaults to $env:PHISH_KEY. .PARAMETER Format Response format: json, xml, html. Default is json. .PARAMETER ShowId Numeric show ID. .PARAMETER Artist Artist slug/name (e.g. "phish"). Uses the API's native artist path. .PARAMETER ArtistId Numeric artist ID. .PARAMETER Year Four-digit show year. .PARAMETER Month Two-digit show month (01-12). .PARAMETER Day Two-digit show day (01-31). .PARAMETER Date Show date in YYYY-MM-DD format. .EXAMPLE PS C:\> Get-ShellPhishShows .EXAMPLE PS C:\> Get-ShellPhishShows -ShowId 1252683584 .EXAMPLE PS C:\> Get-ShellPhishShows -Artist phish -OrderBy showdate -Direction desc -Limit 5 .EXAMPLE PS C:\> Get-ShellPhishShows -Year 1997 #> [CmdletBinding(DefaultParameterSetName = 'Default')] param ( [Parameter(Position=0)] [string]$ApiKey = $env:PHISH_KEY, [Parameter()] [ValidateSet('json','xml','html')] [string]$Format = 'json', [Parameter(ParameterSetName='ByShowId', Mandatory=$true)] [string]$ShowId, [Parameter(ParameterSetName='ByArtist', Mandatory=$true)] [string]$Artist, [Parameter(ParameterSetName='ByArtistId', Mandatory=$true)] [string]$ArtistId, [Parameter(ParameterSetName='ByYear', Mandatory=$true)] [ValidatePattern('^\d{4}$')] [string]$Year, [Parameter(ParameterSetName='ByMonth', Mandatory=$true)] [ValidatePattern('^\d{2}$')] [string]$Month, [Parameter(ParameterSetName='ByDay', Mandatory=$true)] [ValidatePattern('^\d{2}$')] [string]$Day, [Parameter(ParameterSetName='ByDate', Mandatory=$true)] [ValidatePattern('^\d{4}-\d{2}-\d{2}$')] [string]$Date, [Parameter()][string]$OrderBy, [Parameter()][ValidateSet('asc','desc')][string]$Direction, [Parameter()][int]$Limit, [Parameter()][switch]$NoHeader ) switch ($PSCmdlet.ParameterSetName) { 'ByShowId' { $endpoint = "shows/showid/$ShowId.$Format" } 'ByArtist' { $endpoint = "shows/artist/$Artist.$Format" } 'ByArtistId' { $endpoint = "shows/artistid/$ArtistId.$Format" } 'ByYear' { $endpoint = "shows/showyear/$Year.$Format" } 'ByMonth' { $endpoint = "shows/showmonth/$Month.$Format" } 'ByDay' { $endpoint = "shows/showday/$Day.$Format" } 'ByDate' { $endpoint = "shows/showdate/$Date.$Format" } default { $endpoint = "shows.$Format" } } $qp = Get-CommonQueryParams -OrderBy $OrderBy -Direction $Direction -Limit $Limit -NoHeader:$NoHeader Invoke-ShellPhishApi -Endpoint $endpoint -QueryParams $qp -ApiKey $ApiKey } |