Skip to content

Instantly share code, notes, and snippets.

@holyketzer
Forked from maxd/rent_movie.sh
Last active August 29, 2015 14:10
Show Gist options
  • Save holyketzer/a05c11e7fb6b524aab14 to your computer and use it in GitHub Desktop.
Save holyketzer/a05c11e7fb6b524aab14 to your computer and use it in GitHub Desktop.
Integration test on Bash
#!/bin/sh
HOST='api.*****.com'
USER='[email protected]'
PASSWORD='password'
CLIENT_ID='web'
ACCESS_TOKEN=$(curl -s -X POST --data "grant_type=password&username=$USER&password=$PASSWORD" http://$HOST/api/oauth/token | jq -r '.access_token')
echo "Access Token: $ACCESS_TOKEN"
MOVIE_UID=$(curl -s http://$HOST/api/v1/movies?client_id=$CLIENT_ID | jq -r '.movies | map(select(.rentable == true)) | .[].id' | head -n 1)
echo "Rentable Movie: $MOVIE_UID"
BASKET_UID=$(curl -s -X POST --data "client_id=$CLIENT_ID&method=lebara_payment_portal&access_token=$ACCESS_TOKEN" http://$HOST/api/v1/movies/$MOVIE_UID/rent | jq -r '.payment_transaction.basket_id')
echo "Basket ID: $BASKET_UID"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment