mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Setting mailinglist from outside the sdk
This commit is contained in:
1 parent
33f854b203
commit
eca8420c01
2 files changed
+13
-22
No files matched your search
@@ -708,27 +708,6 @@ export class Billing {
|
||||
);
|
||||
}
|
||||
|
||||
async setMailinglist(listId: string, name: string, email: string): Promise<void> {
|
||||
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 } }> {
|
||||
|
||||
+13
-1
@@ -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'
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user