<?php

namespace App\Controllers;

class Employers  extends BaseController
{

    public function verifyEmployer()
    {
        $data = $this->request->getPost();

        if ($data['employer_uid'] != '') {

            $checkData = $this->APIcall("POST", "http://10.10.10.48:6332/api/verify/employer", json_encode($data));


            $udata = [
                'employer_uid' => $data['employer_uid']
            ];
            $addedData =  $this->insert_db('employer_checks',$udata);

            if(  $addedData["uid"] ==''){
                $response = [
                    'message' => 'Failure',
                    'call_return' => '100',
                    'token' => '',
                    'verify_data' => $checkData
                ];
                return $this->fail($response, 500);
            }

            $response = [
                'message' => 'Verification text sent to employer',
                'call_return' => '100',
                'verification_id' => $addedData["uid"],
                'status' => $checkData["res"]["status"],
                'verify_data' => $checkData["res"]["data"]
            ];

            return $this->respond($response, 200);
        } else {
            $response = [
                'message' => 'Failure',
                'call_return' => '100',
                'token' => ''
            ];
            return $this->fail($response, 409);
        }


        //return json_encode( $response );

    }
}