Skip to content

Commit

Permalink
Merge pull request #29 from Readify/param-validation
Browse files Browse the repository at this point in the history
Added missing Parameter Validations.
  • Loading branch information
RobFaie authored Feb 23, 2020
2 parents e7e8f7c + 45ea3df commit 6aea940
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions functions/Add-Tag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function Add-Tag {

# Tags to add to entity
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String[]]
$Tag,

Expand Down
1 change: 1 addition & 0 deletions functions/Invoke-Method.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function Invoke-Method {

# Body of the Rest call
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[PSCustomObject]
$Body,

Expand Down
12 changes: 10 additions & 2 deletions functions/New-Ticket.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ function New-Ticket {

# The subject of the ticket
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[String]
$Subject,

# The dynamic content placeholder
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[String]
$RawSubject,

Expand Down Expand Up @@ -99,6 +101,7 @@ function New-Ticket {
# Allowed values are open, pending, hold, solved or closed
[Parameter(Mandatory = $false)]
[ValidateSet('new', 'open', 'pending', 'hold', 'solved', 'closed')]
[String]
$Status,

# An array of tags to add to the ticket.
Expand All @@ -109,6 +112,7 @@ function New-Ticket {

# An ID to link tickets to local records
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[String]
$ExternalId,

Expand Down Expand Up @@ -142,13 +146,14 @@ function New-Ticket {
[Int64]
$ProblemId,

# For tickets of type "task", the due date of the task. Accepts the ISO 8601 date format (yyyy-mm-dd)
# For tickets of type "task", the due date of the task.
[Parameter(Mandatory = $false)]
[DateTime]
$DueAt,

# An array of the custom field objects consisting of ids and values.
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[PSCustomObject[]]
$CustomFields,

Expand Down Expand Up @@ -191,7 +196,6 @@ function New-Ticket {
follower_ids = 'FollowerId'
forum_topic_id = 'ForumTopicId'
problem_id = 'ProblemId'
due_at = 'DueAt'
tags = 'Tags'
custom_fields = 'CustomFields'
via_followup_source_id = 'FollowupId'
Expand All @@ -209,6 +213,10 @@ function New-Ticket {
}
}

if ($PSBoundParameters.ContainsKey('DueAt')) {
$body.ticket['due_at'] = $DueAt.ToString('yyyy-MM-dd')
}

if ($PSCmdlet.ShouldProcess($Subject, "Create Zendesk Ticket")) {
$result = Invoke-Method -Context $Context -Method 'Post' -Path $path -Body $body -Verbose:$VerbosePreference
$result
Expand Down
1 change: 1 addition & 0 deletions functions/Set-Tag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function Set-Tag {

# Tags to set for the entity. Existing tags not included here will be removed.
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String[]]
$Tag,

Expand Down
2 changes: 1 addition & 1 deletion functions/Set-User.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function Set-User {
# Designates whether the user has forum moderation capabilities.
[Parameter(Mandatory = $false,
ParameterSetName = 'Properties')]
[boolean]
[Boolean]
$Moderator,

# Any notes you want to store about the user.
Expand Down
1 change: 0 additions & 1 deletion todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
- Comment Based Help
- Tests
- OAuth Support
- Parameter Validation
- Attachment Uploads
- Usage Compatability Check
- PS Edition/Version Compatability Check
Expand Down

0 comments on commit 6aea940

Please sign in to comment.