Last updated:
0 purchases
http simulator
http_simulator #
http_simulator library act as backend server, it for development purpose.
Features #
send http GET request
send http POST request
act as backend API.
it have own local storage act like DB.
Installation #
with Dart
dart pub add http_simulator
copied to clipboard
with Flutter
flutter pub add http_simulator
copied to clipboard
This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):
dependencies:
http_simulator: ^1.0.0
copied to clipboard
DESCRIPTION #
in below we will describe the endpoin and the request and response for each enpoint :
User API's:
Register API : /user/register
// request body Example:
{
"id":1,
"idNumber":"101254654",
"fullName":"Khalid Alshehri",
"dateOfBirth":"2022-10-10",
"email":"[email protected]",
"mobile":"96650052154"
}
HttpRoutingSimulator.post(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/user/register"),
body: requestBody);
// the lib will return HttpStatus = 201 , without response body
copied to clipboard
Login API : /user/login
// request body Example :
{
"idNumber":"tom",
"password":"pass@123"
}
HttpRoutingSimulator.post(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/user/login"),
body: requestBody);
// the lib will return HttpStatus = 200
// response body Example :
{
"id":1,
"idNumber":"101254654",
"fullName":"Khalid Alshehri",
"dateOfBirth":"2022-10-10",
"email":"[email protected]",
"mobile":"96650052154",
"tasks":[
{
"id":1,
"name":"TASK1",
"points":1500,
"description":"TASK 1",
"type":"TASK 1"
}
],
"badge":[
{
"id":1,
"name":"BADGE1",
"points":1500,
"description":"BADGE1 1",
"type":"BADGE1 1"
}
]
}
copied to clipboard
Add task to user API : /user/task?taskId=#{taskId}
// request body Example :
{
"id":4, // userId
"idNumber":"1051554145",
}
HttpRoutingSimulator.post(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/user/task?taskId=#{taskId}"),
body: requestBody);
// the lib will return HttpStatus = 200
// response body Example :
{
"id":1,
"idNumber":"101254654",
"fullName":"Khalid Alshehri",
"dateOfBirth":"2022-10-10",
"email":"[email protected]",
"mobile":"96650052154",
"tasks":[
{
"id":1,
"name":"TASK1",
"points":1500,
"description":"TASK 1",
"type":"TASK 1"
}
],
"badge":[
{
"id":1,
"name":"BADGE1",
"points":1500,
"description":"BADGE1 1",
"type":"BADGE1 1"
}
]
}
copied to clipboard
Add Badge to user API : /user/badge?badgeId=#{badgeId}
// request body Example :
{
"id":4, // userId
"idNumber":"1051554145",
}
HttpRoutingSimulator.post(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/user/badge?badgeId=#{badgeId}"),
body: requestBody);
// the lib will return HttpStatus = 200
// response body Example :
{
"id":1,
"idNumber":"101254654",
"fullName":"Khalid Alshehri",
"dateOfBirth":"2022-10-10",
"email":"[email protected]",
"mobile":"96650052154",
"tasks":[
{
"id":1,
"name":"TASK1",
"points":1500,
"description":"TASK 1",
"type":"TASK 1"
}
],
"badge":[
{
"id":1,
"name":"BADGE1",
"points":1500,
"description":"BADGE1 1",
"type":"BADGE1 1"
}
]
}
copied to clipboard
Complaint API's:
Add complaint API : /complaints
// request body Example:
{
"category":"test",
"title":"test",
"details":"test",
"userId":5,
}
HttpRoutingSimulator.post(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/complaints"),
body: requestBody);
// the lib will return HttpStatus = 201 , without response body
copied to clipboard
Get list Of User Complaints API : /complaints?userId=#{userId}
HttpRoutingSimulator.get(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/complaints?userId=#{userId}");
// the lib will return HttpStatus = 200
// response body Example :
[
{
"id":1,
"category":"test",
"title":"test",
"details":"test",
"status":"test",
"userId":5,
"createdAt":"test",
"lastUpdatedAt":"test"
},
{
"id":1,
"category":"test",
"title":"test",
"details":"test",
"status":"test",
"userId":5,
"createdAt":"test",
"lastUpdatedAt":"test"
}
]
copied to clipboard
Get Complaint by id API : /complaints/#{complaintId}
HttpRoutingSimulator.get(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/complaints/#{complaintId}");
// the lib will return HttpStatus = 200
// response body Example :
[
{
"id":1,
"category":"test",
"title":"test",
"details":"test",
"status":"test",
"userId":5,
"createdAt":"test",
"lastUpdatedAt":"test"
}
copied to clipboard
Task API's:
Add Task API : /tasks
// request body Example:
{
"name":"TASK1",
"points":1500,
"description":"TASK 1",
"type":"TASK 1"
}
HttpRoutingSimulator.post(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/tasks"),
body: requestBody);
// the lib will return HttpStatus = 201 , without response body
copied to clipboard
Get list Of Task API : /tasks
HttpRoutingSimulator.get(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/tasks");
// the lib will return HttpStatus = 200
// response body Example :
[
{
"id":1,
"name":"TASK1",
"points":1500,
"description":"TASK 1",
"type":"TASK 1"
},
{
"id":1,
"name":"TASK1",
"points":1500,
"description":"TASK 1",
"type":"TASK 1"
}
]
copied to clipboard
Get Task by id API : /tasks/#{tasktId}
HttpRoutingSimulator.get(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/tasks/#{tasktId}");
// the lib will return HttpStatus = 200
// response body Example :
{
"id":1,
"name":"TASK1",
"points":1500,
"description":"TASK 1",
"type":"TASK 1"
}
copied to clipboard
Badges API's:
Add badge API : /badges
// request body Example:
{
"name":"BADGE1",
"points":1500,
"description":"BADGE1 1",
"type":"BADGE1 1"
}
HttpRoutingSimulator.post(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/badges"),
body: requestBody);
// the lib will return HttpStatus = 201 , without response body
copied to clipboard
Get list Of badges API : /badges
HttpRoutingSimulator.get(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/badges");
// the lib will return HttpStatus = 200
// response body Example :
[
{
"id":1,
"name":"BADGE1",
"points":1500,
"description":"BADGE1 1",
"type":"BADGE1 1"
},
{
"id":1,
"name":"BADGE1",
"points":1500,
"description":"BADGE1 1",
"type":"BADGE1 1"
}
]
copied to clipboard
Get Task by id API : /badges/#{badgeId}
HttpRoutingSimulator.get(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/badges/#{badgeId}"),
body: requestBody);
// the lib will return HttpStatus = 200
// response body Example :
{
"id":1,
"name":"BADGE1",
"points":1500,
"description":"BADGE1 1",
"type":"BADGE1 1"
}
copied to clipboard
Offer API's:
Add Offer API : /offers
// request body Example:
{
"category":"offer",
"title":"offer",
"description":"offer",
"code":"OFFER"
}
HttpRoutingSimulator.post(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/offers"),
body: requestBody);
// the lib will return HttpStatus = 201 , without response body
copied to clipboard
Get list Of offers API : /offers/#{category}
HttpRoutingSimulator.get(
Uri.parse(HttpRoutingSimulator.BASE_URL + "/offers/#{category}");
// the lib will return HttpStatus = 200
// response body Example :
[
{
"id":1,
"category":"offer",
"title":"offer",
"description":"offer",
"code":"OFFER"
},
{
"id":1,
"category":"offer",
"title":"offer",
"description":"offer",
"code":"OFFER"
}
]
copied to clipboard
License #
MIT
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.