Skip to content

khaledelmahdi/Onfido

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Onfido.Core

A .NET Core port from the original Onfido.NET

Installation

You can obtain Onfido.Core from nuget by using the Package Browser, or the Package Manager Console:

PM> Install-Package Onfido.Core

Usage/Setup

To setup your API token you'll need to add a call to Onfido.Settings.SetApiToken() somewhere in your application.

Onfido.Settings.SetApiToken("whatever_your_token_is");

Optionally, you may want to set the version of the API that you're calling; this defaults to the latest version of the API.

Onfido.Settings.SetApiVersion("v2");

When calling each of the services you can either create an instance of Onfido.Api - which will allow you to access all the Onfido endpoints from a single object - or you can create separately as required. For each of the examples below, where we have something like

var Applicant = new Onfido.Resources.Applicants();
return Applicant.Create(applicant)

the following is equally valid

var api = new Onfido.Api();
return api.Applicants.Create(applicant);    

Applicants

The Applicants endpoint supports three operations - Create(), Find(), and All():

Create

var applicants = new Onfido.Resources.Applicants();
var applicant = new Applicant {
	FirstName = "John",
	LastName = "Smith"
	// ...
};

var newApplicant = applicants.Create(applicant);

Retrieve

var applicants = new Onfido.Resources.Applicants();
var existingApplicant = applicants.Find(applicantId);

All

var applicants = new Onfido.Resources.Applicants();
var allApplicants = applicants.All();

The All() operation also permits pagination

var applicants = new Onfido.Resources.Applicants();
var top10Applicants = applicants.All(1, 10):
var next10Applicants = applicants.All(2, 10):

Documents

The Documents endpoint supports a single operation - Create():

Create

var documents = new Onfido.Resources.Documents();
var passport = new FileStream(@"./passport.png", FileMode.Open);
var document = api.Documents.Create(applicantId, passport, "passport.png", Entities.DocumentType.Passport);

Since you can optionally supply a side, Create() also allows you to specify which side of a document you're uploading

var documents = new Onfido.Resources.Documents();
var passport = new FileStream(@"./passport.png", FileMode.Open);
var document = api.Documents.Create(applicantId, passport, "passport.png", Entities.DocumentType.Passport, Entities.DocumentSide.Front);

The Entities.DocumentType and Entities.DocumentSide enums support the following:

public enum DocumentType {
    Passport,
    NationalIdentityCard,
    WorkPermit,
    DrivingLicense,
    NationalInsurance,
    BirthCertificate,
    BankStatement,
    Unknown
}

public enum DocumentSide
{
    Front,
    Back
}

Checks

The Checks endpoint supports three operations - Create(), Find() and All():

Create

var checks = new Onfido.Resources.Checks();
var check = new Check
        {
            Type = CheckType.Standard,
            Reports = new List<Report>
            {
                new Report { Name = "identity" },
                new Report { Name = "document" }
            }
        };
var new_check = checks.Create(applicant_id, check);

Find

var checks = new Onfido.Resources.Checks();
var existingCheck = checks.Find(applicantId, checkId);

All

var checks = new Onfido.Resources.Checks();
var applicantChecks = checks.All(applicantId);

The All() operation also permits pagination

var checks = new Onfido.Resources.Checks();
var top10Checks = checks.All(1, 10):
var next10Checks = checks.All(2, 10):

Reports

The Reports endpoint supports two operations - Find() and All():

Find

var reports = new Onfido.Resources.Reports();
var existingReport = reports.Find(checkId, reportId);

All

var reports = new Onfido.Resources.Reports();
var allReports = reports.All(checkId);

About

A .NET Core port from the original Onfido.NET

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages