Created
May 1, 2025 03:20
-
-
Save jorgeasaurus/a8fefe818df11867feb665ffc83272e2 to your computer and use it in GitHub Desktop.
Retrieves a random rejection reason from the No-as-a-Service API.
This file contains hidden or 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
function Invoke-Rejection { | |
<# | |
.SYNOPSIS | |
Retrieves a random rejection reason from the No-as-a-Service API. | |
.DESCRIPTION | |
Sends an HTTP GET request to the No-as-a-Service (NAAS) API endpoint and returns a randomly generated rejection message. | |
This function is useful for applications requiring humorous or creative rejection responses. | |
.INPUTS | |
None. This function does not accept pipeline input. | |
.OUTPUTS | |
System.String. Returns a rejection reason as a string. | |
.EXAMPLE | |
PS C:\> Invoke-Rejection | |
"This feels like something Future Me would yell at Present Me for agreeing to." | |
Retrieves a random rejection reason from the NAAS API. | |
.NOTES | |
Author: Jorgeasaurus | |
Date: April 30, 2025 | |
Source: https://github.com/hotheadhacker/no-as-a-service | |
#> | |
[CmdletBinding()] | |
param () | |
# Define the API endpoint URL | |
$url = 'https://naas.isalman.dev/no' | |
try { | |
# Send an HTTP GET request to the API and parse the JSON response | |
$response = Invoke-RestMethod -Uri $url -Method Get -ErrorAction Stop | |
# Return the 'reason' field from the response | |
return $response.reason | |
} catch { | |
# Output an error message if the API request fails | |
Write-Error "Failed to retrieve rejection reason: $_" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment