Skip to content

Commit 5ae8916

Browse files
committed
refactor(client and API): status to consent
1 parent fc3acf9 commit 5ae8916

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

client/src/singleconsent.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ GovSingleConsent.prototype.init = function (
5858
Initialises _GovConsent object by performing the following:
5959
1. Removes 'uid' from URL.
6060
2. Sets 'uid' attribute from cookie or URL.
61-
3. Fetches consent status from API if 'uid' exists.
61+
3. Fetches consent object from API if 'uid' exists.
6262
4. Notifies event listeners with API response.
6363
64-
@arg updateConsentsCallback: function(status) - callback to update consent status - response consents object passed
65-
@arg revokeConsentsCallback: function() - callback to revoke all consents - error is passed
64+
@arg updateConsentsCallback: function(consent) - callback to update consent - response consent object passed
65+
@arg revokeConsentsCallback: function() - callback to revoke all consent - error is passed
6666
*/
6767

6868
validateCallbacks(updateConsentsCallback, revokeConsentsCallback)
@@ -91,7 +91,7 @@ GovSingleConsent.prototype.init = function (
9191
getConsentsUrl,
9292
{ timeout: 1000 },
9393
function (responseData) {
94-
this.updateConsentsCallback(responseData.status)
94+
this.updateConsentsCallback(responseData.consent)
9595
}.bind(this)
9696
)
9797
} catch (error) {
@@ -100,13 +100,13 @@ GovSingleConsent.prototype.init = function (
100100
}
101101
}
102102

103-
GovSingleConsent.prototype.setStatus = function (
104-
status,
105-
statusSetCallback,
103+
GovSingleConsent.prototype.setConsent = function (
104+
consent,
105+
consentsSetCallback,
106106
onErrorCallback
107107
) {
108-
if (!status) {
109-
throw new Error('status is required in GovSingleConsent.setStatus()')
108+
if (!consent) {
109+
throw new Error('consent is required in GovSingleConsent.setConsents()')
110110
}
111111

112112
var url = _GovConsentConfig()
@@ -116,8 +116,8 @@ GovSingleConsent.prototype.setStatus = function (
116116
var callback = function (response) {
117117
// get the current uid from the API if we don't already have one
118118
this.updateUID.bind(this)(response.uid)
119-
if (statusSetCallback) {
120-
statusSetCallback()
119+
if (consentsSetCallback) {
120+
consentsSetCallback()
121121
}
122122
}.bind(this)
123123

@@ -127,7 +127,7 @@ GovSingleConsent.prototype.setStatus = function (
127127
{
128128
method: 'POST',
129129
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
130-
body: 'status='.concat(JSON.stringify(status)),
130+
body: 'consent='.concat(JSON.stringify(consent)),
131131
},
132132
callback
133133
)

consent_api/routers/consent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ async def get_consent_status(
102102
origin: Annotated[str | None, Header()] = None,
103103
) -> UserConsent | None:
104104
"""Fetch a specified user's consent status."""
105-
status = (await get_user_consent(uid, db)).first()
106-
if not status:
105+
consent = (await get_user_consent(uid, db)).first()
106+
if not consent:
107107
response.status_code = 404
108-
return status
108+
return consent
109109

110110

111111
@consent.post("/{uid}")

0 commit comments

Comments
 (0)