예제 #1
0
        private void GetApplication(object obj)
        {
            var api  = new Onfido.Api();
            var apps = api.Applicants.All();
            var app  = apps.Where(a => a.Email == Email).FirstOrDefault();

            if (app != null)
            {
                AppId     = app.Id;
                firstName = app.FirstName;
                lastName  = app.LastName;
            }
        }
예제 #2
0
        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);
            }
        }