public function testObtener() { $autorization = sprintf("BASIC + window.btoa(%s + :xxx)", "asdasdasdas"); $options = array('body' => array(), 'config' => array(), 'headers' => array()); $milestone = new Milestone(); $milestone->__set("apiKey", "cat952yellow"); //var_dump($project -> __get("response")); $milestone->obtener(); $response = $milestone->__get("response"); error_log(print_r($response['body'], true)); $this->assertTrue($response['status'] == 'exito'); }
public function obtener() { try { $compania = new Milestone(); $compania->__set("apiKey", APIKEY_); $this->log->addInfo("Inicio flujo de Milestone", array(basename(__FILE__) . "::" . __LINE__)); $compania->obtener(); $response = $compania->__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_milestones')->values($insertValue); $insertId = $insertStatement->execute(); } } else { $this->log->addInfo("Sin recursos encontrados", array(basename(__FILE__) . "::" . __LINE__)); } } catch (PDOException $e) { $this->log->addInfo("PDOException", array(basename(__FILE__) . "::" . __LINE__)); $this->log->addInfo($e->getMessage(), array(basename(__FILE__) . "::" . __LINE__)); } catch (\Exception $e) { $this->log->addInfo(" ", array(basename(__FILE__) . "::" . __LINE__)); $this->log->addInfo($e->getMessage(), array(basename(__FILE__) . "::" . __LINE__)); } }