Пример #1
0
 /** @inheritdoc */
 public function get($ids = null)
 {
     /* prepare request parameters */
     if (is_array($ids)) {
         $params = [self::ODOO_IDS => $ids];
     } elseif (is_int($ids)) {
         $params = [self::ODOO_IDS => [$ids]];
     } else {
         $params = [self::ODOO_IDS => []];
     }
     /* perform request and extract result data */
     $cover = $this->_rest->request($params, self::ROUTE);
     $data = $cover->getResultData();
     $result = $this->_mageSrvInProc->convertValue($data, \Praxigento\Odoo\Data\Odoo\Inventory::class);
     return $result;
 }
Пример #2
0
 public function save($order)
 {
     /* prepare request parameters */
     $underscored = $order->getData(null, true);
     /* perform request and extract result data */
     $cover = $this->_rest->request($underscored, self::ROUTE);
     $data = $cover->getResultData();
     if ($data) {
         $result = $this->_mageSrvInProc->convertValue($data, \Praxigento\Odoo\Data\Odoo\SaleOrder\Response::class);
     } else {
         $error = $cover->getError();
         $result = $this->_mageSrvInProc->convertValue($error, \Praxigento\Odoo\Data\Odoo\Error::class);
         /** TODO : delete tmp code (cannot use getData as getter for property) */
         $debug = $error['data']['debug'];
         $name = $error['data']['name'];
         $result->setDebug($debug);
         $result->setName($name);
     }
     return $result;
 }