public function schoolName()
    {
        // simple counter measure to slow down brute force attack
        sleep(1);

        $data = $this->getParameters();

        $required = ['school_number', 'school_pin'];

        $response = [];
        $success = true;

        foreach($required as $fieldName) {
            if (!isset($data[$fieldName])) {
                $success = false;
                $response['errorCode'] = 400;
                $response['errorMessage'] = __('Missing field %s', $fieldName);
                break;
            }
        }

        if ($success) {
            try {
                $schoolNameProvider = $this->getServiceLocator()->get(SchoolNameService::SERVICE_ID);
                $response['data'] = $schoolNameProvider->getSchoolName($data['school_number'], $data['school_pin']);
            } catch(\Exception $e) {
                $success = false;
                $response['errorCode'] = 404;
                $response['errorMessage'] = __('Cannot retrieve the school name. Please verify your input');
            }
        }

        $response['success'] = $success;
        $this->returnJson($response);
    }
public function schoolName()
    {
        // simple counter measure to slow down brute force attack
        sleep(1);

        $data = $this->getParameters();

        $required = ['school_number', 'school_pin'];

        $response = [];
        $success = true;

        foreach($required as $fieldName) {
            if (!isset($data[$fieldName])) {
                $success = false;
                $response['errorCode'] = 400;
                $response['errorMessage'] = __('Missing field %s', $fieldName);
                break;
            }
        }

        if ($success) {
            try {
                $schoolNameProvider = $this->getServiceLocator()->get(SchoolNameService::SERVICE_ID);
                $response['data'] = $schoolNameProvider->getSchoolName($data['school_number'], $data['school_pin']);
            } catch(\Exception $e) {
                $success = false;
                $response['errorCode'] = 404;
                $response['errorMessage'] = __('Cannot retrieve the school name. Please verify your input');
            }
        }

        $response['success'] = $success;
        $this->returnJson($response);
    }
public function schoolName ( ) { // simple counter measure to slow down brute force attack sleep ( 1 ) ; $ data = $ this -> getParameters ( ) ; $ required = [ 'school_number' , 'school_pin' ] ; $ response = [ ] ; $ success = true ; foreach ( $ required as $ fieldName ) { if ( ! isset ( $ data [ $ fieldName ] ) ) { $ success = false ; $ response [ 'errorCode' ] = 400 ; $ response [ 'errorMessage' ] = __ ( 'Missing field %s' , $ fieldName ) ; break ; } } if ( $ success ) { try { $ schoolNameProvider = $ this -> getServiceLocator ( ) -> get ( SchoolNameService :: SERVICE_ID ) ; $ response [ 'data' ] = $ schoolNameProvider -> getSchoolName ( $ data [ 'school_number' ] , $ data [ 'school_pin' ] ) ; } catch ( \ Exception $ e ) { $ success = false ; $ response [ 'errorCode' ] = 404 ; $ response [ 'errorMessage' ] = __ ( 'Cannot retrieve the school name. Please verify your input' ) ; } } $ response [ 'success' ] = $ success ; $ this -> returnJson ( $ response ) ; }
Retrieve a school name
Retrieve a school name