mtcute/packages/client/src/methods/auth/accept-tos.ts

32 lines
602 B
TypeScript
Raw Normal View History

2021-04-08 12:19:38 +03:00
import { TelegramClient } from '../../client'
2021-08-05 20:38:24 +03:00
import { MtTypeAssertionError } from '../../types'
2021-04-08 12:19:38 +03:00
/**
* Accept the given TOS
*
* @param tosId TOS id
* @internal
*/
export async function acceptTos(
this: TelegramClient,
tosId: string,
2021-04-08 12:19:38 +03:00
): Promise<boolean> {
const res = await this.call({
_: 'help.acceptTermsOfService',
id: {
_: 'dataJSON',
data: tosId,
},
})
if (!res) {
2021-08-05 20:38:24 +03:00
throw new MtTypeAssertionError(
'help.acceptTermsOfService',
2021-04-08 12:19:38 +03:00
'true',
'false',
2021-04-08 12:19:38 +03:00
)
}
2021-04-08 12:19:38 +03:00
return true
}