GBG Developers

Guides   |   Using the Verify People Service

Using the Verify People Service

The GBGPeopleVerifyService class can be used to verify text based name and address information. Create an instance of it:

// create a people verify service
private lazy var peopleVerifyService = GBGPeopleVerifyService()

The address to be verified is built using GBGPersonAddress:

// create a verify request
// a. create an address
let address =  GBGPersonAddress()
    .withPremise("222")
    .withThoroughfare("BAKER STREET")
    .withLocality("LONDON")
    .withPostalCode("SW2 222Q")
    .withCountry("GB")

Populate the date of residence using the GBGResident object:

var resident = GBGResident(JSON: [:])
resident?.from = "2010-01-30"

Now build the entire person request, including the address and date of residence:

// b. build the request
let personRequestHeader = GBGPersonRequestHeader()
    .withJourneyId("432febfd-aaed-40b9-9a3b-ffa1aabb4b99")
    .withJourneyVersion(1)

let person = GBGVerifyPerson()
    .withFirstname("BOB")
    .withLastnames(["KIRK"])
    .withBirthdate("1984-11-29")
    .withGender("MALE")


person.withAddresses([GBGPersonAddresses().withAddress(address).withType("CURRENT").withResident(resident)])

Finally, use the SDK to send the request and then the application code can handle the result. If this is the first verification and no person identifier exists, use the verify method. If you have already performed a verification then use the verifyId method and include the person identifier. The example here uses verifyId. You can use the same syntax but remove the personId from the method if you’re using the verify method.

The example code here takes the person identifier from the GBGVerifyResponseManager object which is a singleton instance that provides storage and access to fields so that they can be used with multiple services in the SDK.

The example code prints some debug output indicating success or failure.

// submit the request to the service and handle the result
self.peopleVerifyService.verifyId(GBGVerifyResponseManager.shared.personId ?? "", person: person, personRequestHeader: personRequestHeader, success: { result in
    let resultLine = result?.body.verification?.result?.state?.lowercased(){
    print("success: verifyPerson \(resultLine)")
}, failure: { (error) in
    self.showPopup(error: error)
})

When this example is run, a success message should be displayed when debugging the application.