I'm using spark in codeigniter as a rest client to talk to the service. The apis are already built separately in swagger.
I'm trying to do an user login functionality. This is my api model schema:
{
"name": "string",
"email": "string",
"password": "string",
"mobile": "string",
"accType": "string",
"meta": "string",
"createdAt": 0
}
For testing user existence, this is my code :
function __construct(){
parent::__construct();
$this->load->library('rest', array(
'server' => 'http://stage.cogxio.co:7070/',
'api_key' => 'local',
'api_name' => 'X-API-KEY',
));
}
function user_exist($data){
$response = $this->rest->get('user/email/'.$data, 'json');
if(property_exists($response, "STATUS")){
$result_code = $response->STATUS;
if($result_code == 200){
return true;
}else{
return false;
}
} else {
return "server error";
}
}
The return of 1 will tell that the email exists otherwise does not exist.
When that checking is over, then I need to check whether the email and password are matching, that is "WHERE email=$email && password=$password
"
Since, I'm new to api, I don't know how to do that.
I know, I need to pass two variables.
function login_match($email, $password){
$response = $this->rest->get('user/email/??, 'json'); // what to do with this field?
}
I don't know how to use the where clause
here.