# shellcheck shell=dash disable=SC2034,SC2154
# https://gitea.com/api/swagger#/repository/repoEditHook
___x_cmd_fjo_repo_hook_edit() {
    param:scope     ___x_cmd_fjo
    param:dsl       <<A
options:
    #1                          "The unique identifier of the hook."                                    <>:Number
    --repo|-r                   "<owner_path>/<repo_path>"                                              <>:RepoName
    --url                       "The URL to which the payloads will be delivered."                      <>=""
    --content_type              "The media type used to serialize the payloads. "                       <>=""
    --events                    "events the hook is triggered for.(array usage,interval)"               <>=""
    --branch_filter             "branch filter"                                                         <>=""
    --authorization_header      "authorization header"                                                  <>=""
    --active                    "Determines if notifications are sent when the webhook is triggered."
    --json|-j                   "output json data"
A
    param:run
    local config
    config=$(x jo "{
        url:\"$url\",
        ${content_type+"content_type:$content_type"},
    }")
    events=$(x jo "[$events]")

    local gen_fjo_json
    gen_fjo_json="$(param:option2json -url -repo +config 'active=^^active')"

    ___x_cmd_fjo_param_init_owner_repo
    ___x_cmd_fjo_curl patch "/repos/${owner_repo}/hooks/$1" "gen_fjo_json" | ___x_cmd_fjo_hook____ui_handler Edit
}

