-
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 #11 from Readify/identities +semver: feature
Added support for User Identity endpoints.
- Loading branch information
Showing
14 changed files
with
851 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
function Get-UserIdentity { | ||
<# | ||
.SYNOPSIS | ||
Returns user identities for a given user id. | ||
.DESCRIPTION | ||
Returns all user identities for a given user id or shows the identity with the given id. | ||
.EXAMPLE | ||
PS C:\> Get-UserIdentity -UserId `427427011998` | ||
Gets all User Identities for the User with Id `427427011998` | ||
.EXAMPLE | ||
PS C:\> Get-UserIdentity -UserId `427427011998` -Id `211258542687` | ||
Gets the User Identity `211258542687` for the User with Id `427427011998` | ||
.EXAMPLE | ||
PS C:\> Get-UserIdentity -UserId `427427011998` -Context $context | ||
Gets all User Identities for the User with Id `427427011998` providing the optional Zendesk Context `$context` | ||
#> | ||
[OutputType([PSCustomObject])] | ||
[CMDletBinding()] | ||
Param ( | ||
# Unique Id of the user identity to retrieve | ||
[Parameter(Mandatory = $false)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$Id, | ||
|
||
# Unique Id of the user to retrieve identities for | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$UserId, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
if ($PSBoundParameters.ContainsKey('Id')) { | ||
$path = "/api/v2/users/$UserId/identities/$Id.json" | ||
$key = 'identity' | ||
} else { | ||
$path = "/api/v2/users/$UserId/identities.json" | ||
$key = 'identities' | ||
} | ||
|
||
$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
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,99 @@ | ||
|
||
function New-UserIdentity { | ||
<# | ||
.SYNOPSIS | ||
Adds a new identity to a user's profile. | ||
.DESCRIPTION | ||
Adds a new identity to a user's profile. | ||
.EXAMPLE | ||
PS C:\> New-UserIdentity -UserId '427427011998 -Type 'email' -Value '[email protected]' | ||
Adds the email address `[email protected]` to the user `427427011998` | ||
.EXAMPLE | ||
PS C:\> New-UserIdentity -UserId '427427011998 -Type 'twitter' -Value 'username' | ||
Adds the twitter account `username` to the user `427427011998` | ||
.EXAMPLE | ||
PS C:\> New-UserIdentity -UserId '427427011998 -Type 'facebook' -Value '855769377321' | ||
Adds the facebook account `855769377321` to the user `427427011998` | ||
.EXAMPLE | ||
PS C:\> New-UserIdentity -UserId '427427011998 -Type 'google' -Value '[email protected]' | ||
Adds the google account `[email protected]` to the user `427427011998` | ||
.EXAMPLE | ||
PS C:\> New-UserIdentity -UserId '427427011998 -Type 'phone_number' -Value '+1 555-123-4567' | ||
Adds the phone_number `+1 555-123-4567` to the user `427427011998` | ||
.EXAMPLE | ||
PS C:\> New-UserIdentity -UserId '427427011998 -Type 'agent_fowarding' -Value '+1 555-123-4567' | ||
Adds the agent_fowarding number `+1 555-123-4567` to the user `427427011998` | ||
.EXAMPLE | ||
PS C:\> New-UserIdentity -UserId '427427011998 -Type 'email' -Value '[email protected]' -Verified | ||
Adds the email address `[email protected]` to the user `427427011998` and marks it as verified | ||
.EXAMPLE | ||
PS C:\> New-UserIdentity -UserId '427427011998 -Type 'email' -Value '[email protected]' -Primary | ||
Adds the email address `[email protected]` to the user `427427011998` as their primary identity | ||
.EXAMPLE | ||
PS C:\> New-UserIdentity -Context $context -UserId '427427011998 -Type 'email' -Value '[email protected]' | ||
Adds the email address `[email protected]` to the user `427427011998` using a Zendesk Context returned from `Get-ZendeskConnection` | ||
#> | ||
[OutputType([PSCustomObject])] | ||
[CMDletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High', DefaultParameterSetName = 'Default')] | ||
Param ( | ||
# The id of the user | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$UserId, | ||
|
||
# The Type of the Identity. | ||
[Parameter(Mandatory = $true)] | ||
[ValidateSet('email', 'twitter', 'facebook', 'google', 'phone_number', 'agent_fowarding', 'sdk')] | ||
[String] | ||
$Type, | ||
|
||
# The identifier for this identity, such as an email address | ||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[String] | ||
$Value, | ||
|
||
# If the identity has been verified | ||
[Parameter(Mandatory = $true, ParameterSetName = 'Verified')] | ||
[Switch] | ||
$Verified, | ||
|
||
# If the identity is the primary identity. | ||
[Parameter(Mandatory = $false, ParameterSetName = 'Verified')] | ||
[Switch] | ||
$Primary, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
$path = "/api/v2/users/$UserId/identities.json" | ||
$body = @{ | ||
identity = @{ | ||
user_id = $UserId | ||
type = $Type | ||
value = $Value | ||
verified = [Boolean]$Verified | ||
primary = [Boolean]$Primary | ||
} | ||
} | ||
|
||
if ($PSCmdlet.ShouldProcess($Value, 'Add User Identity')) { | ||
$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,46 @@ | ||
|
||
function Remove-UserIdentity { | ||
<# | ||
.SYNOPSIS | ||
Delete the specified User Identity | ||
.DESCRIPTION | ||
Delete the specified User Identity | ||
.EXAMPLE | ||
PS C:\> Remove-UserIdentity -UserId `427427011998` -Id `211258542687` | ||
Deletes the User Identity `211258542687` for the User with Id `427427011998` | ||
.EXAMPLE | ||
PS C:\> Remove-UserIdentity -Context $context -UserId `427427011998` -Id `211258542687` | ||
Deletes the User Identity `211258542687` for the User with Id `427427011998` specifying the optional Context | ||
#> | ||
[OutputType([PSCustomObject])] | ||
[CMDletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] | ||
Param ( | ||
# Unique Id of the user identity to delete | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$Id, | ||
|
||
# Unique Id of the user whose identity is to be deleted | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$UserId, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
$path = "/api/v2/users/$UserId/identities/$Id.json" | ||
|
||
if ($PSCmdlet.ShouldProcess($Id, 'Delete User Identity')) { | ||
$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,42 @@ | ||
|
||
function Send-UserIdentityVerification { | ||
<# | ||
.SYNOPSIS | ||
Sends the user a verification email with a link to verify ownership of the email address. | ||
.DESCRIPTION | ||
Sends the user a verification email with a link to verify ownership of the email address. | ||
.EXAMPLE | ||
PS C:\> Send-UserIdentityVerification -UserId `427427011998` -Id `211258542687` | ||
Triggers a Zendesk Identity Verification Email for User Identity `211258542687` | ||
#> | ||
[OutputType([PSCustomObject])] | ||
[CMDletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] | ||
Param ( | ||
# Unique Id of the user identity to verify | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$Id, | ||
|
||
# Unique Id of the user whose identity to verify | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$UserId, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
$path = "/api/v2/users/$UserId/identities/$Id/request_verification.json" | ||
|
||
if ($PSCmdlet.ShouldProcess('Send a User Identity Verification', $Id)) { | ||
$result = Invoke-Method -Context $Context -Method 'Put' -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,41 @@ | ||
|
||
function Set-UserIdentityAsPrimary { | ||
<# | ||
.SYNOPSIS | ||
Sets the specified identity as primary. | ||
.DESCRIPTION | ||
Sets the specified identity as primary. | ||
.EXAMPLE | ||
PS C:\> Set-UserIdentityAsPrimary -UserId `427427011998` -Id `211258542687` | ||
Sets the User Identity `211258542687` for the User with Id `427427011998` as their primary Identity | ||
#> | ||
[OutputType([PSCustomObject])] | ||
[CMDletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] | ||
Param ( | ||
# Unique Id of the user identity to make primary | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$Id, | ||
|
||
# Unique Id of the user | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$UserId, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
$path = "/api/v2/users/$UserId/identities/$Id/make_primary" | ||
|
||
if ($PSCmdlet.ShouldProcess('Set User Identity as Primary', $Id)) { | ||
$result = Invoke-Method -Context $Context -Method 'Put' -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,42 @@ | ||
|
||
function Set-UserIdentityAsVerified { | ||
<# | ||
.SYNOPSIS | ||
Sets the specified identity as verified. | ||
.DESCRIPTION | ||
Sets the specified identity as verified. | ||
.EXAMPLE | ||
PS C:\> Set-UserIdentityAsVerified -UserId `427427011998` -Id `211258542687` | ||
Sets the User Identity `211258542687` for the User with Id `427427011998` as verified | ||
#> | ||
[OutputType([PSCustomObject])] | ||
[CMDletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] | ||
Param ( | ||
# Unique Id of the user identity to mark as verified | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$Id, | ||
|
||
# Unique Id of the user | ||
[Parameter(Mandatory = $true)] | ||
[ValidateRange(1, [Int64]::MaxValue)] | ||
[Int64] | ||
$UserId, | ||
|
||
# Zendesk Connection Context from `Get-ZendeskConnection` | ||
[Parameter(Mandatory = $false)] | ||
[PSTypeName('ZendeskContext')] | ||
[PSCustomObject] | ||
$Context = $null | ||
) | ||
|
||
$path = "/api/v2/users/$UserId/identities/$Id/verify" | ||
|
||
if ($PSCmdlet.ShouldProcess('Set User Identity as Verified', $Id)) { | ||
$result = Invoke-Method -Context $Context -Method 'Put' -Path $path -Verbose:$VerbosePreference | ||
$result | ||
} | ||
|
||
} |
Oops, something went wrong.