transfers.http91 lines, 2.2 KB
| 1 | # Transfers through the gateway. The first seven requests set up Alice and |
| 2 | # Bob, once; then Alice pays Bob, and we follow the transfer. |
| 3 | @baseUrl = http://localhost:8080 |
| 4 | @password = correct horse battery staple |
| 5 | @token = {{login.response.body.access_token}} |
| 6 | @walletId = {{wallet.response.body.id}} |
| 7 | |
| 8 | ### Register |
| 9 | POST {{baseUrl}}/v1/auth/register |
| 10 | Content-Type: application/json |
| 11 | |
| 12 | {"email": "alice@example.com", "password": "{{password}}"} |
| 13 | |
| 14 | ### Log in |
| 15 | # @name login |
| 16 | POST {{baseUrl}}/v1/auth/login |
| 17 | Content-Type: application/json |
| 18 | |
| 19 | {"email": "alice@example.com", "password": "{{password}}"} |
| 20 | |
| 21 | ### Open a wallet |
| 22 | # @name wallet |
| 23 | POST {{baseUrl}}/v1/wallets |
| 24 | Authorization: Bearer {{token}} |
| 25 | Content-Type: application/json |
| 26 | |
| 27 | {"currency": "USD"} |
| 28 | |
| 29 | ### Deposit fifty dollars |
| 30 | POST {{baseUrl}}/v1/wallets/{{walletId}}/deposits |
| 31 | Authorization: Bearer {{token}} |
| 32 | Idempotency-Key: {{$guid}} |
| 33 | Content-Type: application/json |
| 34 | |
| 35 | {"amount": 5000, "currency": "USD"} |
| 36 | |
| 37 | ### Bob, so Alice has someone to pay |
| 38 | POST {{baseUrl}}/v1/auth/register |
| 39 | Content-Type: application/json |
| 40 | |
| 41 | {"email": "bob@example.com", "password": "{{password}}"} |
| 42 | |
| 43 | ### |
| 44 | # @name bob |
| 45 | POST {{baseUrl}}/v1/auth/login |
| 46 | Content-Type: application/json |
| 47 | |
| 48 | {"email": "bob@example.com", "password": "{{password}}"} |
| 49 | |
| 50 | ### |
| 51 | # @name bobsWallet |
| 52 | POST {{baseUrl}}/v1/wallets |
| 53 | Authorization: Bearer {{bob.response.body.access_token}} |
| 54 | Content-Type: application/json |
| 55 | |
| 56 | {"currency": "USD"} |
| 57 | |
| 58 | ### Pay Bob fifteen dollars |
| 59 | # @name transfer |
| 60 | POST {{baseUrl}}/v1/transfers |
| 61 | Authorization: Bearer {{token}} |
| 62 | Idempotency-Key: {{$guid}} |
| 63 | Content-Type: application/json |
| 64 | |
| 65 | { |
| 66 | "from": "{{walletId}}", |
| 67 | "to": "{{bobsWallet.response.body.id}}", |
| 68 | "amount": 1500, |
| 69 | "currency": "USD" |
| 70 | } |
| 71 | |
| 72 | ### Where is it? |
| 73 | GET {{baseUrl}}{{transfer.response.headers.Location}} |
| 74 | Authorization: Bearer {{token}} |
| 75 | |
| 76 | ### Pay Bob a hundred dollars |
| 77 | POST {{baseUrl}}/v1/transfers |
| 78 | Authorization: Bearer {{token}} |
| 79 | Idempotency-Key: {{$guid}} |
| 80 | Content-Type: application/json |
| 81 | |
| 82 | {"from": "{{walletId}}", "to": "{{bobsWallet.response.body.id}}", "amount": 10000, "currency": "USD"} |
| 83 | |
| 84 | ### Balance |
| 85 | GET {{baseUrl}}/v1/wallets/{{walletId}}/balance |
| 86 | Authorization: Bearer {{token}} |
| 87 | |
| 88 | ### Bob's balance |
| 89 | GET {{baseUrl}}/v1/wallets/{{bobsWallet.response.body.id}}/balance |
| 90 | Authorization: Bearer {{bob.response.body.access_token}} |
| 91 |