Skip to content

Instantly share code, notes, and snippets.

@reginaldojunior
Created December 7, 2016 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reginaldojunior/e8bd2c468b0af5e98bf1357a739c41d0 to your computer and use it in GitHub Desktop.
Save reginaldojunior/e8bd2c468b0af5e98bf1357a739c41d0 to your computer and use it in GitHub Desktop.
bonito.php
<?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