Created
October 23, 2017 20:06
-
-
Save louisscruz/b13b844758bbfe483d210f81950565c9 to your computer and use it in GitHub Desktop.
create_account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
COUNT_FILE=~/Code/zendesk/scripts/create_account/create_account_count.txt | |
create_count_file() { | |
echo '1' > $COUNT_FILE | |
} | |
ensure_count_file() { | |
if [ ! -f $COUNT_FILE ]; then | |
echo 'Creating a count file' | |
create_count_file | |
fi | |
} | |
get_count() { | |
cat $COUNT_FILE | |
} | |
handle_increment_count() { | |
local CURRENT_COUNT=$(get_count) | |
echo $(($CURRENT_COUNT + 1)) > $COUNT_FILE | |
} | |
make_request() { | |
curl -v -d 'owner[name]=Louis Cruz' \ | |
-d 'owner[email][email protected]' \ | |
-d 'owner[password]=password' \ | |
-d 'owner[is_verified]=1' \ | |
-d 'address[phone]=1234567890' \ | |
-d 'account[name]=Louis Cruz' \ | |
-d 'account[subdomain]='$1 \ | |
-d 'account[help_desk_size]=Large group' \ | |
-d 'account[language]=en' \ | |
-d 'terms=terms_and_things' \ | |
-H 'Authorization: Bearer 0ae8899b8624384922ed49cfd89ab5020eb8f77bf008d6e12f6a08e620f0fcea' \ | |
https://zendeskaccounts.zd-dev.com/api/v2/accounts.json | |
} | |
create_account() { | |
ensure_count_file | |
local SUB_NAME=lcruz$(get_count) | |
make_request $SUB_NAME | |
handle_increment_count | |
echo | |
echo 'Account created!' | |
echo 'Here are your account details:' | |
echo '[email protected]' | |
echo 'password' | |
echo $SUB_NAME | |
} | |
create_account |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This assumes that you keep scripts in
~/Code/zendesk/scripts
. Place this in~/Code/zendesk/scripts/
. Then, alias the script in your~/.bash_profile
. For instance, I addedalias caccount='~/Code/zendesk/scripts/create_account/create_account'
. You might need to runchmod +x ~/Code/zendesk/scripts/create_account/create_account
to have permission to run it.