Created
December 7, 2016 18:14
-
-
Save reginaldojunior/e8bd2c468b0af5e98bf1357a739c41d0 to your computer and use it in GitHub Desktop.
bonito.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\User; | |
use App\Products; | |
use App\Logs; | |
use Session; | |
use Route; | |
use Response; | |
use App\Library\ExternalIntegration\Products as ProductsIntegration; | |
use App\Library\PluggToCommunication\PluggToProduct; | |
class ProductsController extends Controller | |
{ | |
protected $Integration; | |
protected $PluggToProduct; | |
protected $userListData; | |
protected $Products; | |
public function __construct() | |
{ | |
$this->ProductsIntegration = new ProductsIntegration; | |
$this->Products = new Products; | |
} | |
public function importByUserId($userId) | |
{ | |
$this->PluggToProduct = new PluggToProduct($userId); | |
$productsProcessedOnFormatPluggTo = $this->ProductsIntegration | |
->setKeyShop($this->PluggToProduct->user->key_shop) | |
->setKeyApp($this->PluggToProduct->user->key_app) | |
->getAllProducts() | |
->getListProductsFormatPluggTo(); | |
return $this->getResponseProductsSendings($productsProcessedOnFormatPluggTo, $userId); | |
} | |
public function refreshProductsLastHourByUserId($userId) | |
{ | |
$this->PluggToProduct = new PluggToProduct($userId); | |
$productsProcessedOnFormatPluggTo = $this->ProductsIntegration | |
->setKeyShop($this->PluggToProduct->user->key_shop) | |
->setKeyApp($this->PluggToProduct->user->key_app) | |
->getProductsChangedsLastHour() | |
->getListProductsFormatPluggTo(); | |
return $this->getResponseProductsSendings($productsProcessedOnFormatPluggTo, $userId); | |
} | |
public function getResponseProductsSendings($productsProcessedOnFormatPluggTo, $userId) | |
{ | |
$this->PluggToProduct->setProducts($productsProcessedOnFormatPluggTo); | |
$this->Products->saveFromDataPlugg($productsProcessedOnFormatPluggTo, $userId); | |
$productsSendingsToPluggTo = $this->PluggToProduct->sendListProducts(); | |
return Response::json( | |
$productsSendingsToPluggTo, | |
200 | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment