-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Readify/sharing-agreements
Adds Sharing Agreement commands. +semver: feature
- Loading branch information
Showing
7 changed files
with
404 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function Get-SharingAgreement { | ||
<# | ||
.SYNOPSIS | ||
Returns a sharing agreement for your account. | ||
.DESCRIPTION | ||
Returns a sharing agreement for your account. | ||
.EXAMPLE | ||
PS C:\> Get-ZendeskSharingAgreement | ||
Lists all sharing agreements | ||
.EXAMPLE | ||
PS C:\> Get-ZendeskSharingAgreement -Id 1 | ||
Gets the details of the sharing agreement with id 1 | ||
#> | ||
[OutputType([PSCustomObject])] | ||
[CmdletBinding(DefaultParameterSetName = 'Default')] | ||
Param ( | ||
|
||
# Unique Id of the sharing agreement to retrieve | ||
[Parameter(Mandatory = $false)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$Id, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
Assert-IsAgent -Context $Context | ||
|
||
if ($PSBoundParameters.ContainsKey('Id')) { | ||
$path = "/api/v2/sharing_agreements/$Id.json" | ||
$key = 'sharing_agreement' | ||
} else { | ||
$path = '/api/v2/sharing_agreements.json' | ||
$key = 'sharing_agreements' | ||
} | ||
|
||
$result = Invoke-Method -Context $Context -Path $path -Verbose:$VerbosePreference | ||
$result | Select-Object -Expand $key | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
function New-SharingAgreement { | ||
<# | ||
.SYNOPSIS | ||
Creates a sharing agreement. | ||
.DESCRIPTION | ||
Creates a sharing agreement. Requires sharing to be enabled on the Zendesk instance. For more information see: https://support.zendesk.com/hc/en-us/articles/203661466-Sharing-tickets-with-other-Zendesk-Support-accounts | ||
.EXAMPLE | ||
PS C:\> New-ZendeskSharingAgreement -RemoteSubdomain 'Foo' | ||
Creates a new sharing agreement with the Foo Zendesk Support instance. | ||
#> | ||
[OutputType([PSCustomObject])] | ||
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] | ||
Param ( | ||
# Name of this sharing agreement | ||
[Parameter(Mandatory = $false)] | ||
[ValidateNotNullOrEmpty()] | ||
[String] | ||
$Name, | ||
|
||
# The direction of the agreement | ||
[Parameter(Mandatory = $false)] | ||
[ValidateSet('inbound', 'outbound')] | ||
[String] | ||
$Type, | ||
|
||
# The status of the agreement | ||
[Parameter(Mandatory = $false)] | ||
[ValidateSet('accepted', 'declined', 'pending', 'inactive')] | ||
[String] | ||
$Status, | ||
|
||
# The Partner System | ||
[Parameter(Mandatory = $false)] | ||
[ValidateSet('jira')] | ||
[String] | ||
$PartnerName, | ||
|
||
# Subdomain of the remote account | ||
[Parameter(Mandatory = $false)] | ||
[ValidateNotNullOrEmpty()] | ||
[String] | ||
$RemoteSubdomain, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
Assert-IsAdmin -Context $Context | ||
|
||
$path = '/api/v2/sharing_agreements.json' | ||
$body = @{ | ||
sharing_agreement = @{ | ||
} | ||
} | ||
|
||
if ($PSBoundParameters.ContainsKey('Name')) { | ||
$body.sharing_agreement['name'] = $Name | ||
} | ||
|
||
if ($PSBoundParameters.ContainsKey('Type')) { | ||
$body.sharing_agreement['type'] = $Type | ||
} | ||
|
||
if ($PSBoundParameters.ContainsKey('Status')) { | ||
$body.sharing_agreement['status'] = $Status | ||
} | ||
|
||
if ($PSBoundParameters.ContainsKey('PartnerName')) { | ||
$body.sharing_agreement['partner_name'] = $PartnerName | ||
} | ||
|
||
if ($PSBoundParameters.ContainsKey('RemoteSubdomain')) { | ||
$body.sharing_agreement['remote_subdomain'] = $RemoteSubdomain | ||
} | ||
|
||
if ($PSCmdlet.ShouldProcess($Name, 'Create Group')) { | ||
$result = Invoke-Method -Context $Context -Method 'Post' -Path $path -Body $body -Verbose:$VerbosePreference | ||
$result | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
function Remove-SharingAgreement { | ||
<# | ||
.SYNOPSIS | ||
Deletes a sharing agreement. | ||
.DESCRIPTION | ||
Deletes a sharing agreement. | ||
.EXAMPLE | ||
PS C:\> Remove-ZendeskSharingAgreement -Id 1 | ||
Deletes the sharing agreement with Id 1 | ||
#> | ||
[OutputType([PSCustomObject])] | ||
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] | ||
Param ( | ||
# Unique Id of sharing agreement to delete | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$Id, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
Assert-IsAdmin -Context $Context | ||
|
||
$path = "/api/v2/sharing_agreements/$Id.json" | ||
|
||
if ($PSCmdlet.ShouldProcess($Id, "Delete Sharing Agreement")) { | ||
$result = Invoke-Method -Context $Context -Method 'Delete' -Path $path -Verbose:$VerbosePreference | ||
$result | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
function Update-SharingAgreement { | ||
<# | ||
.SYNOPSIS | ||
Updates the status of a sharing agreement | ||
.DESCRIPTION | ||
Updates the status of a sharing agreement | ||
.EXAMPLE | ||
PS C:\> Update-SharingAgreement -Id 1 -Status 'accepted' | ||
Accepts the sharing agreement with id 1. | ||
.EXAMPLE | ||
PS C:\> Update-SharingAgreement -Id 1 -Status 'declined' | ||
Declines the sharing agreement with id 1. | ||
#> | ||
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] | ||
Param ( | ||
# Unique Id of the sharing agreement to update | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$Id, | ||
|
||
# The status of the agreement | ||
[Parameter(Mandatory = $true)] | ||
[ValidateSet('accepted', 'declined', 'pending', 'inactive')] | ||
[String] | ||
$Status, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
Assert-IsAdmin -Context $Context | ||
|
||
$path = "/api/v2/sharing_agreements/$Id.json" | ||
$body = @{ | ||
sharing_agreement = @{ | ||
status = $Status | ||
} | ||
} | ||
|
||
if ($PSCmdlet.ShouldProcess($Id, 'Update Sharing Agreement.')) { | ||
$result = Invoke-Method -Context $Context -Method 'Put' -Path $path -Body $body -Verbose:$VerbosePreference | ||
$result | ||
} | ||
} |
Oops, something went wrong.