fx.http100 lines, 2.4 KB
| 1 | # Currency conversion, through the gateway: Alice holds dollars, and buys |
| 2 | # euros. Send the requests in order, on a fresh database. |
| 3 | @baseUrl = http://localhost:8080 |
| 4 | @password = correct horse battery staple |
| 5 | @token = {{login.response.body.access_token}} |
| 6 | @dollars = {{usd.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 | ### A dollar wallet |
| 22 | # @name usd |
| 23 | POST {{baseUrl}}/v1/wallets |
| 24 | Authorization: Bearer {{token}} |
| 25 | Content-Type: application/json |
| 26 | |
| 27 | {"currency": "USD"} |
| 28 | |
| 29 | ### Deposit five hundred dollars |
| 30 | POST {{baseUrl}}/v1/wallets/{{dollars}}/deposits |
| 31 | Authorization: Bearer {{token}} |
| 32 | Idempotency-Key: {{$guid}} |
| 33 | Content-Type: application/json |
| 34 | |
| 35 | {"amount": 50000, "currency": "USD"} |
| 36 | |
| 37 | ### A euro wallet |
| 38 | # @name eur |
| 39 | POST {{baseUrl}}/v1/wallets |
| 40 | Authorization: Bearer {{token}} |
| 41 | Content-Type: application/json |
| 42 | |
| 43 | {"currency": "EUR"} |
| 44 | |
| 45 | ### Quote: sell a hundred dollars for euros |
| 46 | # @name quote |
| 47 | POST {{baseUrl}}/v1/fx/quotes |
| 48 | Authorization: Bearer {{token}} |
| 49 | Content-Type: application/json |
| 50 | |
| 51 | {"from": "USD", "to": "EUR", "sell_amount": 10000} |
| 52 | |
| 53 | ### Convert |
| 54 | # @name convert |
| 55 | POST {{baseUrl}}/v1/fx/conversions |
| 56 | Authorization: Bearer {{token}} |
| 57 | Idempotency-Key: {{quote.response.body.id}} |
| 58 | Content-Type: application/json |
| 59 | |
| 60 | {"quote_id": "{{quote.response.body.id}}"} |
| 61 | |
| 62 | ### The same quote, as a new request |
| 63 | POST {{baseUrl}}/v1/fx/conversions |
| 64 | Authorization: Bearer {{token}} |
| 65 | Idempotency-Key: {{$guid}} |
| 66 | Content-Type: application/json |
| 67 | |
| 68 | {"quote_id": "{{quote.response.body.id}}"} |
| 69 | |
| 70 | ### Dollars |
| 71 | GET {{baseUrl}}/v1/wallets/{{dollars}}/balance |
| 72 | Authorization: Bearer {{token}} |
| 73 | |
| 74 | ### Euros |
| 75 | GET {{baseUrl}}/v1/wallets/{{eur.response.body.id}}/balance |
| 76 | Authorization: Bearer {{token}} |
| 77 | |
| 78 | ### Quote: ten dollars in yen |
| 79 | POST {{baseUrl}}/v1/fx/quotes |
| 80 | Authorization: Bearer {{token}} |
| 81 | Content-Type: application/json |
| 82 | |
| 83 | {"from": "USD", "to": "JPY", "sell_amount": 1000} |
| 84 | |
| 85 | ### Quote: buy exactly fifty euros |
| 86 | # @name buyQuote |
| 87 | POST {{baseUrl}}/v1/fx/quotes |
| 88 | Authorization: Bearer {{token}} |
| 89 | Content-Type: application/json |
| 90 | |
| 91 | {"from": "USD", "to": "EUR", "buy_amount": 5000} |
| 92 | |
| 93 | ### Convert the fifty euros |
| 94 | # @name convertBuy |
| 95 | POST {{baseUrl}}/v1/fx/conversions |
| 96 | Authorization: Bearer {{token}} |
| 97 | Idempotency-Key: {{buyQuote.response.body.id}} |
| 98 | Content-Type: application/json |
| 99 | |
| 100 | {"quote_id": "{{buyQuote.response.body.id}}"} |