#!/bin/bash

tokens_file='/etc/direct-tokens/api_test_tokens'
client_login='andy-ilyin-client'
operator_login='at-direct-super'
oauth_token=$(grep $operator_login $tokens_file |awk '{print $2}')


SCRIPTPATH=`readlink -f $0`
SCRIPTDIR=`dirname $SCRIPTPATH`

source $SCRIPTDIR/beta_number

SERVICE_URL="$URL/adimages"
# echo $SERVICE_URL

REQUEST='<?xml version="1.0" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:general="http://api.direct.yandex.com/v5/general"
    xmlns:adimages="http://api.direct.yandex.com/v5/adimages"
>
    <soapenv:Body>
        <adimages:DeleteRequest>
            <SelectionCriteria>
                <AdImageHashes>UIyE3OkjEFlMfCagFLvwSA</AdImageHashes>
            </SelectionCriteria>
        </adimages:DeleteRequest>
    </soapenv:Body>
</soapenv:Envelope>'

case "$1" in
    *-r*)
        echo "$REQUEST"
        exit
        ;;
esac

curl \
    -k -v \
    -H "SOAPAction: 'http://api.direct.yandex.com/v5/adimages/delete'" \
    -H "Authorization: Bearer $oauth_token" \
    -H "Client-Login: $client_login" \
    -H 'Accept-Language: ru, en-gb;q=0.8, ru;q=0.6, en;q=0.7' \
    -d "$REQUEST" \
    "$SERVICE_URL"

echo
