Evosphere JS Router v0.1.20
Le router Evosphere est un outil Javascript contenant les liens vers les différentes entrées de l'API Evosphere. Elle
donne un libellé à chaque route.
Attention : le routeur ne réalise aucune requête HTTP. Son rôle est purement de distribuer les routes et de permettre
de les générer lorsque celles-ci demandent des paramètres.
Utilisation
L'objet Router est en réalité une Usine. Elle ne représente pas le routeur lui-même mais permet d'en créer.
Afin de récupérer une route, il suffit de récupérer son libellé dans l'objet routes
.
import Router from 'evosphere-router';
const router = Router();
const getApikeyRoute = router.routes.apikey();
Si une route nécessite des paramètres d'URL, il suffit d'envoyer en paramètre de la route un objet contenant le nom
du paramètre à renseigner.
const getUserRoute = router.routes.user.getUser({
id: 2164
});
Routes disponibles
const routes = (domain, version) => ({
activity: {
getStats: createRoute(getVersionURL("/users/{id}/activities", domain, version)),
getActivities: createRoute(getVersionURL("/activities", domain, version)),
getActivity: createRoute(getVersionURL("/activities/{id}", domain, version)),
createActivity: createRoute(getVersionURL("/activities", domain, version)),
getCategories: createRoute(getVersionURL("/activities/categories", domain, version)),
getCategory: createRoute(getVersionURL("/activities/categories/{id}", domain, version)),
addActivityToPracticeList: createRoute(getVersionURL("/activities/practice", domain, version)),
removeActivityFromPracticeList: createRoute(getVersionURL("/activities/{id}/practice", domain, version)),
getSessions: createRoute(getVersionURL("/sessions", domain, version)),
createSession: createRoute(getVersionURL("/sessions", domain, version)),
getSession: createRoute(getVersionURL("/sessions/{id}", domain, version)),
patchSession: createRoute(getVersionURL("/sessions/{id}", domain, version)),
finishSession: createRoute(getVersionURL("/sessions/{id}/finish", domain, version)),
deleteSession: createRoute(getVersionURL("/sessions/{id}", domain, version)),
likeSession: createRoute(getVersionURL("/sessions/{id}/likes", domain, version)),
unlikeSession: createRoute(getVersionURL("/sessions/{id}/likes", domain, version)),
getSessionLikes: createRoute(getVersionURL("/sessions/{id}/likes", domain, version)),
getSessionComments: createRoute(getVersionURL("/sessions/{id}/comments", domain, version)),
createSessionComment: createRoute(getVersionURL("/sessions/{id}/comments", domain, version)),
subscribeToSession: createRoute(getVersionURL("/sessions/{id}/subscribes", domain, version)),
unsubscribeToSession: createRoute(getVersionURL("/sessions/{id}/subscribes", domain, version)),
isSubscribedToSession: createRoute(getVersionURL("/sessions/{id}/subscribes/isSubscribed", domain, version)),
practice: {
get: createRoute(getVersionURL("/sessions/practice", domain, version)),
start: createRoute(getVersionURL("/sessions/practice", domain, version)),
update: createRoute(getVersionURL("/sessions/practice", domain, version)),
finish: createRoute(getVersionURL("/sessions/practice/finish", domain, version)),
revive: createRoute(getVersionURL("/sessions/practice/{id}/revive", domain, version)),
}
},
apikey: createRoute(getStandardURL("apikey", domain)),
notification:{
getNotifications: createRoute(getVersionURL("/notifications", domain, version)),
patchNotification: createRoute(getVersionURL("/notifications/{id}", domain, version)),
getNotification: createRoute(getVersionURL("/notifications/{id}", domain, version)),
},
relation:{
getFollowers: createRoute(getVersionURL("/users/{id}/followers", domain, version)),
follow: createRoute(getVersionURL("/users/{id}/followers", domain, version)),
unfollow: createRoute(getVersionURL("/users/{id}/followers", domain, version)),
getFollowing: createRoute(getVersionURL("/users/{id}/followers", domain, version)),
getFriends: createRoute(getVersionURL("/users/{id}/friends", domain, version)),
getFriendship: createRoute(getVersionURL("/users/{id}/friendship", domain, version)),
sendFriendRequest: createRoute(getVersionURL("/users/{id}/friendship", domain, version)),
acceptOrDeclineFriendRequest: createRoute(getVersionURL("/users/{id}/friendship", domain, version)),
removeFromFriends: createRoute(getVersionURL("/users/{id}/friendship", domain, version)),
},
social: {
getPosts: createRoute(getVersionURL("/posts", domain, version)),
postPost: createRoute(getVersionURL("/posts", domain, version)),
getPost: createRoute(getVersionURL("/posts/{id}", domain, version)),
patchPost: createRoute(getVersionURL("/posts/{id}", domain, version)),
deletePost: createRoute(getVersionURL("/posts/{id}", domain, version)),
likePost: createRoute(getVersionURL("/posts/{id}/likes", domain, version)),
unlikePost: createRoute(getVersionURL("/posts/{id}/likes", domain, version)),
getPostLikes: createRoute(getVersionURL("/posts/{id}/likes", domain, version)),
subscribeToPost: createRoute(getVersionURL("/posts/{id}/subscribes", domain, version)),
unsubscribeToPost: createRoute(getVersionURL("/posts/{id}/subscribes", domain, version)),
getPostSubscribers: createRoute(getVersionURL("/posts/{id}/subscribes", domain, version)),
commentPost: createRoute(getVersionURL("/posts/{id}/comments", domain, version)),
getPostComments: createRoute(getVersionURL("/posts/{id}/comments", domain, version)),
getComment: createRoute(getVersionURL("/comments/{id}", domain, version)),
getAnswerComments: createRoute(getVersionURL("/comments/{id}", domain, version)),
answerTo: createRoute(getVersionURL("/comments/{id}", domain, version)),
patchComment: createRoute(getVersionURL("/comments/{id}", domain, version)),
deleteComment: createRoute(getVersionURL("/comments/{id}", domain, version)),
likeComment: createRoute(getVersionURL("/comments/{id}/likes", domain, version)),
unlikeComment: createRoute(getVersionURL("/comments/{id}/likes", domain, version)),
getCommentLikes: createRoute(getVersionURL("/comments/{id}/likes", domain, version)),
subscribeToComment: createRoute(getVersionURL("/comments/{id}/subscribes", domain, version)),
unsubscribeToComment: createRoute(getVersionURL("/comments/{id}/subscribes", domain, version)),
getCommentSubscribers: createRoute(getVersionURL("/comments/{id}/subscribes", domain, version))
},
user: {
getUser: createRoute(getVersionURL("/users/{id}", domain, version)),
getUsers: createRoute(getVersionURL("/users", domain, version)),
getUserStatus: createRoute(getVersionURL("/users/{id}/status", domain, version)),
sendPasswordResetRequest: createRoute(getVersionURL("/users/{id}/password/retrieve", domain, version)),
confirmPasswordResetRequest: createRoute(getVersionURL("/users/{id}/password/retrieve/confirm", domain, version)),
updateProfile: createRoute(getVersionURL("/profile", domain, version)),
register: createRoute(getVersionURL("/register", domain, version)),
preregister: createRoute(getVersionURL("/preregistration", domain, version))
}
});