diff --git a/.docker/src-cron/opt/callcenter/call-center-update b/.docker/src-cron/opt/callcenter/call-center-update index d81af056a3..1dae8c8e54 100755 --- a/.docker/src-cron/opt/callcenter/call-center-update +++ b/.docker/src-cron/opt/callcenter/call-center-update @@ -11,24 +11,67 @@ source ~/.profile $SPACE callwait &> /dev/null waitTimeFile="waittime.json" -#echo "Getting access token." -tokenResponse=$(curl -s -X POST https://login.$CALL_CENTER_ENVIRONMENT/oauth/token -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=client_credentials&client_id=$CALL_CENTER_CLIENT_ID&client_secret=$CALL_CENTER_CLIENT_SECRET") +# echo "Getting access token." +tokenResponse=$( + curl -s -X POST https://login.$CALL_CENTER_ENVIRONMENT/oauth/token \ + -H "Content-Type: application/x-www-form-urlencoded" \ + -d "grant_type=client_credentials&client_id=$CALL_CENTER_CLIENT_ID&client_secret=$CALL_CENTER_CLIENT_SECRET" +) token=$(echo "$tokenResponse" | jq -r '.access_token') -#echo "Getting en wait time." -enWaitTime=$(curl -s -X GET https://api.$CALL_CENTER_ENVIRONMENT/api/v2/routing/queues/$CALL_CENTER_EN_QUEUE_ID/estimatedwaittime -H "Authorization:Bearer $token" | jq -r '.results[].estimatedWaitTimeSeconds'); +# echo "Getting en wait time." +enWaitTimeResponse=$( + curl -s -X GET https://api.$CALL_CENTER_ENVIRONMENT/api/v2/routing/queues/$CALL_CENTER_EN_QUEUE_ID/mediatypes/call/estimatedwaittime \ + -H "Authorization:Bearer $token" +); +enWaitTime=$(echo "$enWaitTimeResponse" | jq -r '.results[].estimatedWaitTimeSeconds') -#echo "Getting sp wait time." -spWaitTime=$(curl -s -X GET https://api.$CALL_CENTER_ENVIRONMENT/api/v2/routing/queues/$CALL_CENTER_SP_QUEUE_ID/estimatedwaittime -H "Authorization:Bearer $token" | jq -r '.results[].estimatedWaitTimeSeconds'); +# echo "Getting en chat wait time." +enChatWaitTimeResponse=$( + curl -s -X GET https://api.$CALL_CENTER_ENVIRONMENT/api/v2/routing/queues/$CALL_CENTER_EN_QUEUE_ID/mediatypes/chat/estimatedwaittime \ + -H "Authorization:Bearer $token" +); +enChatWaitTime=$(echo "$enChatWaitTimeResponse" | jq -r '.results[].estimatedWaitTimeSeconds') + +# echo "Getting sp wait time." +spWaitTimeResponse=$( + curl -s -X GET https://api.$CALL_CENTER_ENVIRONMENT/api/v2/routing/queues/$CALL_CENTER_SP_QUEUE_ID/mediatypes/call/estimatedwaittime \ + -H "Authorization:Bearer $token" +); +spWaitTime=$(echo "$spWaitTimeResponse" | jq -r '.results[].estimatedWaitTimeSeconds') + +# echo "Getting sp chat wait time." +spChatWaitTimeResponse=$( + curl -s -X GET https://api.$CALL_CENTER_ENVIRONMENT/api/v2/routing/queues/$CALL_CENTER_SP_QUEUE_ID/mediatypes/chat/estimatedwaittime \ + -H "Authorization:Bearer $token" +); +spChatWaitTime=$(echo "$spChatWaitTimeResponse" | jq -r '.results[].estimatedWaitTimeSeconds') timestamp=$(date +%s) -combinedWaitTimes='{ "enEstimatedWaitTimeSeconds": '$enWaitTime', - "spEstimatedWaitTimeSeconds": '$spWaitTime', - "timestamp": '$timestamp'}' +combinedWaitTimes='{ + "call": { + "en": { + "estimatedWaitTimeSeconds": '$enWaitTime' + }, + "sp": { + "estimatedWaitTimeSeconds": '$enChatWaitTime' + } + }, + "chat": { + "en": { + "estimatedWaitTimeSeconds": '$spWaitTime' + }, + "sp": { + "estimatedWaitTimeSeconds": '$spChatWaitTime' + } + }, + "timestamp": '$timestamp' +}' -#echo "Setting wait time file." +# echo "Setting wait time file." +# echo "$combinedWaitTimes" >&2 echo "$combinedWaitTimes" > $waitTimeFile -# # Upload file to S3 bucket -#echo "uploading waittime.json to S3." +# Upload file to S3 bucket +# echo "uploading waittime.json to S3." aws_cp waittime.json s3://$S3_BUCKET/$VERSION/waittime.json