Skip to content

Instantly share code, notes, and snippets.

@maxd
Last active August 29, 2015 14:10
Show Gist options
  • Save maxd/01e3e1d90ddfaf738eb8 to your computer and use it in GitHub Desktop.
Save maxd/01e3e1d90ddfaf738eb8 to your computer and use it in GitHub Desktop.
Rent Movie
#!/bin/sh
set -x
HOST='0.0.0.0:3000'
USER='customer5@mail.com'
PASSWORD='123456asd'
CLIENT_ID='foo'
CLIENT_VERSION='1.0'
LOCALE='ta'
TIMEZONE='3600'
ACCESS_TOKEN=$(curl -s -X POST --data "client_version=$CLIENT_VERSION&locale=$LOCALE&timezone=$TIMEZONE&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&client_version=$CLIENT_VERSION&locale=$LOCALE&timezone=$TIMEZONE" | jq -r '.movies | map(select(.rentable == true)) | .[].id' | head -n 1)
echo "Rentable Movie: $MOVIE_UID"
RENT_JSON=$(curl -s -X POST --data "client_version=$CLIENT_VERSION&locale=$LOCALE&timezone=$TIMEZONE&client_id=$CLIENT_ID&method=lebara_payment_portal&access_token=$ACCESS_TOKEN" http://$HOST/api/v1/movies/$MOVIE_UID/rent)
BASKET_UID=$(echo $RENT_JSON | jq -r '.payment_transaction.basket_id')
PAYMENT_URL=$(echo $RENT_JSON | jq -r '.payment_transaction.payment_url')
echo "Basket ID: $BASKET_UID"
echo "Payment URL: $PAYMENT_URL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment