Shop.psm1
function New-Shop { [CmdletBinding()] param( [Parameter(HelpMessage = "Uid des Shops (synthetische oder echte)")] $ShopUid, [Parameter(Mandatory)] [string]$Bezeichnung, [Parameter(Mandatory, HelpMessage = "Sicherheitseinstellung (erstellt z.B. mit New-Sicherheitseinstellung-Object)")] [PSCustomObject]$SicherheitsEinstellung, [string]$Beschreibung ) process { $Body = [PSCustomObject]@{ type = "Shop"; Bezeichnung = $Bezeichnung; Sicherheitseinstellung = $SicherheitsEinstellung; }; if ($PSBoundParameters.ContainsKey("ShopUid")) { $Body | Add-Member -MemberType NoteProperty -Name "Uid" -Value $ShopUid; } if ($PSBoundParameters.ContainsKey("Beschreibung")) { $Body | Add-Member -MemberType NoteProperty -Name "Beschreibung" -Value $Beschreibung; } $res = Invoke-Weedu -Uri "rest/Shops" -Method POST -Body $Body; return $res; } } function Set-Shop { [CmdletBinding(DefaultParameterSetName = "Default")] param( [Parameter(Mandatory, HelpMessage = "Uid des Shops")] $ShopUid, [Parameter(ParameterSetName = "Uebersetzung", HelpMessage = "Zweistelliger Sprachcode (ISO 639-1), z.B. fr, en oder it")] [string]$Sprache, [string]$Bezeichnung, [string]$Beschreibung ) process { $Body = [PSCustomObject]@{ type = "Shop"; }; $Uid = ConvertTo-WeeduGuid $ShopUid; if ($PSBoundParameters.ContainsKey("Bezeichnung")) { $Body | Add-Member -MemberType NoteProperty -Name "Bezeichnung" -Value $Bezeichnung; } if ($PSBoundParameters.ContainsKey("Beschreibung")) { $Body | Add-Member -MemberType NoteProperty -Name "Beschreibung" -Value $Beschreibung; } if ($PSCmdlet.ParameterSetName -eq "Default") { $res = Invoke-Weedu -Uri "/rest/Shops/{0}" -UriParams $Uid -Method PUT -Body $Body; } else { $res = Invoke-Weedu -Uri "/rest/Shops/{0}/{1}" -UriParams @($Uid, $Sprache) -Method PUT -Body $Body; } return $res; } } function Get-Shop { [CmdletBinding()] param( [Parameter(Mandatory, ValueFromPipeline, HelpMessage = "Uid des Shops")] $ShopUid, [Parameter(HelpMessage = "Zweistelliger Sprachcode (ISO 639-1), z.B. fr, en oder it")] [string]$Sprache ) process { $Uid = ConvertTo-WeeduGuid $ShopUid; if ($PSBoundParameters.ContainsKey("Sprache")) { return Invoke-Weedu -Uri "/rest/Shops/{0}/{1}" -UriParams @($Uid, $Sprache) -Method GET; } else { return Invoke-Weedu -Uri "/rest/Shops/{0}" -UriParams $Uid -Method GET; } } } function Remove-Shop { [CmdletBinding()] param( [Parameter(Mandatory, HelpMessage = "Uid des Shops")] $ShopUid, [Parameter(HelpMessage = "Zweistelliger Sprachcode (ISO 639-1), z.B. fr, en oder it")] [string]$Sprache ) process { $Uid = ConvertTo-WeeduGuid $ShopUid; if ($PSBoundParameters.ContainsKey("Sprache")) { return Invoke-Weedu -Uri "/rest/Shops/{0}/{1}" -UriParams @($Uid, $Sprache) -Method DELETE; } else { return Invoke-Weedu -Uri "/rest/Shops/{0}" -UriParams $Uid -Method DELETE; } } } Export-ModuleMember -function New-Shop Export-ModuleMember -function Set-Shop Export-ModuleMember -function Get-Shop Export-ModuleMember -function Remove-Shop |