From ed3b209130b6f941dcc1ac5142c0ef802255ce60 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 20 May 2015 20:32:56 +0200 Subject: lib/cac.sh: _cac_{use curl in {get,post}}_api_v1 --- lib/cac.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/cac.sh b/lib/cac.sh index d2108d360..5e3f4ec70 100644 --- a/lib/cac.sh +++ b/lib/cac.sh @@ -8,26 +8,22 @@ _cac_exec() { fi } +_cac_curl_api_v1() { + _cac_exec curl -fsS "$1" "https://panel.cloudatcost.com/api/v1/$2.php" $( + shift 2 + set -- "$@" login="$cac_login" key="$cac_key" + for arg; do + echo -d $(printf '%s' "$arg" | url_encode) + done + ) +} + _cac_get_api_v1() { - _cac_exec curl -fsS \ - $(shift - set -- "$@" login="$cac_login" key="$cac_key" - for arg; do - echo -d $(printf '%s' "$arg" | url_encode) - done - ) \ - -G "https://panel.cloudatcost.com/api/v1/$1.php" + _cac_curl_api_v1 -G "$@" } _cac_post_api_v1() { - _cac_exec curl -fsS \ - $(shift - set -- "$@" login="$cac_login" key="$cac_key" - for arg; do - echo -d $(printf '%s' "$arg" | url_encode) - done - ) \ - -X POST "https://panel.cloudatcost.com/api/v1/$1.php" + _cac_curl_api_v1 -XPOST "$@" } cac_listservers() { -- cgit v1.2.3