From 53ef3e7f3bdd5a67bb6e800f94c0be96c1706976 Mon Sep 17 00:00:00 2001 From: Lennard Strohmeyer <lennard.strohmeyer@digitallearning.gmbh> Date: Thu, 27 Mar 2025 17:07:29 +0100 Subject: [PATCH] #152: streamlined third party API, updated documentation --- docs/docs/third_party_access.md | 789 ++++++++++---------------------- src/consents/views.py | 14 - 2 files changed, 235 insertions(+), 568 deletions(-) diff --git a/docs/docs/third_party_access.md b/docs/docs/third_party_access.md index 93328c1..cdd896d 100644 --- a/docs/docs/third_party_access.md +++ b/docs/docs/third_party_access.md @@ -18,7 +18,7 @@ In cases were neither a provider schema is available or the provider hasn't yet ### Get user consent -This endpoint returns the current user consent for a given user along with the provider schema the user accepted and a flag for data recording pausation. +This endpoint returns the current user consent for a given user, along with a flag indicating data recording pausation. - HTTP Method: **GET** - URL `/api/v1/consents/user/status/user1@polaris.com/third-party` @@ -31,11 +31,11 @@ This endpoint returns the current user consent for a given user along with the p ###### Returns -| Code | Type | Description | -| ----- | ---- | -------------------------------------------------------------------------------------------- | -| `200` | dict | dict containing `user_consent`, `provider_schema` and `paused_data_recording` (boolean flag) | -| `401` | dict | invalid token | -| `400` | dict | invalid request data e.g. `{"user_id":["Object with email=user1@polaris does not exist."]}` | +| Code | Type | Description | +| ----- | ---- |------------------------------------------------------------------------------------------| +| `200` | dict | dict containing `consent` and `paused_data_recording` (boolean flag) | +| `401` | dict | invalid token | +| `400` | dict | invalid request data e.g. `{"user_id":["Object with email=user1@polaris does not exist."]}` | ###### Example @@ -45,7 +45,7 @@ $ curl -X GET http://[RIGHT_ENGINE_URL]/api/v1/consents/user/status/user1@polari Response -```js +```json { "consent": { "id": 1, @@ -138,181 +138,13 @@ Response "objects": [] }] }, - "provider_schema": { - "id": 1, - "definition": { - "id": "h5p-0", - "name": "H5P", - "description": "Open-source content collaboration framework", - "groups": [{ - "label": "Default group", - "description": "default", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/experienced", - "label": "Experienced", - "description": "Experienced", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", - "label": "1.1.1 Funktionen", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.1.1 Funktionen" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/attempted", - "label": "Attempted", - "description": "Attempted", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", - "label": "2.3.1 Funktion Zirkulationsleitung", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "2.3.1 Funktion Zirkulationsleitung" - } - } - }] - }], - "isDefault": true - }, { - "label": "Group 2", - "description": "Lorem ipsum", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/interacted", - "label": "Interacted", - "description": "Lorem ipsum", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", - "label": "1.2.3 Kappenventil", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.2.3 Kappenventil" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/answered", - "label": "Answered", - "description": "lorem ipsum", - "defaultConsent": false, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", - "label": "7.2.1 Ventil Basics", - "defaultConsent": false, - "definition": { - "name": { - "enUS": "7.2.1 Ventil Basics" - } - } - }] - }], - "isDefault": false - }], - "essential_verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/liked", - "label": "Liked", - "description": "Like interaction", - "defaultConsent": true, - "objects": [] - }] - }, - "groups": [{ - "label": "Default group", - "description": "default", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/experienced", - "label": "Experienced", - "description": "Experienced", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", - "label": "1.1.1 Funktionen", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.1.1 Funktionen" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/attempted", - "label": "Attempted", - "description": "Attempted", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", - "label": "2.3.1 Funktion Zirkulationsleitung", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "2.3.1 Funktion Zirkulationsleitung" - } - } - }] - }], - "isDefault": true - }, { - "label": "Group 2", - "description": "Lorem ipsum", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/interacted", - "label": "Interacted", - "description": "Lorem ipsum", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", - "label": "1.2.3 Kappenventil", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.2.3 Kappenventil" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/answered", - "label": "Answered", - "description": "lorem ipsum", - "defaultConsent": false, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", - "label": "7.2.1 Ventil Basics", - "defaultConsent": false, - "definition": { - "name": { - "enUS": "7.2.1 Ventil Basics" - } - } - }] - }], - "isDefault": false - }], - "essential_verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/liked", - "label": "Liked", - "description": "Like interaction", - "defaultConsent": true, - "objects": [] - }], - "updated": "2023-02-09T12:45:57.562000Z", - "created": "2023-02-09T12:45:57.562000Z", - "provider": 1, - "superseded_by": null - }, "paused_data_recording": false } ``` ### Get provider details -Allows a third party to query the details of one's provider. Among other things, all created schemas are supplied here. +Allows a third party to query the details of the current provider. Among other things, all associated groups and created schemas are supplied here. - HTTP Method: **GET** - URL `/api/v1/consents/provider-status/third-party` @@ -325,383 +157,254 @@ $ curl -X GET 127.0.0.1:8003/api/v1/consents/provider-status/third-party -H "Con Response -```js +```json { - "id": 1, - "name": "H5P", - "versions": [{ - "id": 5, - "definition": { - "id": "h5p-0", - "name": "H5P", - "description": "Open-source content collaboration framework", - "groups": [{ - "label": "Default group", - "description": "default", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/experienced", - "label": "Experienced", - "description": "Experienced", - "defaultConsent": false, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", - "label": "1.1.1 Funktionen", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.1.1 Funktionen" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/attempted", - "label": "Attempted", - "description": "Attempted", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", - "label": "2.3.1 Funktion Zirkulationsleitung", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "2.3.1 Funktion Zirkulationsleitung" - } - } - }] - }], - "isDefault": true - }, { - "label": "Group 2", - "description": "Lorem ipsum", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/interacted", - "label": "Interacted", - "description": "Lorem ipsum", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", - "label": "1.2.3 Kappenventil", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.2.3 Kappenventil" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/answered", - "label": "Answered", - "description": "lorem ipsum", - "defaultConsent": false, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", - "label": "7.2.1 Ventil Basics", - "defaultConsent": false, - "definition": { - "name": { - "enUS": "7.2.1 Ventil Basics" - } - } - }] - }], - "isDefault": false - }], - "essential_verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/liked", - "label": "Liked", - "description": "Like interaction", - "defaultConsent": true, - "objects": [] - }, { - "id": "http://h5p.example.com/expapi/verbs/clicked", - "label": "Clicked", - "description": "Clicked interaction", - "defaultConsent": true, - "objects": [] - }] + "id": 1, + "name": "H5P", + "groups": [ + { + "id": 1, + "verbs": [ + { + "id": "http://h5p.example.com/expapi/verbs/experienced", + "label": "Experienced", + "description": "Experienced", + "defaultConsent": true, + "objects": [ + { + "id": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", + "objectType": "Activity", + "defaultConsent": true, + "definition": { + "type": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", + "name": { + "enUS": "1.1.1 Funktionen" + } + }, + "object_type": "Activity", + "matching": "definitionType", + "label": "" + } + ] }, - "groups": [{ - "label": "Default group", - "description": "default", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/experienced", - "label": "Experienced", - "description": "Experienced", - "defaultConsent": false, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", - "label": "1.1.1 Funktionen", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.1.1 Funktionen" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/attempted", - "label": "Attempted", - "description": "Attempted", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", - "label": "2.3.1 Funktion Zirkulationsleitung", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "2.3.1 Funktion Zirkulationsleitung" - } - } - }] - }], - "isDefault": true - }, { - "label": "Group 2", - "description": "Lorem ipsum", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/interacted", - "label": "Interacted", - "description": "Lorem ipsum", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", - "label": "1.2.3 Kappenventil", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.2.3 Kappenventil" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/answered", - "label": "Answered", - "description": "lorem ipsum", - "defaultConsent": false, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", - "label": "7.2.1 Ventil Basics", - "defaultConsent": false, - "definition": { - "name": { - "enUS": "7.2.1 Ventil Basics" - } - } - }] - }], - "isDefault": false - }], - "essential_verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/liked", - "label": "Liked", - "description": "Like interaction", - "defaultConsent": true, - "objects": [] - }, { - "id": "http://h5p.example.com/expapi/verbs/clicked", - "label": "Clicked", - "description": "Clicked interaction", - "defaultConsent": true, - "objects": [] - }], - "updated": "2023-02-09T10:19:51.566456Z", - "created": "2023-02-09T10:19:51.566471Z", - "provider": 1, - "superseded_by": null - }, { - "id": 1, - "definition": { - "id": "h5p-0", - "name": "H5P", - "description": "Open-source content collaboration framework", - "groups": [{ - "label": "Default group", - "description": "default", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/experienced", - "label": "Experienced", - "description": "Experienced", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", - "label": "1.1.1 Funktionen", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.1.1 Funktionen" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/attempted", - "label": "Attempted", - "description": "Attempted", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", - "label": "2.3.1 Funktion Zirkulationsleitung", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "2.3.1 Funktion Zirkulationsleitung" - } - } - }] - }], - "isDefault": true - }, { - "label": "Group 2", - "description": "Lorem ipsum", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/interacted", - "label": "Interacted", - "description": "Lorem ipsum", - "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", - "label": "1.2.3 Kappenventil", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.2.3 Kappenventil" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/answered", - "label": "Answered", - "description": "lorem ipsum", - "defaultConsent": false, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", - "label": "7.2.1 Ventil Basics", - "defaultConsent": false, - "definition": { - "name": { - "enUS": "7.2.1 Ventil Basics" - } - } - }] - }], - "isDefault": false - }], - "essential_verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/liked", - "label": "Liked", - "description": "Like interaction", - "defaultConsent": true, - "objects": [] - }] + { + "id": "http://h5p.example.com/expapi/verbs/attempted", + "label": "Attempted", + "description": "Attempted", + "defaultConsent": true, + "objects": [ + { + "id": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", + "objectType": "Activity", + "defaultConsent": true, + "definition": { + "type": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", + "name": { + "enUS": "2.3.1 Funktion Zirkulationsleitung" + } + }, + "object_type": "Activity", + "matching": "definitionType", + "label": "" + } + ] }, - "groups": [{ - "label": "Default group", - "description": "default", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/experienced", - "label": "Experienced", - "description": "Experienced", + { + "id": "http://h5p.example.com/expapi/verbs/interacted", + "label": "Interacted", + "description": "Lorem ipsum", + "defaultConsent": true, + "objects": [ + { + "id": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", + "objectType": "Activity", + "defaultConsent": true, + "definition": { + "type": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", + "name": { + "enUS": "1.2.3 Kappenventil" + } + }, + "object_type": "Activity", + "matching": "definitionType", + "label": "" + } + ] + }, + { + "id": "http://h5p.example.com/expapi/verbs/answered", + "label": "Answered", + "description": "lorem ipsum", + "defaultConsent": false, + "objects": [ + { + "id": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", + "objectType": "Activity", + "defaultConsent": false, + "definition": { + "type": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", + "name": { + "enUS": "7.2.1 Ventil Basics" + } + }, + "object_type": "Activity", + "matching": "definitionType", + "label": "" + } + ] + } + ], + "purposeOfCollection": "Lorem Ipsum", + "group_id": "372f255714963f49f0f8e7acca75e0fc55140d00cae2d4328f5a9a6bf090c359", + "label": "Default group", + "description": "default", + "requires_consent": true, + "updated": "2025-03-27T16:01:20.025590Z", + "created": "2025-03-27T16:01:20.025602Z", + "provider": 1, + "provider_schema": 1 + } + ], + "versions": [ + { + "id": 1, + "definition": { + "id": "h5p-0", + "name": "H5P", + "description": "Open-source content collaboration framework", + "verbs": [ + { + "id": "http://h5p.example.com/expapi/verbs/experienced", + "label": "Experienced", + "description": "Experienced", + "defaultConsent": true, + "objects": [ + { + "id": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", + "objectType": "Activity", "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", - "label": "1.1.1 Funktionen", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.1.1 Funktionen" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/attempted", - "label": "Attempted", - "description": "Attempted", + "definition": { + "type": "http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF", + "name": { + "enUS": "1.1.1 Funktionen" + } + }, + "object_type": "Activity", + "matching": "definitionType", + "label": "" + } + ] + }, + { + "id": "http://h5p.example.com/expapi/verbs/attempted", + "label": "Attempted", + "description": "Attempted", + "defaultConsent": true, + "objects": [ + { + "id": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", + "objectType": "Activity", "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", - "label": "2.3.1 Funktion Zirkulationsleitung", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "2.3.1 Funktion Zirkulationsleitung" - } - } - }] - }], - "isDefault": true - }, { - "label": "Group 2", + "definition": { + "type": "http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm", + "name": { + "enUS": "2.3.1 Funktion Zirkulationsleitung" + } + }, + "object_type": "Activity", + "matching": "definitionType", + "label": "" + } + ] + }, + { + "id": "http://h5p.example.com/expapi/verbs/interacted", + "label": "Interacted", "description": "Lorem ipsum", - "verbs": [{ - "id": "http://h5p.example.com/expapi/verbs/interacted", - "label": "Interacted", - "description": "Lorem ipsum", + "defaultConsent": true, + "objects": [ + { + "id": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", + "objectType": "Activity", "defaultConsent": true, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", - "label": "1.2.3 Kappenventil", - "defaultConsent": true, - "definition": { - "name": { - "enUS": "1.2.3 Kappenventil" - } - } - }] - }, { - "id": "http://h5p.example.com/expapi/verbs/answered", - "label": "Answered", - "description": "lorem ipsum", + "definition": { + "type": "http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46", + "name": { + "enUS": "1.2.3 Kappenventil" + } + }, + "object_type": "Activity", + "matching": "definitionType", + "label": "" + } + ] + }, + { + "id": "http://h5p.example.com/expapi/verbs/answered", + "label": "Answered", + "description": "lorem ipsum", + "defaultConsent": false, + "objects": [ + { + "id": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", + "objectType": "Activity", "defaultConsent": false, - "objects": [{ - "id": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", - "label": "7.2.1 Ventil Basics", - "defaultConsent": false, - "definition": { - "name": { - "enUS": "7.2.1 Ventil Basics" - } - } - }] - }], - "isDefault": false - }], - "essential_verbs": [{ + "definition": { + "type": "http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b", + "name": { + "enUS": "7.2.1 Ventil Basics" + } + }, + "object_type": "Activity", + "matching": "definitionType", + "label": "" + } + ] + } + ], + "essential_verbs": [ + { "id": "http://h5p.example.com/expapi/verbs/liked", "label": "Liked", "description": "Like interaction", "defaultConsent": true, "objects": [] - }], - "updated": "2023-02-09T10:19:51.568203Z", - "created": "2023-02-09T09:45:15.405764Z", - "provider": 1, - "superseded_by": 5 - }] + } + ], + "additional_lrs": [] + }, + "additional_lrs": [], + "updated": "2025-03-27T16:01:20.013790Z", + "created": "2025-03-27T16:01:20.013799Z", + "provider": 1, + "superseded_by": null + } + ] } ``` ### Save user consent -The provider schema id for each provider must always refer to the latest schema version of the respective provider, otherwise the request will be rejected +Save consent declarations for one or multiple verb groups for a user. - HTTP Method: **POST** - URL `/api/v1/consents/user/save/third-party` ###### Parameters -| Name | Type | Required | Default | -| -------------------- | ---------- | -------- | ------- | -| `user_id` | str | Yes | None | -| `provider_schema_id` | int | Yes | None | -| `verbs` | list[dict] | Yes | None | +| Name | Type | Required | Default | +|----------------------|-----------| -------- | ------- | +| `user_id` | str | Yes | None | +| `groups` | list[int] | Yes | None | ###### Returns -| Code | Type | Description | -| ----- | ---- | ----------------------------------------------------------------------------------------------------- | -| `200` | dict | dict with entry for each user contain list of consented verb and object ids | -| `401` | dict | invalid token | -| `403` | dict | reaised if a verb for a provider other than the one associated with the application token is provided | -| `400` | dict | invalid request data e.g. `{"user_id":["Object with email=user1@polaris does not exist."]}` | +| Code | Type | Description | +| ----- | ---- |------------------------------------------------------------------------------------------------------| +| `200` | dict | dict with the key "message" stating that the consent was saved | +| `401` | dict | invalid token | +| `403` | dict | raised if a verb for a provider other than the one associated with the application token is provided | +| `400` | dict | invalid request data e.g. `{"user_id":["Object with email=user1@polaris does not exist."]}` | ###### Examples @@ -710,36 +413,14 @@ curl -X POST 127.0.0.1:8003/api/v1/consents/user/save/third-party --data '{ "use ``` -Formatted request payload -```js +Formatted request payload (group IDs have to be retrieved beforehand) +```json { "user_id": "user1@polaris.com", - "provider_schema_id": 3, - "verbs": [ - { - "provider": 1, - "id": "http://h5p.example.com/expapi/verbs/experienced", - "consented": false, - "objects": "[{\"id\":\"http://h5p.example.com/expapi/activity/QKGPPiIhI4zx9YAZZksLKigqyf7yW4WF\",\"label\":\"1.1.1 Funktionen\",\"defaultConsent\":true,\"definition\":{\"name\":{\"enUS\":\"1.1.1 Funktionen\"}},\"consented\":true}]" - }, - { - "provider": 1, - "id": "http://h5p.example.com/expapi/verbs/attempted", - "consented": true, - "objects": "[{\"id\":\"http://h5p.example.com/expapi/activity/VeH7S8NeGlCRM1myYRDBjHMCknLqDLgm\",\"label\":\"2.3.1 Funktion Zirkulationsleitung\",\"defaultConsent\":true,\"definition\":{\"name\":{\"enUS\":\"2.3.1 Funktion Zirkulationsleitung\"}},\"consented\":true}]" - }, - { - "provider": 1, - "id": "http://h5p.example.com/expapi/verbs/interacted", - "consented": true, - "objects": "[{\"id\":\"http://h5p.example.com/expapi/activity/ofN2ODcnLRaVu30lUpzrWPqF2AcG7g46\",\"label\":\"1.2.3 Kappenventil\",\"defaultConsent\":true,\"definition\":{\"name\":{\"enUS\":\"1.2.3 Kappenventil\"}},\"consented\":true}]" - }, - { - "provider": 1, - "id": "http://h5p.example.com/expapi/verbs/answered", - "consented": false, - "objects": "[{\"id\":\"http://h5p.example.com/expapi/activity/K34IszYvGE4R0cC72Ean6msLfLCJtQ8b\",\"label\":\"7.2.1 Ventil Basics\",\"defaultConsent\":false,\"definition\":{\"name\":{\"enUS\":\"7.2.1 Ventil Basics\"}},\"consented\":false}]" - } + "groups": [ + 1, + 2, + 5 ] } ``` diff --git a/src/consents/views.py b/src/consents/views.py index c4731ba..dc09367 100644 --- a/src/consents/views.py +++ b/src/consents/views.py @@ -806,23 +806,9 @@ class GetUsersConsentsThirdPartyView(APIView): status=status.HTTP_200_OK, ) else: - accepted_provider_schemas = user.accepted_provider_schemas.all() - provider_schemas = list( - filter( - lambda schema: schema.provider.id == int(provider.provider.id), - accepted_provider_schemas, - ) - ) - - provider_schema = ( - ProviderSchemaSerializer(provider_schemas, many=True).data[0] - if len(provider_schemas) > 0 - else None - ) return JsonResponse( { "consent": user_consent, - "provider_schema": provider_schema, "paused_data_recording": user.paused_data_recording, }, safe=False, -- GitLab