public/helper/Get-TwitterLists_Memberships.ps1

function Get-TwitterLists_Memberships {
<#
.SYNOPSIS
    Create and manage lists

.DESCRIPTION
    GET lists/memberships
    
    Returns the lists the specified user has been added to. If user_id or screen_name are not provided, the memberships for the authenticating user are returned.

.PARAMETER user_id
    The ID of the user for whom to return results. Helpful for disambiguating when a valid user ID is also a valid screen name.

.PARAMETER screen_name
    The screen name of the user for whom to return results. Helpful for disambiguating when a valid screen name is also a user ID.

.PARAMETER count
    The amount of results to return per page. Defaults to 20. No more than 1000 results will ever be returned in a single page.

.PARAMETER cursor
    Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list. It is recommended to always use cursors when the method supports them. See Cursoring for more information.

.PARAMETER filter_to_owned_lists
    When set to true , t or 1 , will return just lists the authenticating user owns, and the user represented by user_id or screen_name is a member of.

.NOTES
    This helper function was generated by the information provided here:
    https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-memberships

#>

    [CmdletBinding()]
    Param(
        [string]$user_id,
        [string]$screen_name,
        [string]$count,
        [string]$cursor,
        [string]$filter_to_owned_lists
    )
    Begin {

        [hashtable]$Parameters = $PSBoundParameters
                   $CmdletBindingParameters | ForEach-Object { $Parameters.Remove($_) }

        [string]$Method      = 'GET'
        [string]$Resource    = '/lists/memberships'
        [string]$ResourceUrl = 'https://api.twitter.com/1.1/lists/memberships.json'

    }
    Process {

        # Find & Replace any ResourceUrl parameters.
        $UrlParameters = [regex]::Matches($ResourceUrl, '(?<!\w):\w+')
        ForEach ($UrlParameter in $UrlParameters) {
            $UrlParameterValue = $Parameters["$($UrlParameter.Value.TrimStart(":"))"]
            $ResourceUrl = $ResourceUrl -Replace $UrlParameter.Value, $UrlParameterValue
        }

        $OAuthSettings = Get-TwitterOAuthSettings -Resource $Resource
        Invoke-TwitterAPI -Method $Method -ResourceUrl $ResourceUrl -Parameters $Parameters -OAuthSettings $OAuthSettings

    }
    End {

    }
}