Commit 9d796baa authored by Emiliano Balbuena's avatar Emiliano Balbuena

(fix): Query issues; (chore): Tweak response

1 merge request!281WIP: (feat): Minds Pro
Pipeline #72478041 passed with stages
in 11 minutes and 6 seconds
......@@ -29,7 +29,8 @@ class pro implements Interfaces\Api
->setUser(Session::getLoggedinUser());
return Factory::response([
'active' => $manager->isActive()
'isActive' => $manager->isActive(),
/* TODO: Send values */
]);
}
......@@ -45,11 +46,26 @@ class pro implements Interfaces\Api
$manager
->setUser(Session::getLoggedinUser());
$success = $manager->enable(time() + (365 * 86400));
switch ($pages[0]) {
case 'enable':
// TODO: Send and process payment data
$success = $manager->enable(time() + (365 * 86400));
return Factory::response([
'done' => $success,
]);
if (!$success) {
return Factory::response([
'status' => 'error',
'message' => 'Error activating Pro',
]);
}
return Factory::response([/* TODO: Send values */]);
default:
return Factory::response([
'status' => 'error',
'message' => 'Unknown method'
]);
}
}
/**
......@@ -76,8 +92,13 @@ class pro implements Interfaces\Api
$success = $manager->disable();
return Factory::response([
'done' => $success,
]);
if (!$success) {
return Factory::response([
'status' => 'error',
'message' => 'Error disabling Pro',
]);
}
return Factory::response([]);
}
}
......@@ -39,10 +39,12 @@ class InitializeValuesDelegate
if (!$values) {
$values = new Values();
$values
->setUserGuid($user->guid);
}
if (!$values->getDomain()) {
$values->setDomain("pro-{$user->username}.minds.com");
$values->setDomain("pro-{$user->guid}.minds.com");
}
$this->repository
......
......@@ -49,11 +49,11 @@ class Repository
$cqlOpts = [];
if ($opts['user_guid']) {
$where .= 'user_guid = ?';
$where[] = 'user_guid = ?';
$values[] = new Bigint($opts['user_guid']);
} elseif ($opts['domain']) {
$cql = "SELECT * FROM pro_by_domain";
$where = 'domain = ?';
$where[] = 'domain = ?';
$values[] = $opts['domain'];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment