Commit 635f25dc authored by Emiliano Balbuena's avatar Emiliano Balbuena

(wip): Campaign stats preview

1 merge request!235WIP: Boost Campaigns (&24)
Pipeline #71568950 failed with stages
in 3 minutes and 4 seconds
<?php
/**
* preview
* @author edgebal
*/
namespace Minds\Controllers\api\v2\boost\campaigns;
use Minds\Core\Boost\Campaigns\Campaign;
use Minds\Core\Boost\Campaigns\Stats;
use Minds\Core\Di\Di;
use Minds\Interfaces;
use Minds\Api\Factory;
class preview implements Interfaces\Api
{
/**
* Equivalent to HTTP GET method
* @param array $pages
* @return mixed|null
*/
public function get($pages)
{
return Factory::response([]);
}
/**
* Equivalent to HTTP POST method
* @param array $pages
* @return mixed|null
*/
public function post($pages)
{
$campaign = new Campaign();
$campaign
->setType($_POST['type'] ?? '')
->setEntityUrns($_POST['entity_urns'] ?? [])
->setBudgetType($_POST['budget_type'] ?? '')
->setHashtags($_POST['hashtags'] ?? [])
->setStart((int) ($_POST['start'] ?? 0))
->setEnd((int) ($_POST['end'] ?? 0))
->setBudget((float) ($_POST['budget'] ?? 0));
/** @var Stats $statsManager */
$statsManager = Di::_()->get('Boost\Campaigns\Stats');
$stats = $statsManager->get($campaign);
return Factory::response([
'preview' => [
'cannot_fulfill_daily' => $stats['cannot_fulfill_daily'],
]
]);
}
/**
* Equivalent to HTTP PUT method
* @param array $pages
* @return mixed|null
*/
public function put($pages)
{
return Factory::response([]);
}
/**
* Equivalent to HTTP DELETE method
* @param array $pages
* @return mixed|null
*/
public function delete($pages)
{
return Factory::response([]);
}
}
......@@ -71,6 +71,9 @@ class BoostProvider extends Provider
$this->di->bind('Boost\Campaigns\Repository', function ($di) {
return new Campaigns\Repository();
}, ['useFactory' => true]);
$this->di->bind('Boost\Campaigns\Stats', function ($di) {
return new Campaigns\Stats();
}, ['useFactory' => true]);
}
}
<?php
/**
* Stats
* @author edgebal
*/
namespace Minds\Core\Boost\Campaigns;
class Stats
{
/**
* @param Campaign $campaign
* @return array
*/
public function get(Campaign $campaign)
{
return [
'cannot_fulfill_daily' => false,
];
}
}
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