import UserTransactionsModel from "@/models/userTransactionsModel.js";

export default class MyUserModel
{
    id = "";
    firstName = "";
    lastName = "";
    userName = "";
    totalBalance = "";
    userTransactions = [];

    static createFromApiResult(apiResult){
        const userModel =  Object.assign(new MyUserModel(), apiResult);

        const notMapperTransaction = Object.freeze(userModel.userTransactions);
        userModel.userTransactions = [];

        for (const transaction of notMapperTransaction) {
            userModel.userTransactions.push(UserTransactionsModel.createFromApiResult(transaction))
        }

        return userModel;
    }
}