Skip to content

Commit

Permalink
Closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
erwindevreugd committed Nov 12, 2017
1 parent e491d6c commit a4c1784
Show file tree
Hide file tree
Showing 24 changed files with 260 additions and 177 deletions.
47 changes: 28 additions & 19 deletions PSTruPortal/Public/Add-Credential.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,68 @@ function Add-Credential {
[string]$SessionKey = $Script:SessionKey,

[Parameter(
Mandatory=$true
ValueFromPipelineByPropertyName=$true
)]
[switch]$UseSSL = $Script:UseSSL,

[Parameter(
ValueFromPipelineByPropertyName=$true
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors,

[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true
)]
[int]$PersonId,

[Parameter(
Mandatory=$true
Mandatory=$true,
ValueFromPipelineByPropertyName=$true
)]
[string]$CardNumber,

[Parameter(
Mandatory=$false
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$IssueCode,

[Parameter(
Mandatory=$false
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$Pin,

[Parameter(
Mandatory=$false
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[string]$ActiveFrom,

[Parameter(
Mandatory=$false
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[string]$ActiveTo,

[Parameter(
Mandatory=$false
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[switch]$AntipassbackExempt,

[Parameter(
Mandatory=$false
)]
[switch]$ExtendedAccess,

[Parameter(
Mandatory=$false
)]
[int[]]$AccessLevels,

[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[switch]$UseSSL = $Script:UseSSL,
[switch]$ExtendedAccess,

[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors
[int[]]$AccessLevels
)

begin {
Expand Down
15 changes: 9 additions & 6 deletions PSTruPortal/Public/Get-AccessLevel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ function Get-AccessLevel {
ValueFromPipelineByPropertyName=$true
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors,

[Parameter()]
[int]$Id,

[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$AccessLevelId,

[Parameter()]
[ValidateRange(1,250)]
Expand All @@ -53,8 +56,8 @@ function Get-AccessLevel {
limit=$Limit;
}

if($Id) {
$uri = "$uri/$Id"
if($AccessLevelId) {
$uri = "$uri/$AccessLevelId"
}

Write-Verbose -Message "$($method) $($uri) $($contentType)"
Expand All @@ -71,7 +74,7 @@ function Get-AccessLevel {
$response = Invoke-RestMethod @message
$response | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Id=$_.id;
AccessLevelId=$_.id;
Name=$_.name;
}
}
Expand Down
15 changes: 9 additions & 6 deletions PSTruPortal/Public/Get-ActionTrigger.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ function Get-ActionTrigger {
ValueFromPipelineByPropertyName=$true
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors,

[Parameter()]
[int]$Id,

[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$ActionTriggerId,

[Parameter()]
[ValidateRange(1,250)]
Expand All @@ -53,8 +56,8 @@ function Get-ActionTrigger {
limit=$Limit;
}

if($Id) {
$uri = "$uri/$Id"
if($ActionTriggerId) {
$uri = "$uri/$ActionTriggerId"
}

Write-Verbose -Message "$($method) $($uri) $($contentType)"
Expand All @@ -71,7 +74,7 @@ function Get-ActionTrigger {
$response = Invoke-RestMethod @message
$response | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Id=$_.id;
ActionTriggerId=$_.id;
Name=$_.name;
}
}
Expand Down
20 changes: 13 additions & 7 deletions PSTruPortal/Public/Get-Credential.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ function Get-Credential {
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors,

[Parameter()]
[int]$Id,
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$CredentialId,

[Parameter()]
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$PersonId,

[Parameter()]
Expand Down Expand Up @@ -56,8 +62,8 @@ function Get-Credential {
limit=$Limit;
}

if($Id) {
$uri = "$uri/$Id"
if($CredentialIdId) {
$uri = "$uri/$CredentialId"
}

if($PersonId) {
Expand All @@ -78,11 +84,11 @@ function Get-Credential {
$response = Invoke-RestMethod @message
$response | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Id=$_.id;
CredentialId=$_.id;
ActiveFrom=$_.activeFrom;
ActiveTo=$_.activeTo;
AntipassbackExempt=$_.antipassbackExempt;
Cardnumber=$_.cardNumber;
CardNumber=$_.cardNumber;
AccessLevels=$_.accessLevels;
Pin=$_.pin;
PersonId=$_.PersonId;
Expand Down
13 changes: 8 additions & 5 deletions PSTruPortal/Public/Get-Device.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ function Get-Device {
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors,

[Parameter()]
[int]$Id,
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$DeviceId,

[Parameter()]
[ValidateRange(1,250)]
Expand All @@ -53,8 +56,8 @@ function Get-Device {
limit=$Limit;
}

if($Id) {
$uri = "$uri/$Id"
if($DeviceId) {
$uri = "$uri/$DeviceId"
}

Write-Verbose -Message "$($method) $($uri) $($contentType)"
Expand All @@ -71,7 +74,7 @@ function Get-Device {
$response = Invoke-RestMethod @message
$response | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Id=$_.id;
DeviceId=$_.id;
Name=$_.name;
}
}
Expand Down
13 changes: 8 additions & 5 deletions PSTruPortal/Public/Get-Door.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ function Get-Door {
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors,

[Parameter()]
[int]$Id,
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$DoorId,

[Parameter()]
[ValidateRange(1,250)]
Expand All @@ -53,8 +56,8 @@ function Get-Door {
limit=$Limit;
}

if($Id) {
$uri = "$uri/$Id"
if($DoorId) {
$uri = "$uri/$DoorId"
}

Write-Verbose -Message "$($method) $($uri) $($contentType)"
Expand All @@ -71,7 +74,7 @@ function Get-Door {
$response = Invoke-RestMethod @message
$response | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Id=$_.id;
DoorId=$_.id;
Name=$_.name;
State=$_.state;
ReaderTamper=$_.readerTemper;
Expand Down
32 changes: 22 additions & 10 deletions PSTruPortal/Public/Get-Event.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,28 @@ function Get-Event {
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors,

[Parameter()]
[int]$Id,
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$EventId,

[Parameter()]
[int]$Type,
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$EventType,

[Parameter()]
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$PersonId,

[Parameter()]
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$DeviceId,

[Parameter()]
Expand Down Expand Up @@ -73,8 +85,8 @@ function Get-Event {
$query.Add("deviceId", $DeviceId)
}

if($Id) {
$uri = "$uri/$Id"
if($EventId) {
$uri = "$uri/$EventId"
}

Write-Verbose -Message "$($method) $($uri) $($contentType)"
Expand All @@ -97,8 +109,8 @@ function Get-Event {
}
$response | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Id=$_.id;
Type=$_.type;
EventId=$_.id;
EventType=$_.type;
Description=$_.description;
PersonId=$_.personId;
PersonName=$_.personName;
Expand Down
13 changes: 8 additions & 5 deletions PSTruPortal/Public/Get-Input.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ function Get-Input {
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors,

[Parameter()]
[int]$Id,
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$InputId,

[Parameter()]
[ValidateRange(1,250)]
Expand All @@ -52,8 +55,8 @@ function Get-Input {
limit=$Limit;
}

if($Id) {
$uri = "$uri/$Id"
if($InputId) {
$uri = "$uri/$InputId"
}

Write-Verbose -Message "$($method) $($uri) $($contentType)"
Expand All @@ -70,7 +73,7 @@ function Get-Input {
$response = Invoke-RestMethod @message
$response | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Id=$_.id;
InputId=$_.id;
Name=$_.name;
State=$_.state;
}
Expand Down
13 changes: 8 additions & 5 deletions PSTruPortal/Public/Get-Output.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ function Get-Output {
)]
[switch]$IgnoreCertificateErrors = $Script:IgnoreCertificateErrors,

[Parameter()]
[int]$Id,
[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$true
)]
[int]$OutputId,

[Parameter()]
[ValidateRange(1,250)]
Expand All @@ -52,8 +55,8 @@ function Get-Output {
limit=$Limit;
}

if($Id) {
$uri = "$uri/$Id"
if($OutputId) {
$uri = "$uri/$OutputId"
}

Write-Verbose -Message "$($method) $($uri) $($contentType)"
Expand All @@ -70,7 +73,7 @@ function Get-Output {
$response = Invoke-RestMethod @message
$response | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Id=$_.id;
OutputId=$_.id;
Name=$_.name;
State=$_.state;
}
Expand Down
Loading

0 comments on commit a4c1784

Please sign in to comment.