Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dktunited/sports-tracking-data-do…
Browse files Browse the repository at this point in the history
…cumentation
  • Loading branch information
canssens committed Jun 21, 2021
2 parents a909e37 + e778456 commit 06699b1
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 21 deletions.
80 changes: 60 additions & 20 deletions docs/063-user-program.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 :

Expand All @@ -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"]
}
}
```

Expand All @@ -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.
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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.
Expand Down Expand Up @@ -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": {
Expand Down
169 changes: 169 additions & 0 deletions docs/064-from-program-to-activity.md
Original file line number Diff line number Diff line change
@@ -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.


2 changes: 1 addition & 1 deletion docs/071-get-user-favorites.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ User can save some favorites things.



## Retreive user's favorites
## Retrieve user's favorites

### Parameters

Expand Down

0 comments on commit 06699b1

Please sign in to comment.