public static Applicant Applicant(bool created) { var applicant = new Applicant { Title = "Mr", FirstName = "John", LastName = "Smith", Gender = "male", DateOfBirth = new System.DateTime(2013, 2, 17), Telephone = "02088909293", Country = "GBR" }; if (created) { applicant.Id = "1030303-123123-123123"; applicant.CreatedAt = new System.DateTime(2014, 5, 23, 13, 50, 33); applicant.HRef = "/v1/applicants/1030303-123123-123123"; } applicant.Addresses = new List<Address> { AddressGenerator.Address1(), AddressGenerator.Address2() }; applicant.IdNumbers = new List<IdNumber> { IdNumberGenerator.IdNumber1(), IdNumberGenerator.IdNumber2() }; return applicant; }
public Applicant Create(Applicant applicant) { const string path = "applicants"; var payload = SerializeEntity(applicant); return _requestor.Post<Applicant>(path, payload); }
private bool CreateApp() { var api = new Onfido.Api(); var applicant = new Onfido.Entities.Applicant { FirstName = FirstName, LastName = LastName, Email = Email, DateOfBirth = DayOfBirth.GetValueOrDefault(DateTime.Now.AddDays(-1)), Mobile = CellPhone, Country = Country.alpha3Code }; try { Applicant app = new Onfido.Entities.Applicant(); if (!string.IsNullOrWhiteSpace(AppId)) { var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", string.Format("Token token={0}", Settings.GetApiToken())); var stUrl = $"https://{Settings.Hostname}/{Settings.GetApiVersion()}/applicants/{AppId}"; var uri = new Uri(stUrl); var deleteResponse = client.DeleteAsync(uri); if (deleteResponse.Id == 1) { MessageDetails = deleteResponse.Status.ToString(); return(false); } } else { app = api.Applicants.Create(applicant); AppId = app.Id; } return(true); } catch (Exception ex) { MessageDetails = ex.Message; return(false); } }