import { request } from './index';

export type CreateTempUserDataType = { mobile: string };
export type TempUserType = CreateTempUserDataType;

export async function createTempUser(data: CreateTempUserDataType): Promise<TempUserType> {
  return await request(false, {
    url: '/users/temp-users',
    method: 'POST',
    data
  });
}

export type SendSmsKeyRequestDataType = { mobile: string };
export type SendSmsKeyRequestReturnType = SendSmsKeyRequestDataType;

export async function sendSmsKeyRequest(
  data: SendSmsKeyRequestDataType
): Promise<SendSmsKeyRequestReturnType> {
  return await request(false, {
    url: '/users/temp-users/send-sms-key',
    method: 'PATCH',
    data
  });
}

export type CheckSmsKeyRequestDataType = { mobile: string; smsKey: string };
export type CheckSmsKeyRequestReturnType = { mobile: string; authKey: string };

export async function checkSmsKeyRequest(
  data: CheckSmsKeyRequestDataType
): Promise<CheckSmsKeyRequestReturnType> {
  return await request(false, {
    url: '/users/temp-users/check-sms-key',
    method: 'PATCH',
    data
  });
}
