<?php

namespace Yajny\Member\Entities\BalanceTransactions;

class ProcessedTransaction
{
    public $rawTransaction;
    public $is_processed;

    public function __construct(RawTransaction $rawTransaction, $is_processed = 0)
    {
        $this->rawTransaction = $rawTransaction;
        $this->is_processed = $is_processed;
    }

    public function toArray()
    {
        return [
            'user_id' => $this->rawTransaction->user_id,
            'source_type' => $this->rawTransaction->source_type,
            'source_id' => $this->rawTransaction->source_id,
            'amount' => $this->rawTransaction->amount,
            'status' => $this->rawTransaction->status,
            'is_processed' => $this->is_processed,
            'raw_transaction' => json_encode($this->rawTransaction->toArray())
        ];
    }
}