protected function checkResponse(ResponseInterface $response, $data)
    {
        if ($response->getStatusCode() >= 400) {
            $errorMessage = '';
            if (!empty($data['errors'])) {
                foreach ($data['errors'] as $error) {
                    if (!empty($errorMessage)) {
                        $errorMessage .= ' , ';
                    }
                    $errorMessage .= implode(' - ', $error);
                }
            } else {
                $errorMessage = $response->getReasonPhrase();
            }
            throw new IdentityProviderException(
                $errorMessage,
                $response->getStatusCode(),
                $response
            );
        }
    }
protected function checkResponse(ResponseInterface $response, $data)
    {
        if ($response->getStatusCode() >= 400) {
            $errorMessage = '';
            if (!empty($data['errors'])) {
                foreach ($data['errors'] as $error) {
                    if (!empty($errorMessage)) {
                        $errorMessage .= ' , ';
                    }
                    $errorMessage .= implode(' - ', $error);
                }
            } else {
                $errorMessage = $response->getReasonPhrase();
            }
            throw new IdentityProviderException(
                $errorMessage,
                $response->getStatusCode(),
                $response
            );
        }
    }
protected function checkResponse ( ResponseInterface $ response , $ data ) { if ( $ response -> getStatusCode ( ) >= 400 ) { $ errorMessage = '' ; if ( ! empty ( $ data [ 'errors' ] ) ) { foreach ( $ data [ 'errors' ] as $ error ) { if ( ! empty ( $ errorMessage ) ) { $ errorMessage .= ' , ' ; } $ errorMessage .= implode ( ' - ' , $ error ) ; } } else { $ errorMessage = $ response -> getReasonPhrase ( ) ; } throw new IdentityProviderException ( $ errorMessage , $ response -> getStatusCode ( ) , $ response ) ; } }
Checks Fitbit API response for errors.

@throws IdentityProviderException

@param ResponseInterface $response
@param array|string      $data     Parsed response data
Checks Fitbit API response for errors .