Skip to content

Commit

Permalink
Merge pull request #2012 from usagov/USAGOV-2013-call-center-chat-times
Browse files Browse the repository at this point in the history
USAGOV-2013-call-center-chat-times: added chat wait times and restruc…
  • Loading branch information
akf authored Oct 17, 2024
2 parents bee7b05 + d69f41a commit 6268f69
Showing 1 changed file with 55 additions and 12 deletions.
67 changes: 55 additions & 12 deletions .docker/src-cron/opt/callcenter/call-center-update
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6268f69

Please sign in to comment.