/// <summary> /// /// </summary> /// <param name="attributeId"></param> /// <returns></returns> private F1toPCO.Model.F1.people F1GetPeopleByAttribute(int attributeId) { F1toPCO.Model.F1.people peopleCollection = null; RestRequest request = new RestRequest { Path = "People/Search" }; request.AddParameter("attribute", attributeId.ToString()); request.AddParameter("recordsperpage", "100"); request.AddParameter("include", "attributes,addresses,communications"); using (RestResponse response = F1Client.Request(request)) { if (response.StatusCode == HttpStatusCode.OK) { using (StreamReader streamReader = new StreamReader(response.ContentStream)) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(F1toPCO.Model.F1.people)); // Deserialize the response into a Person object. peopleCollection = xmlSerializer.Deserialize(streamReader) as F1toPCO.Model.F1.people; } } else { throw new Exception("An error occured: Status code: " + response.StatusCode, response.InnerException); } } return(peopleCollection); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <returns></returns> private int F1GetAttributeID(string name) { int attributeId = 0; RestRequest request = new RestRequest { Path = "People/AttributeGroups" }; using (RestResponse response = F1Client.Request(request)) { if (response.StatusCode == HttpStatusCode.OK) { using (StreamReader streamReader = new StreamReader(response.ContentStream)) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(Model.F1.attributeGroups)); // Deserialize the response into a Person object. Model.F1.attributeGroups attributes = xmlSerializer.Deserialize(streamReader) as Model.F1.attributeGroups; attributeId = attributes.FindAttributeIDByName(name); } } else { throw new Exception("An error occured: Status code: " + response.StatusCode, response.InnerException); } } return(attributeId); }
/// <summary> /// /// </summary> /// <param name="peopleAttribute"></param> /// <returns></returns> private bool F1DeletePeopleAttribute(Model.F1.peopleAttribute peopleAttribute) { var request = new RestRequest { Path = string.Format("People/{0}/Attributes/{1}", peopleAttribute.person.id, peopleAttribute.id), VersionPath = "v1", Method = WebMethod.Delete }; RestResponse response = F1Client.Request(request); if (response.StatusCode == HttpStatusCode.NoContent) { return(true); } return(false); }
/// <summary> /// /// </summary> /// <param name="peopleAttribute"></param> /// <returns></returns> private bool F1UpdatePeopleAttribute(Model.F1.peopleAttribute peopleAttribute) { var request = new RestRequest { Path = string.Format("People/{0}/Attributes/{1}", peopleAttribute.person.id, peopleAttribute.id), VersionPath = "v1", Method = WebMethod.Put, Entity = this.SerializeEntity(peopleAttribute) }; RestResponse response = F1Client.Request(request); if (response.StatusCode == HttpStatusCode.OK) { return(true); } return(false); }