Skip to content

Commit

Permalink
Add closes #132
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavecarroll committed Aug 16, 2022
1 parent 92f7a5e commit 67b597c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions BluebirdPS/public/api_v2/lists/Get-TwitterPinnedList.ps1
@@ -0,0 +1,12 @@
function Get-TwitterPinnedList {
[OutputType('BluebirdPS.APIV2.ListInfo.List')]
[CmdletBinding()]
param()

$Request = [TwitterRequest]@{
Endpoint ='https://api.twitter.com/2/users/{0}/pinned_lists' -f $BluebirdPSConfiguration.AuthUserId
ExpansionType = 'List'
}

Invoke-TwitterRequest -RequestParameters $Request
}
31 changes: 31 additions & 0 deletions BluebirdPS/public/api_v2/lists/Set-TwitterPinnedList.ps1
@@ -0,0 +1,31 @@
function Set-TwitterPinnedList {
[CmdletBinding(DefaultParameterSetName='PinList')]
param(
[Parameter(Mandatory,ValueFromPipeline)]
[ValidateObjectNotNullOrEmpty()]
[BluebirdPS.APIV2.ListInfo.List]$List,

[Parameter(ParameterSetName='PinList')]
[switch]$PinList,

[Parameter(ParameterSetName='UnpinList')]
[switch]$UnpinList
)

if ($PSCmdlet.ParameterSetName -eq 'PinList') {
$Request = [TwitterRequest]@{
HttpMethod = 'POST'
Endpoint ='https://api.twitter.com/2/users/{0}/pinned_lists' -f $BluebirdPSConfiguration.AuthUserId
Body = [PSCustomObject]@{ 'list_id' = $List.Id } | ConvertTo-Json
}
} else {
$Request = [TwitterRequest]@{
HttpMethod = 'DELETE'
Endpoint ='https://api.twitter.com/2/users/{0}/pinned_lists/{1}' -f $BluebirdPSConfiguration.AuthUserId,$List.Id
}
}

$SetTwitterPinnedList = Invoke-TwitterRequest -RequestParameters $Request
$PinnedList = $SetTwitterPinnedList ? 'pinned' : 'not pinned'
'List {0} is {1}' -f $List.ToShortString(),$PinnedList
}

0 comments on commit 67b597c

Please sign in to comment.