import { Attr } from 'ts-framework' import { OperatorResponseDTO } from './operator' import { RiderResponseWithDetailsDTO } from './rider-response' import { UserAppRoleResponseDTO } from './user-app-role' import { CreateUserEmailDTO, UserEmailResponseDTO } from './user-email' import { CreateUserPhoneDTO, UserPhoneResponseDTO } from './user-phones' export class CreateUserDTO { @Attr({ type: String }) firstName: string @Attr({ type: String }) lastName: string @Attr({ type: String }) password: string @Attr({ type: String }) username: string @Attr({ type: CreateUserPhoneDTO }) phones: CreateUserPhoneDTO[] @Attr({ type: CreateUserEmailDTO, optional: true }) email?: CreateUserEmailDTO @Attr({ type: Array, optional: true }) middleName?: string @Attr({ type: String, optional: true }) note?: string @Attr({ type: String, optional: true }) birthDate?: string @Attr({ type: String, optional: true }) rolesInApp?: string[] @Attr({ type: String, optional: true }) photo?: string } export class CreateUserWithOwnerProviderDTO { @Attr({ type: String }) firstName: string @Attr({ type: String }) lastName: string @Attr({ type: String }) providerId: string @Attr({ type: CreateUserPhoneDTO }) phones: CreateUserPhoneDTO[] @Attr({ type: String }) username: string @Attr({ type: String, optional: true }) birthDate?: string @Attr({ type: Array, optional: true }) middleName?: string @Attr({ type: String, optional: true }) note?: string @Attr({ type: String }) password: string @Attr({ type: CreateUserEmailDTO, optional: true }) email?: CreateUserEmailDTO @Attr({ type: String, optional: true }) photo?: string } export class UpdateUserDTO { @Attr({ type: String }) id: string @Attr({ type: String, optional: true }) birthDate?: string @Attr({ type: CreateUserEmailDTO, optional: true }) email?: CreateUserEmailDTO @Attr({ type: String, optional: true }) firstName?: string @Attr({ type: String, optional: true }) lastName?: string @Attr({ type: Array, optional: true }) middleName?: string @Attr({ type: String, optional: true }) note?: string @Attr({ type: String, optional: true }) rolesInApp?: string[] @Attr({ type: CreateUserPhoneDTO, optional: true }) phones?: CreateUserPhoneDTO[] @Attr({ type: String, optional: true }) photo?: string @Attr({ type: String, optional: true }) username?: string @Attr({ type: String, optional: true }) externalId?: string } export class UserOnlyResponseDTO { id: string firstName: string lastName: string isDeleted: boolean isActive: boolean createdAt: Date updatedAt: Date username: string middleName?: string constructor(model: UserOnlyResponseDTO) { this.id = model.id this.firstName = model.firstName this.lastName = model.lastName this.isDeleted = model.isDeleted this.isActive = model.isActive this.createdAt = model.createdAt this.updatedAt = model.updatedAt this.middleName = model.middleName this.username = model.username } static of(model: UserOnlyResponseDTO): UserOnlyResponseDTO { return new UserOnlyResponseDTO(model) } } export class UserInfoDTO { photo?: string birthDate?: string note?: string } export class UserResendInvitation { @Attr({ type: String }) userId: string @Attr({ type: String }) organizationId: string } export class UserResponseDTO { id: string firstName: string lastName: string isDeleted: boolean isActive: boolean createdAt: Date updatedAt: Date username: string phones: UserPhoneResponseDTO[] rolesInApp: UserAppRoleResponseDTO[] email?: UserEmailResponseDTO middleName?: string photo?: string birthDate?: string note?: string info?: UserInfoDTO invitationTime?: Date constructor(model: UserResponseDTO) { this.id = model.id this.firstName = model.firstName this.lastName = model.lastName this.isDeleted = model.isDeleted this.isActive = model.isActive this.createdAt = model.createdAt this.updatedAt = model.updatedAt this.phones = model.phones this.email = model.email this.middleName = model.middleName this.username = model.username this.rolesInApp = model.rolesInApp if (model.info) { this.birthDate = model.info.birthDate this.photo = model.info.photo this.note = model.info.note } } static of(model: UserResponseDTO): UserResponseDTO { return new UserResponseDTO(model) } } export class UserResponseWithRolesDTO { operator?: OperatorResponseDTO | null rider?: RiderResponseWithDetailsDTO | null } export class UserResponseWithPasswordDTO extends UserResponseDTO { password: string constructor(model: UserResponseWithPasswordDTO) { super(model) this.password = model.password } static of(model: UserResponseWithPasswordDTO): UserResponseWithPasswordDTO { return new UserResponseWithPasswordDTO(model) } } export class UserRemoveDTO { @Attr({ type: String }) id: string } export class UserDeactivateDTO { @Attr({ type: String }) id: string } export class UserFindByIdsDTO { @Attr({ type: String }) ids: string[] } export class UserSearchDTO { @Attr({ type: String, optional: true }) ids?: string[] @Attr({ type: String, optional: true }) firstName?: string @Attr({ type: String, optional: true }) lastName?: string @Attr({ type: String, optional: true }) fullName?: string @Attr({ type: String, optional: true }) fullPhoneNumber?: string @Attr({ type: Number, optional: true }) limit?: number } export class ChangePasswordByRecoveryTokenDTO { @Attr({ type: String }) passwordRecoveryToken: string @Attr({ type: String }) password: string @Attr({ type: String }) passwordConfirmation: string } export interface UserPhotoResponseDTO { userId: string photo?: string } export class UserNameResponseDTO { @Attr({ type: String }) firstName: string @Attr({ type: String }) lastName: string }