private function apiCall(
        $method,
        array $query = array(),
        callable $onSuccess,
        $emptyValue = null
    ) {
        try {
            return $onSuccess(
                $this->restApiClient->$method($query)
            );
        } catch (BadResponseException $e) {
            if (($response = $e->getResponse())
                && $response->getStatusCode() == 404
            ) {
                return $emptyValue;
            }

            throw $e;
        }
    }