diff --git a/src/github/gh-notification-delete.sh b/src/github/gh-notification-delete.sh new file mode 100755 index 0000000..50fcceb --- /dev/null +++ b/src/github/gh-notification-delete.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# This section loads configuration files needed to set environment variables +# such as GITHUB_TOKEN. If these variables are already exported globally in the shell, +# the files below can remain commented out. Otherwise, uncomment the appropriate +# file(s) as needed. This particular script only needs GITHUB_TOKEN to function properly. + +# source "$GITNAP/utils/auth.sh" +# source "$GITNAP/utils/settings.sh" + + + +function delete_github_notifications() { + local NOTIFICATION_ID + local endpoint + local response + local tmp_file + + NOTIFICATION_ID="$1" + + # Checks if the parameter was provided. + if [[ -z "$NOTIFICATION_ID" ]]; then + echo "Provide id notification to delete" + exit 1 + fi + + # API Endpoint + endpoint="https://api.github.com/notifications/threads/$NOTIFICATION_ID" + + # Delete notifications + response=$(curl -sSL -X DELETE "$endpoint" \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" ) + + echo "$response" + +} + +delete_github_notifications "$1" diff --git a/src/github/gh-notification-list.sh b/src/github/gh-notification-list.sh new file mode 100755 index 0000000..3d335e9 --- /dev/null +++ b/src/github/gh-notification-list.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# This section loads configuration files needed to set environment variables +# such as GITHUB_TOKEN. If these variables are already exported globally in the shell, +# the files below can remain commented out. Otherwise, uncomment the appropriate +# file(s) as needed. This particular script only needs GITHUB_TOKEN to function properly. + +# source "$GITNAP/utils/auth.sh" +# source "$GITNAP/utils/settings.sh" + + + +function list_github_notifications() { + local endpoint + local response + local tmp_file + + # API Endpoint + endpoint="https://api.github.com/notifications" + + # Get notifications + response=$(curl -sSL "$endpoint" \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" ) + + # See in terminal + tmp_file=$(mktemp) + echo "$response" > "$tmp_file" + less "$tmp_file" + rm "$tmp_file" + +} + +list_github_notifications