From 31e9884f944b31bd18bd1eb312331d1ea19d0d35 Mon Sep 17 00:00:00 2001 From: CJ Green <44074998+okaycj@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:37:13 -0500 Subject: [PATCH] Updated helper to be called by researchers --- packages/lookit-helpers/src/index.ts | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/lookit-helpers/src/index.ts b/packages/lookit-helpers/src/index.ts index de6ea5dc..962c3840 100644 --- a/packages/lookit-helpers/src/index.ts +++ b/packages/lookit-helpers/src/index.ts @@ -1,14 +1,24 @@ import api from "@lookit/lookit-api"; -async function child(uuid: string) { - const child = await api.retrieveChild(uuid); - const { given_name, birthday, age_at_birth, additional_information } = - child.attributes; - return { given_name, birthday, age_at_birth, additional_information }; -} +class Helpers { + child_uuid: string; + response_uuid: string; + + constructor(child_uuid: string, response_uuid: string) { + this.child_uuid = child_uuid; + this.response_uuid = response_uuid; + } + + async child() { + const child = await api.retrieveChild(this.child_uuid); + const { given_name, birthday, age_at_birth, additional_information } = + child.attributes; + return { given_name, birthday, age_at_birth, additional_information }; + } -async function pastSessions(response_uuid: string) { - return await api.retrievePastSessions(response_uuid); + async pastSessions() { + return await api.retrievePastSessions(this.response_uuid); + } } -export default { child, pastSessions }; +export default Helpers;