protected function generateManifest()
    {
        $manifest = $this->package->getManifestHeader();

        $requestedItems = $this->package->getServices();

        foreach ($requestedItems as $service => $resources) {
            foreach ($resources as $resourceName => $details) {
                if (isset($this->data[$service][$resourceName])) {
                    $records = $this->data[$service][$resourceName];
                    foreach ($records as $i => $record) {
                        $api = $service . '/' . $resourceName;
                        switch ($api) {
                            case 'system/user':
                            case 'system/admin':
                                $manifest['service'][$service][$resourceName][] =
                                    array_get($record, 'email', array_get($record, 'id', array_get($details, $i, [])));
                                break;
                            default:
                                $manifest['service'][$service][$resourceName][] =
                                    array_get($record, 'name', array_get($record, 'id', array_get($details, $i, [])));
                                break;
                        }
                    }
                } else {
                    $manifest['service'][$service][$resourceName] = $details;
                }
            }
        }

        return $manifest;
    }