register

In order to register a new user the Register endpoint needs to be called, creating a user on the Karhoo platform.

register(userRegistration: UserRegistration) : Call<UserInfo>

Parameters

user’s details
userRegistration: UserRegistration

Returns

callback with user’s object
Call: <[UserInfo](ref:user-service-objects-schemas)>

Errors

Examples

iOS

let userService = Karhoo.getUserService()
let userRegistration = UserRegistration(firstName: "John",
                                        lastName: "Doe",
                                        email: "[email protected]",
                                        phoneNumber: "12345678910",
                                        locale = "en-GB",
                                        password: "password")
userService.register(userRegistration: userRegistration)
           .execute { result in
            
       switch result {
        case .success(let user):
            print("User: \(user)")
        case .failure(let error):
            print("error: \(error.code) \(error.message)")
    }
}

Android

val userRegisteration = UserRegistration(firstName = "John",
                lastName = "Doe",
                email = "[email protected]",
                phoneNumber = "12345678910",
                locale = "en-GB",
                password = "password")

userService.register(userRegistration).execute { result ->
    when (result) {
        is Resource.Success -> print(result.data) // Handle data
        is Resource.Failure -> print(result.error, userInfo) //Handle errors
    }
}