Commit 15274f9a authored by aguestuser's avatar aguestuser

[ns] add trust boost command

parent d5fdb70c
......@@ -22,6 +22,7 @@ print_usage(){
echo " list-channels"
echo " list-numbers"
echo " release-numbers"
echo " trust"
echo ""
echo "To learn what these commands do, run:"
echo ""
......@@ -34,7 +35,8 @@ if [[ $command != "help" ]] &&
[[ $command != "create-number" ]] &&
[[ $command != "list-channels" ]] &&
[[ $command != "list-numbers" ]] &&
[[ $command != "release-numbers" ]]
[[ $command != "release-numbers" ]] &&
[[ $command != "trust" ]]
then
print_usage
exit 1
......
......@@ -21,6 +21,9 @@ boost cli supports the following commands:
release-numbers <path>
- releases all phone numbers with twilio ids listed at given path
trust <user phone number>
- trusts all safety numbers associated with a user's phone number
for more detailed instructions on any command, run:
boost <command> -h
......
#!/usr/bin/env bash
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]];then
echo "this command trusts all safety numbers associated with a user's phone number. valid options are:"
echo ""
echo "-p : user phone number";
echo "-u : url to target (in dev, use signalboost.ngrok.io)";
echo ""
exit 1
fi
echo "--- checking environment and args..."
if [ -z $SIGNALBOOST_API_TOKEN ];then
echo "--- ERROR: no SIGNALBOOST_API_TOKEN found. try \`\$ set -a && source .env && set +a\`"
exit 1
fi
while getopts ":p:n:s:u:" opt; do
case "$opt" in
p)
phone_number="$OPTARG"
;;
u)
url="$OPTARG"
;;
esac
done
if [[ ! $phone_number =~ ^\+(1|52)[0-9]{10}$ ]];then
echo "> ERROR: -p must be a 10 digit phone number prefixed by a country code (+1 or +52)"
exit 1
fi
if [ -z $url ];then url=${SIGNALBOOST_HOST_URL}; fi
echo "--- trusting all safety numbers for user phone number ${phone_number} at url ${url}"
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Token: $SIGNALBOOST_API_TOKEN" \
-d "{ \"memberPhoneNumber\": \"$phone_number\" }" \
https://${url}/channels | jq
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment