[go: up one dir, main page]

0% found this document useful (0 votes)
78 views7 pages

API Rental Project

Uploaded by

Khánh Linh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views7 pages

API Rental Project

Uploaded by

Khánh Linh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Simple Tool Rental API

This API allows you to reserve a tool.

The API is available at https://simple-tool-rental-api.glitch.me

authentication:

Endpoint
● Status
● Tools
○ Get all tools
○ Get a single tool
● Orders
○ Get all orders
○ Get a single order
○ Create a new order
○ Update an order
○ Delete an order

A. Status: GET /status

Returns the status of the API:

● UP: indicates that the API is running as expected.


● DOWN: indicates that the API is currently not working.

B. Tools: GET https://simple-tool-rental-api.glitch.me/tools

Returns a list of tools from the inventory.

1/ Parameters: tools?category={category_name}, tools?results={number}...

Name Type In Description

category string query Optional - Specifies the category of tools


you want to be returned. It can be one of:
ladders, plumbing, power-tools, trailers,
electric-generators, lawn-care.
results integer query Optional - Specifies the number of results
you want. Must be number between 1 and
20.

By default, only 20 tools will be displayed.

available boolean query Optional - Specifies the availability of the


tools. By default, all tools will be displayed.

2/ Status codes

Status code Description

200 OK Indicates a successful response.

400 Bad Request Indicates that the parameters provided are invalid.

Get a single tool: https://simple-tool-rental-api.glitch.me


GET /tools/{toolId}

Returns a single tool from the inventory

1/ Parameters

Name Type In Description

toolId integer path Specifies the id of the tool you wish to retrieve.

user-manual boolean query Optional - Returns the user manual in PDF


format.

2/ Status codes

Status code Description

200 OK Indicates a successful response.

404 Not found Indicates that there is no tool with the specified id.
C. Orders

Create a new order


POST /orders

=> New order is created for an existed toolID

1/ Parameters

Name Type In Description

Authorization string header Required.

Specifies the bearer token of the API


client.

Bearer {YOUR TOKEN}

Bearer

session/phien lam viec: 15p

token1

b5afc3917d2a8ac78aeebc9f19748a9be48b
85034cf4d41e57c79ed60742d82d

toolId integer body Required

The existing ID.

customerName string body Required

Specifies the name of the customer.

comment string body Optional. Specifies a comment.


Example request body:

{
"toolId": 4643,
"customerName": "John Doe",
"comment": "This is QA03 class"
}

2/ Status codes

Status code Description

201 Created Indicates that the order has been created successfully.

400 Bad Request Indicates that the parameters provided are invalid.

401 Unauthorized Indicates that request has not been authenticated.


Check the response body for additional details.

Get all orders


Returns all orders created by the API client.

GET /orders

1/ Parameters

Name Type In Description

Authorization string header Specifies the bearer token of the API client.

Specifies the bearer token of the API client.

Bearer {YOUR TOKEN}

Bearer

session/phien lam viec: 15p

2/ Status codes

Status code Description


200 Ok Indicates a successful response.

401 Unauthorized Indicates that request has not been authenticated. Check the
response body for additional details.

Get a single order


Returns a single order.

GET /orders/{orderId}?invoice =>url/path

1/ Parameters

Name Type In Description

Authorization string header Specifies the bearer token of the API


client.

Bearer {YOUR TOKEN}

invoice boolean query Optional - Shows the PDF invoice

2/ Status codes

Status code Description

200 Ok Indicates a successful response.

401 Unauthorized Indicates that request has not been authenticated. Check the
response body for additional details.

404 Not found Indicates that there is no order with the specified id associated
with the API client.

Update an order
PATCH /orders/{orderId}

1/ Parameters

Name Type In Description

Authorization string header Specifies the bearer token of the API


client.

Bearer {YOUR TOKEN}

customerName string body required

. Specifies the name of the customer.

comment string body Optional.

Specifies a comment.

Example request body:

{
"customerName": "Joe Doe",
"comment": "Joe Doe"
}

2/ Status codes

Status code Description

204 No Content Indicates that the order has been updated successfully.

400 Bad Request Indicates that the parameters provided are invalid.

401 Unauthorized Indicates that request has not been authenticated. Check the
response body for additional details.

404 Not found Indicates that there is no order with the specified id associated
with the API client.

Delete an order
DELETE /orders/{orderId}

1/ Parameters

Name Type In Description

Authorization string header Specifies the bearer token of the API client.

Bearer {YOUR TOKEN}

orderId string path Specifies the order id.

2/ Status codes

Status code Description

204 No Content Indicates that the order has been deleted successfully.

400 Bad Request Indicates that the parameters provided are invalid.

401 Unauthorized Indicates that request has not been authenticated. Check the
response body for additional details.

404 Not found Indicates that there is no order with the specified id associated to the
API client.

You might also like