Skip to content

Latest commit

 

History

History
207 lines (159 loc) · 4.9 KB

DShop.rest

File metadata and controls

207 lines (159 loc) · 4.9 KB

@apiUrl = http://localhost:5000 @identityServiceUrl = http://localhost:5002 @accessToken = xxxxxxxxxxxxxxxxxx @refreshToken = xxxxxxxxxxxxxxxxxx @operationId = xxxxxxxxxxxxxxxxxx @productId = xxxxxxxxxxxxxxxxxx @customerId = xxxxxxxxxxxxxxxxxx @orderId = xxxxxxxxxxxxxxxxxx

# ================= OPERATION DETAILS ======================= #

### Whenever you send HTTP POST/PUT/DELETE request, you can verify whether the operation succeded or not by updating @operationId parameter above ### The operationId is a part of the response returned from the API and can be found under X-Operation: operations/{{operationId}} custom header GET {{apiUrl}}/operations/{{operationId}}

# ================= IDENTITY SERVICE ======================= #

### Sign up as admin POST {{identityServiceUrl}}/sign-up content-type: application/json

{
"email": "dshop-admin@mailinator.com", "password": "secret", "role": "admin"

}

### Sign in as admin POST {{identityServiceUrl}}/sign-in content-type: application/json

{
"email": "dshop-admin@mailinator.com", "password": "secret"

}

# Once authenticated, copy the obtained accessToken and update the @accessToken parameter above.

# ================= API GATEWAY ======================= #

### Create as many unique (by name) products as needed POST {{apiUrl}}/products authorization: Bearer {{accessToken}} content-type: application/json

{
"name": "My product", "description": "My product description", "vendor": "My company", "price": 2000, "quantity": 10

}

### Get products list GET {{apiUrl}}/products

### Get product details by updating @productId parameter above GET {{apiUrl}}/products/{{productId}} authorization: Bearer {{accessToken}}

### Update a product if needed PUT {{apiUrl}}/products/{{productId}} authorization: Bearer {{accessToken}} content-type: application/json

{
"name": "My product updated", "description": "My product updated description", "price": 3500, "quantity": 15

}

### Delete a product if needed DELETE {{apiUrl}}/products/{{productId}} authorization: Bearer {{accessToken}}

### Browse customers (if exist) GET {{apiUrl}}/customers authorization: Bearer {{accessToken}}

### Get a customer account details GET {{apiUrl}}/customers/{{customerId}} authorization: Bearer {{accessToken}}

# ================= USER WORKFLOW ======================= #

### Sign up as user POST {{identityServiceUrl}}/sign-up content-type: application/json

{
"email": "dshop-user@mailinator.com", "password": "secret", "role": "user"

}

### Sign in as user POST {{identityServiceUrl}}/sign-in content-type: application/json

{
"email": "dshop-user@mailinator.com", "password": "secret"

}

# Once authenticated, copy the obtained accessToken and update the @accessToken parameter above

### Create a customer account POST {{apiUrl}}/customers authorization: Bearer {{accessToken}} content-type: application/json

{
"firstName": "John", "lastName": "Kowalski", "address": "My Street 01/02, My City", "country": "My Country"

}

### Add some products to your cart. POST {{apiUrl}}/cart/items authorization: Bearer {{accessToken}} content-type: application/json

{
"productId": "{{productId}}", "quantity": 1

}

### Get your shopping cart GET {{apiUrl}}/cart authorization: Bearer {{accessToken}}

### Delete a product from your cart if needed DELETE {{apiUrl}}/cart/items/{{productId}} authorization: Bearer {{accessToken}}

### Clear cart DELETE {{apiUrl}}/cart authorization: Bearer {{accessToken}}

### Create a new order POST {{apiUrl}}/orders authorization: Bearer {{accessToken}} content-type: application/json

{

### Get your orders list GET {{apiUrl}}/orders authorization: Bearer {{accessToken}}

### Get your order details by updating @orderId parameter above GET {{apiUrl}}/orders/{{orderId}} authorization: Bearer {{accessToken}}

### Complete an order (only works for new orders with status "created") POST {{apiUrl}}/orders/{{orderId}}/complete authorization: Bearer {{accessToken}} content-type: application/json

{

### Cancel an order if needed (only works for new orders with status "created") DELETE {{apiUrl}}/orders/{{orderId}} authorization: Bearer {{accessToken}}

# ================= IDENTITY SERVICE ======================= #

### Get your identity GET http://localhost:5002/me authorization: Bearer {{accessToken}}

### Change password PUT http://localhost:5002/me/password authorization: Bearer {{accessToken}} content-type: application/json

{
"currentPassword": "secret", "newPassword": "very_secret"

}

### Generate a new access token by updating @refreshToken parameter above POST http://localhost:5002/access-tokens/{{refreshToken}}/refresh content-type: application/json

{

### Revoke a current access token POST http://localhost:5002/access-tokens/revoke authorization: Bearer {{accessToken}} content-type: application/json

{

### Revoke a current refresh token POST http://localhost:5002/refresh-tokens/{{refreshToken}}/revoke authorization: Bearer {{accessToken}} content-type: application/json

{