public/helper/Get-TwitterGeo_ReverseGeocode.ps1

function Get-TwitterGeo_ReverseGeocode {
<#
.SYNOPSIS
    Get places near a location
 
.DESCRIPTION
    GET geo/reverse_geocode
     
    Given a latitude and a longitude, searches for up to 20 places that can be used as a place_id when updating a status.
     
    This request is an informative call and will deliver generalized results about geography.
 
.PARAMETER lat
    The latitude to search around. This parameter will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding long parameter.
 
.PARAMETER long
    The longitude to search around. The valid ranges for longitude are -180.0 to +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding lat parameter.
 
.PARAMETER accuracy
    A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet. If this is not passed in, then it is assumed to be 0m. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
 
.PARAMETER granularity
    This is the minimal granularity of place types to return and must be one of: neighborhood, city, admin or country . If no granularity is provided for the request neighborhood is assumed.
Setting this to city, for example, will find places which have a type of city, admin or country.
 
.PARAMETER max_results
    A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
 
.NOTES
    This helper function was generated by the information provided here:
    https://developer.twitter.com/en/docs/geo/places-near-location/api-reference/get-geo-reverse_geocode
 
#>

    [CmdletBinding()]
    Param(
        [string]$lat,
        [string]$long,
        [string]$accuracy,
        [string]$granularity,
        [string]$max_results
    )
    Begin {

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

        [string]$Method      = 'GET'
        [string]$Resource    = '/geo/reverse_geocode'
        [string]$ResourceUrl = 'https://api.twitter.com/1.1/geo/reverse_geocode.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
        }

        If (-Not $OAuthSettings) { $OAuthSettings = Get-TwitterOAuthSettings -Resource $Resource }
        Invoke-TwitterAPI -Method $Method -ResourceUrl $ResourceUrl -Parameters $Parameters -OAuthSettings $OAuthSettings

    }
    End {

    }
}