Esempio n. 1
0
 public function testObtener()
 {
     $autorization = sprintf("BASIC  + window.btoa(%s + :xxx)", "asdasdasdas");
     $options = array('body' => array(), 'config' => array(), 'headers' => array());
     $time = new TimeEntry();
     $time->__set("apiKey", "cat952yellow");
     //var_dump($project -> __get("response"));
     $time->obtener();
     error_log(print_r($time->__get("response"), true));
 }
Esempio n. 2
0
 public function obtener()
 {
     try {
         $timeEntry = new TimeEntry();
         $timeEntry->__set("apiKey", APIKEY_);
         $this->log->addInfo("Inicio flujo de TimeEntry", array(basename(__FILE__) . "::" . __LINE__));
         $timeEntry->obtener();
         $response = $timeEntry->__get("response");
         if ($response['status'] == "exito" && count($response['body']) > 0) {
             $this->log->addInfo("Respuesta de api exitosa", array(basename(__FILE__) . "::" . __LINE__));
             $values = array();
             $pdo = new \Slim\PDO\Database(BD_DNS_, BD_USER_, BD_PWD_);
             //Conexion::getInstance();
             foreach ($response['body'] as $key => $value) {
                 $keys = array();
                 $insertValue = array();
                 foreach ($value as $keyB => $valueB) {
                     array_push($keys, $keyB);
                     array_push($insertValue, empty($valueB) || $valueB == '' ? 'null' : $valueB);
                 }
                 $this->log->addInfo(print_r($keys, true), array(basename(__FILE__) . "::" . __LINE__));
                 $this->log->addInfo(print_r($insertValue, true), array(basename(__FILE__) . "::" . __LINE__));
                 $insertStatement = $pdo->insert($keys)->into('lkp_time_entries')->values($insertValue);
                 $insertId = $insertStatement->execute();
             }
         } else {
             $this->log->addInfo("Sin recursos encontrados", array(basename(__FILE__) . "::" . __LINE__));
         }
     } catch (PDOException $e) {
         $this->log->addError("PDOException", array(basename(__FILE__) . "::" . __LINE__));
         $this->log->addError($e->getMessage(), array(basename(__FILE__) . "::" . __LINE__));
     } catch (\Exception $e) {
         $this->log->addError(" ", array(basename(__FILE__) . "::" . __LINE__));
         $this->log->addError($e->getMessage(), array(basename(__FILE__) . "::" . __LINE__));
     }
 }