public string UploadModel(Project project, Space space, string filePath, string fileName)
 {
     string response = this.UploadFile("projects/" + project.id + "/models?spaceId=" + space.id, filePath, fileName);
     return response;
 }
 ///<Summary>
 ///
 ///</Summary>
 public Space SetSpace(Project project, Space space)
 {
     string spaceData = JsonConvert.SerializeObject(space);
     string spaceJson = this.PutRequest("projects/" + project.id + "/spaces/" + space.id, spaceData);
     Space setSpace = JsonConvert.DeserializeObject<Space>(spaceJson);
     return setSpace;
 }
 ///<Summary>
 ///TODO Set Space - Name, Transformation Matrix
 ///</Summary>
 public Space SetSpaceName(Project project, Space space, string name)
 {
     string spaceData = "{\"name\": \"" + name + "\"}";
     string spaceJson = this.PutRequest("projects/" + project.id + "/spaces/" + space.id, spaceData);
     Space setSpace = JsonConvert.DeserializeObject<Space>(spaceJson);
     return setSpace;
 }
 ///<Summary>
 ///Test if space is root of project
 ///</Summary>
 public Boolean IsRootSpace(Space space)
 {
     if (space.id == space.parentSpaceId)
     {
         return true;
     }
     return false;
 }
 ///<Summary>
 ///
 ///</Summary>
 public MetaModel SetModelReference(Project project, Space space, MetaModel modelReference)
 {
     string modelReferenceData = JsonConvert.SerializeObject(modelReference);
     string modelReferenceJson = this.PostRequest("projects/" + project.id + "/spaces/" + space.id + "/metamodels/" + modelReference.id, modelReferenceData);
     MetaModel setModelReference = JsonConvert.DeserializeObject<MetaModel>(modelReferenceJson);
     return setModelReference;
 }
 ///<Summary>
 ///Get SubSpace
 ///</Summary>
 public Space GetSubSpace(Project project, Space parent, string id)
 {
     string spaceJson = this.GetRequest("projects/" + project.id + "/spaces/" + parent.id + "/subspaces/" + id);
     Space space = JsonConvert.DeserializeObject<Space>(spaceJson);
     return space;
 }
 ///<Summary>
 ///Get SubSpaces By Parent ID
 ///</Summary>
 public SubSpaceList GetSubSpaces(Project project, Space parent)
 {
     string spaceJson = this.GetRequest("projects/" + project.id + "/spaces/" + parent.id + "/subspaces");
     SubSpaceList descendants = JsonConvert.DeserializeObject<SubSpaceList>(spaceJson);
     return descendants;
 }
 ///<Summary>
 ///Get Model Reference Details
 ///</Summary>
 public MetaModel GetModelReferenceDetails(Project project, Space space, string id)
 {
     string modelReferenceJson = this.GetRequest("projects/" + project.id + "/spaces/" + space.id + "/metamodels/" + id);
     MetaModel modelReference = JsonConvert.DeserializeObject<MetaModel>(modelReferenceJson);
     return modelReference;
 }
 ///<Summary>
 ///Get Models References in Space
 ///</Summary>
 public MetaModelList GetModelReferencesDetails(Project project, Space space)
 {
     string modelReferenceJson = this.GetRequest("projects/" + project.id + "/spaces/" + space.id + "/metamodels");
     MetaModelList modelReferences = JsonConvert.DeserializeObject<MetaModelList>(modelReferenceJson);
     return modelReferences;
 }
 ///<Summary>
 ///Download Model From Space
 ///</Summary>
 public string DownloadModel(Project project, Space space, string id, string path, string fileName)
 {
     return null;
 }
 ///<Summary>
 ///Delete Model Reference
 ///</Summary>
 public void DeleteModelReference(Project project, Space space, string id)
 {
     this.DeleteRequest("projects/" + project.id + "/spaces/" + space.id + "/metamodels/" + id);
 }
 ///<Summary>
 ///Create Space
 ///</Summary>
 public Space CreateSpace(Project project, Space parentSpace, string name)
 {
     string spaceData = "{\"name\": \"" + name + "\"}";
     string spaceJson = this.PostRequest("projects/" + project.id + "/spaces/" + parentSpace.id + "/subspaces", spaceData);
     Space space = JsonConvert.DeserializeObject<Space>(spaceJson);
     return space;
 }
 ///<Summary>
 ///Create a Model Reference (Metamodel) to a Model
 ///</Summary>
 public MetaModel CreateModelReference(Project project, Space space, Model model)
 {
     string modelData = "{\"modelId\": \"" + model.id + "\"}";
     string modelJson = this.PostRequest("projects/" + project.id + "/spaces/" + space.id + "/metamodels", modelData);
     MetaModel modelReference = JsonConvert.DeserializeObject<MetaModel>(modelJson);
     return modelReference;
 }
        public Model CreateModelAndVersionAndReference(Project project, Space space, string message, string modelFileName, string modelPath, string coverImageName, string coverImagePath)
        {
            // Read model file data
            FileStream modelFs = new FileStream(modelPath, FileMode.Open, FileAccess.Read);
            byte[] modelData = new byte[modelFs.Length];
            modelFs.Read(modelData, 0, modelData.Length);
            modelFs.Close();

            // Read coverImage data
            FileStream imageFs = new FileStream(coverImagePath, FileMode.Open, FileAccess.Read);
            byte[] imageData = new byte[imageFs.Length];
            imageFs.Read(imageData, 0, imageData.Length);
            imageFs.Close();

            // Generate post objects
            Dictionary<string, object> postParameters = new Dictionary<string, object>();
            postParameters.Add("message", message);
            postParameters.Add("file", new FileParameter(modelData, modelFileName));
            postParameters.Add("cover_img", new FileParameter(imageData, coverImageName));

            //make the request
            String modelJson = this.PostMultiPartFormDataPostRequest("projects/" + project.id + "/models?spaceId=" + space.id, postParameters);

            Model model = JsonConvert.DeserializeObject<Model>(modelJson);
            return model;
        }