public static CreateProjectGroupResponse Create(OneSkyService service, string name, CultureInfo culture) { //https://github.com/onesky/api-documentation-platform/blob/master/resources/project_group.md string url = "https://platform.api.onesky.io/1/project-groups"; string parameters = service.GetAuthenticationParameters() + "&name=" + name + "&locale=" + LocaleCodeHelper.ConvertToLocaleCode(culture.Name); url += "?" + parameters; using (var client = new WebClient()) { var jsonSerializer = new DataContractJsonSerializer(typeof(CreateProjectGroupResponse)); using (var stream = service.StringToStream(client.UploadString(url, parameters))) { return((CreateProjectGroupResponse)jsonSerializer.ReadObject(stream)); } } }
public static CreateProjectResponse Create(OneSkyService service, int projectGroupId, string name, string description, string projectType) { //https://github.com/onesky/api-documentation-platform/blob/master/resources/project.md string url = String.Format("https://platform.api.onesky.io/1/project-groups/{0}/projects", projectGroupId); string parameters = service.GetAuthenticationParameters() + "&name=" + name + "&description=" + description + "&project_type=" + projectType; url += "?" + parameters; using (var client = new WebClient()) { var jsonSerializer = new DataContractJsonSerializer(typeof(CreateProjectResponse)); using (var stream = service.StringToStream(client.UploadString(url, parameters))) { return((CreateProjectResponse)jsonSerializer.ReadObject(stream)); } } }
public static bool Update(OneSkyService service, int projectId, string name, string description) { //https://github.com/onesky/api-documentation-platform/blob/master/resources/project.md string url = String.Format("https://platform.api.onesky.io/1/projects/{0}", projectId); string parameters = service.GetAuthenticationParameters() + "&name=" + name + "&description=" + description; url += "?" + parameters; try { using (var client = new WebClient()) { client.UploadString(url, "PUT", parameters); } return(true); } catch (WebException) { return(false); } }