/** * @Given /^I send a POST request to the \'([^\']*)\' method with the values:$/ */ public function iSendAPOSTRequestToTheMethodWithTheValues($method, TableNode $table) { $tabel = $table->getRowsHash(); $my_api = new test_API("test.api.com"); try { switch ($method) { case 'getstandard': self::$api_response = $my_api->getStandard($tabel["dataIncarcare"], $tabel["page"], self::$the_auth_token); self::$requested_dataIncarcare = $tabel["dataIncarcare"]; self::$requested_page = $tabel["page"]; break; case 'getextended': self::$api_response = $my_api->getExtended($tabel["dataIncarcare"], $tabel["page"], self::$the_auth_token); self::$requested_dataIncarcare = $tabel["dataIncarcare"]; self::$requested_page = $tabel["page"]; break; case 'getone': self::$api_response = $my_api->getOne($tabel["numarHotarare"], $tabel["dataHotarare"], self::$the_auth_token); self::$requested_numarHotarare = $tabel["numarHotarare"]; self::$requested_dataHotarare = $tabel["dataHotarare"]; break; case 'gettoken': self::$api_response = $my_api->getToken($tabel["grand_type"], $tabel["username"], $tabel["password"], $tabel["client_id"], $tabel["client_secret"]); break; default: throw new Exception("The method '{$method}' does not exist in the API."); } } catch (Exception $e) { // Process the error throw new Exception($e->getMessage()); } }