From c2e00a7638e1987ee4e7aed37e4ca85759c297a9 Mon Sep 17 00:00:00 2001 From: stremovsky Date: Thu, 12 Dec 2019 09:17:32 +0200 Subject: [PATCH] create user app --- create-test-user.sh | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/create-test-user.sh b/create-test-user.sh index 44ea175..e8c584e 100755 --- a/create-test-user.sh +++ b/create-test-user.sh @@ -1,6 +1,26 @@ #!/bin/bash -set -x +DATABUNKER_APIKEY='1ca9a727-ee10-9cc6-c1a2-72da05951e69' -DATABUNKER_APIKEY='25ae59fb-3859-b807-7420-cdb83e089b42' -curl -s http://localhost:3000/v1/user -XPOST "X-Bunker-Token: "$DATABUNKER_APIKEY -H "Content-Type: application/json" -d '{"name":"yul","email":"test@paranoidguy.com"}' +echo "Creating user." +RESULT=`curl -s http://localhost:3000/v1/user \ + -H "X-Bunker-Token: "$DATABUNKER_APIKEY -H "Content-Type: application/json" \ + -d '{"fname":"Test","lname":"Account","email":"test@paranoidguy.com","phone":"4444"}'` +STATUS=`echo $RESULT | jq ".status" | tr -d '"'` +if [ "$STATUS" == "error" ]; then + echo "Error to create user, trying to lookup by email." + RESULT=`curl -s http://localhost:3000/v1/user/email/test@paranoidguy.com -H "X-Bunker-Token: "$DATABUNKER_APIKEY` + STATUS=`echo $RESULT | jq ".status" | tr -d '"'` +fi +if [ "$STATUS" == "error" ]; then + echo "Failed to fetch user by email, got: $RESULT" + exit +fi + +TOKEN=`echo $RESULT | jq ".token" | tr -d '"'` +echo "User token is $TOKEN" + +RESULT=`curl -s http://localhost:3000/v1/userapp/token/$TOKEN/shiping \ + -H "X-Bunker-Token: "$DATABUNKER_APIKEY -H "Content-Type: application/json" \ + -d '{"country":"Israel","address":"Allenby 1","postcode":"12345","status":"active"}' | jq ".status" | tr -d '"'` +echo "User shiping record created, status $RESULT" \ No newline at end of file