From e778456ceae5f30e6be288ce27ecd4ce061f5429 Mon Sep 17 00:00:00 2001 From: Thomas Dessaux Date: Fri, 4 Jun 2021 15:20:39 +0200 Subject: [PATCH] Add new file from program to activity --- docs/063-user-program.md | 80 +++++++++---- docs/064-from-program-to-activity.md | 169 +++++++++++++++++++++++++++ docs/071-get-user-favorites.md | 2 +- 3 files changed, 230 insertions(+), 21 deletions(-) create mode 100644 docs/064-from-program-to-activity.md diff --git a/docs/063-user-program.md b/docs/063-user-program.md index a7ec14b..f834fdf 100644 --- a/docs/063-user-program.md +++ b/docs/063-user-program.md @@ -15,6 +15,12 @@ activity > user_session > user_program * modelId : Your program model identifier * current : A boolean to know if this program is used. +Some informations are optionals : +* language : standard iso (ex : 'fr','es') +* provider : name the program provider (whitelisted) allowed value : DCM. If you need new value, contact us. +* status : (pending / processing / completed / cancelled) default : pending +* preferences : json with informations, allowed : "week_days" : ["monday","wednesday"] + The basic needs : @@ -27,9 +33,15 @@ The basic needs : ```json { - "modelId": "XXX", + "modelId": "myModelID", "user": "/v2/users/{{ldid}}", - "current": true + "current": true, + "language": "be", + "provider": "DCM", + "status": "processing", + "preferences": { + "week_days" : ["monday","wednesday"] + } } ``` @@ -39,16 +51,25 @@ The basic needs : status 201 : Created { "@context": "/v2/contexts/UserProgram", - "@id": "/v2/user_programs/XXX", + "@id": "/v2/user_programs/xxx", "@type": "UserProgram", - "id": "XXX", - "modelId": "XXX", + "id": "xxx", + "modelId": "xxx", "userSessions": [], - "user": "/v2/users/XXX", + "user": "/v2/users/xxx", "current": true, + "language": "be", + "preferences": { + "week_days": [ + "monday", + "wednesday" + ] + }, + "provider": "DCM", + "status": "processing", "endedAt": null, - "createdAt": "2020-04-17T08:02:53+00:00", - "updatedAt": "2020-04-17T08:02:53+00:00" + "createdAt": "2021-06-04T12:31:59+00:00", + "updatedAt": "2021-06-04T12:31:59+00:00" } status 4xx : Client errors, check response for details. @@ -71,9 +92,15 @@ This method will automatically create your user program and your user sessions l ```json { - "modelId": "XXX", + "modelId": "myModelID", "user": "/v2/users/{{ldid}}", "current": true, + "language": "be", + "provider": "DCM", + "status": "processing", + "preferences": { + "week_days" : ["monday","wednesday"] + }, "userSessions": [ { "modelId": "XXX", @@ -97,10 +124,10 @@ This method will automatically create your user program and your user sessions l status 201 : Created { "@context": "/v2/contexts/UserProgram", - "@id": "/v2/user_programs/XXX", + "@id": "/v2/user_programs/xxx", "@type": "UserProgram", - "id": "XXX", - "modelId": "XXX", + "id": "xxx", + "modelId": "xxx", "userSessions": [ { "@id": "/v2/user_sessions/XXX", @@ -119,11 +146,20 @@ status 201 : Created "type": "string" } ], - "user": "/v2/users/XXX", + "user": "/v2/users/xxx", "current": true, + "language": "be", + "preferences": { + "week_days": [ + "monday", + "wednesday" + ] + }, + "provider": "DCM", + "status": "processing", "endedAt": null, - "createdAt": "2020-04-17T08:13:18+00:00", - "updatedAt": "2020-04-17T08:13:18+00:00" + "createdAt": "2021-06-04T12:31:59+00:00", + "updatedAt": "2021-06-04T12:31:59+00:00" } status 4xx : Client errors, check response for details. @@ -181,11 +217,15 @@ status 200: OK "type": "string" } ], - "user": "/v2/users/XXX", - "current": false, - "endedAt": "2019-03-25T16:17:44+00:00", - "createdAt": "2019-03-25T16:10:40+00:00", - "updatedAt": "2019-03-25T16:17:44+00:00" + "user": "/v2/users/xxx", + "current": true, + "language": null, + "preferences": [], + "provider": null, + "status": "pending", + "endedAt": null, + "createdAt": "2021-03-24T16:09:18+00:00", + "updatedAt": "2021-03-24T16:09:18+00:00" } ], "hydra:view": { diff --git a/docs/064-from-program-to-activity.md b/docs/064-from-program-to-activity.md new file mode 100644 index 0000000..e947883 --- /dev/null +++ b/docs/064-from-program-to-activity.md @@ -0,0 +1,169 @@ +# From program to activity + +There are 2 ways to create a program. + +## Create a program without detail + +`POST https://api.decathlon.net/sportstrackingdata/v2/user_programs/` + +> Request Body + +```json +{ + "modelId": "yourModelId", + "user": "/v2/users/{{ldid}}", + "current": true, + "language": "fr", + "provider": "DCM", + "status": "processing", + "preferences": { + "week_days" : ["monday","wednesday"] + } +} +``` + +## Create a program and session(s) at the same time + +`POST https://api.decathlon.net/sportstrackingdata/v2/user_programs/` + +> Request Body + +```json +{ + "modelId": "yourModelId", + "user": "/v2/users/{{ldid}}", + "current": true, + "language": "fr", + "provider": "DCM", + "status": "processing", + "preferences": { + "week_days" : ["monday","wednesday"], + "userSessions": [ + { + "modelId": "xxx", + "userProgram": "/v2/user_programs/xxx", + "user": "/v2/users/{{ldid}}", + "position": 1, + "type": "session", + "provider": "DCM", + "status": "pending", + "completeDate": null, + "scheduledDate": "2021-04-25T12:00:00+00:00" + }, + { + "modelId": "xxx", + "userProgram": "/v2/user_programs/xxx", + "user": "/v2/users/{{ldid}}", + "position": 2, + "type": "session", + "provider": "DCM", + "status": "pending", + "completeDate": null, + "scheduledDate": "2021-04-26T12:00:00+00:00" + } + ] +} +``` + +## User session on a program + +User session can be part of a program, or be independante (also called simpleSession). +If you created your user sessions from your user Program (seen just previously), no need to create user Session. + +Otherwise, you can create how much sessions you want and linked them to your program : + + +`POST 'https://api.decathlon.net/sportstrackingdata/v2/user_sessions'` + +> Request Body + +```json +{ + "modelId": "xxx", + "userProgram": "/v2/user_programs/xxx", + "user": "/v2/users/{{ldid}}", + "position": 1, + "type": "session", + "provider": "DCM", + "status": "pending", + "completeDate": null , + "scheduledDate": "2021-04-25T12:00:00+02:00" +} +``` + + +## User session without program + +If you want to create an independante user Session, same thing but send userProgram to null + +`POST 'https://api.decathlon.net/sportstrackingdata/v2/user_sessions'` + +> Request Body + +```json +{ + "modelId": "xxx", + "userProgram": null, + "user": "/v2/users/{{ldid}}", + "position": 1, + "type": "simpleSession", + "provider": "DCM", + "status": "pending", + "completeDate": null , + "scheduledDate": "2021-04-25T12:00:00+02:00" +} +``` + + +## Create an user session from an activity + +You can also create a session directly from your activity’s creation : + +`POST 'https://api.decathlon.net/sportstrackingdata/v2/activities'` + +> Request Body + +```json +{ + "name": "Mon activité", + "startdate": "2021-04-22T09:09:27+00:00", + "duration": 3000, + "user": "/v2/users/{{ldid}}", + "sport": "/v2/sports/381", + "userSession":{ + "modelId": "test", + "userProgram": null, + "user": "/v2/users/{{ldid}}", + "type": "session", + "provider": "DCM" + } +} +``` + + +## Create an activity and link to an exisiting user session + +As seen just above, you can create an activity and user Session at the same time. +You can also create an activity and link it to an already existing user session : + +`POST 'https://api.decathlon.net/sportstrackingdata/v2/activities'` + +> Request Body + +```json +{ + "name": "Mon activité", + "startdate": "2021-04-22T07:51:19+00:00", + "duration": 3000, + "user": "/v2/users/{{ldid}}", + "sport": "/v2/sports/381", + "userSession":"/v2/user_sessions/yourUserSessionId" +} +``` + +## Relations between session and activity +You can link multiple activities to the same user session : +Relation N:1. +User session has a field completeDate who is automatically completed by the first activity’s startdate linked. You can update it with a PUT userSession if needed. + + diff --git a/docs/071-get-user-favorites.md b/docs/071-get-user-favorites.md index aef271f..3395ecc 100644 --- a/docs/071-get-user-favorites.md +++ b/docs/071-get-user-favorites.md @@ -10,7 +10,7 @@ User can save some favorites things. -## Retreive user's favorites +## Retrieve user's favorites ### Parameters