Last active
June 28, 2022 11:38
-
-
Save M97Chahboun/25cdeed2f072f8b466a0d2ec089c8b89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:example/models/post_model.dart'; | |
import 'package:mvc_rocket/mvc_rocket.dart'; | |
const String postsEndpoint = "posts"; | |
class PostRequests { | |
static Future getPosts(Post postModel) => | |
RocketController().get(rocketRequestKey).getObjData( | |
// endpoint | |
postsEndpoint, | |
// your model | |
postModel, | |
inspect: (data) { | |
return data; | |
}, | |
// if you received data as List multi will be true & if data as map you not should to define multi its false as default | |
multi: true, | |
// parameters for send it with request | |
// params:{"key":"value"}, | |
// inspect method for determine exact json use for generate your model in first step | |
// if your api send data directly without any supplement values you not should define it | |
// inspect:(data)=>data["response"] | |
); | |
static Future postPosts(Post postModel){ | |
// RocketController().get(rocketRequestKey).postObjData(); | |
// TODO : implement post request | |
} | |
static Future putPosts(int id, Post postModel){ | |
// RocketController().get(rocketRequestKey).putObjData(); | |
// TODO : implement put request | |
} | |
static Future deletePosts(int id){ | |
// RocketController().get(rocketRequestKey).delJsonData(); | |
// TODO : implement delete request | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment