Commit 995d247c authored by Emiliano Balbuena's avatar Emiliano Balbuena

(wip): Hydrate referrer

1 merge request!393WIP: (feat): Withdrawal status support
Pipeline #95461215 failed with stages
in 2 minutes and 43 seconds
......@@ -37,6 +37,7 @@ class withdrawals implements Interfaces\Api, Interfaces\ApiAdminPam
'limit' => isset($_GET['limit']) ? (int) $_GET['limit'] : 12,
'offset' => isset($_GET['offset']) ? $_GET['offset'] : '',
'hydrate' => true,
'admin' => true,
];
/** @var Response $withdrawals */
......
......@@ -30,4 +30,13 @@ class RequestHydrationDelegate
return $request
->setUser($user);
}
public function hydrateForAdmin(Request $request)
{
// TBD
// TODO: Hydrate referrer
return $request;
}
}
......@@ -95,7 +95,8 @@ class Manager
public function getList(array $opts = []): Response
{
$opts = array_merge([
'hydrate' => false
'hydrate' => false,
'admin' => false,
], $opts);
$requests = $this->repository->getList($opts);
......@@ -107,6 +108,10 @@ class Manager
$request = $this->requestHydrationDelegate->hydrate($request);
}
if ($opts['admin']) {
$request = $this->requestHydrationDelegate->hydrateForAdmin($request);
}
$response[] = $request;
}
......
......@@ -63,12 +63,15 @@ class Request implements JsonSerializable
/** @var User */
protected $user;
/** @var User */
protected $referrer;
/**
* @return array
*/
public function export()
{
return [
$data = [
'timestamp' => $this->timestamp,
'amount' => $this->amount,
'user_guid' => $this->userGuid,
......@@ -76,8 +79,17 @@ class Request implements JsonSerializable
'status' => $this->status,
'completed' => $this->completed,
'completed_tx' => $this->completedTx,
'user' => $this->user ? $this->user->export() : null,
];
if ($this->user) {
$data['user'] = $this->user->export();
}
if ($this->referrer) {
$data['referrer'] = $this->referrer->export();
}
return $data;
}
/**
......
Please register or to comment