diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index ecc2e1a54..0908d7397 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -708,27 +708,6 @@ export class Billing { ); } - async setMailinglist(listId: string, name: string, email: string): Promise { - const path = `/mailinglists/${listId}`; - const uri = new URL('https://growth.appwrite.io/v1' + path); - const params = - name !== '' - ? { - email, - name - } - : { email }; - - return await this.client.call( - 'POST', - uri, - { - 'content-type': 'application/json' - }, - params - ); - } - async setMembership( programId: string ): Promise<{ $createdAt: string } | { error: { code: number; message: string } }> { diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 0b6cd287a..a62db4dd5 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -12,7 +12,7 @@ const handleGithubEducationMembership = async (name: string, email: string) => { `${base}/education/error?message=${result.error.message}&code=${result.error.code}` ); } else if (result && '$createdAt' in result) { - sdk.forConsole.billing.setMailinglist('gh-student', name, email); + setToGhStudentMailingList(name, email); } }; @@ -40,3 +40,15 @@ export const load: PageLoad = async ({ parent, url }) => { redirect(303, `${base}/onboarding${url.search}`); } }; + +const setToGhStudentMailingList = async (name: string, email: string) => { + const path = `/mailinglists/gh-student`; + const body = name !== '' ? { name, email } : { email }; + return fetch('https://growth.appwrite.io/v1' + path, { + method: 'POST', + body: JSON.stringify(body), + headers: { + 'Content-Type': 'application/json' + } + }); +};