CLASS

# RoomleUserManager

Contents

  • Methods
    • register(identification:password:acceptedTermsAndConditions:newsletter:completion:)
    • login(identification:password:completion:)
    • updateUserProfile(_:completion:)
    • deleteUser(completion:)
    • logout()
    • forgotPassword(email:completion:)
    • getTenants(completion:)
    • switchTo(tenant:)
public class RoomleUserManager : NSObject

Can access user data. Register, login, logout and switching tenants

# Methods

# register(identification:password:acceptedTermsAndConditions:newsletter:completion:)

public func register(identification: String, password: String, acceptedTermsAndConditions: Bool, newsletter: Bool, completion: ((_ user: RoomleUser?, _ error: Error?) -> Void)?)

Will register a new user with given email and password. The user has to manually accept terms and conditions, otherwise this function will fail. This call will also automatically login newly created user.

  • parameter identification: email of the user, which should get registered.
  • parameter password: password of the user, which should get registered.
  • parameter acceptedTermsAndConditions: indicating if the user has accept Roomles' terms and conditions. This has to be true, otherwise it will fail.
  • parameter newsletter: indicating if the user wants to receive a newsletter from Roomle.
  • parameter completion: block which will be executed with either a user object or an error.

# Parameters

Name Description
identification email of the user, which should get registered.
password password of the user, which should get registered.
acceptedTermsAndConditions indicating if the user has accept Roomles’ terms and conditions. This has to be true, otherwise it will fail.
newsletter indicating if the user wants to receive a newsletter from Roomle.
completion block which will be executed with either a user object or an error.

# login(identification:password:completion:)

public func login(identification: String, password: String, completion: ((_ user: RoomleUser?, _ error: Error?) -> Void)?)

Will login given user.

  • parameter identification: email of the user, which should get logged in.
  • parameter password: password of the user, which should get logged in.
  • parameter completion: block which will be executed with either a user object or an error.

# Parameters

Name Description
identification email of the user, which should get logged in.
password password of the user, which should get logged in.
completion block which will be executed with either a user object or an error.

# updateUserProfile(_:completion:)

public func updateUserProfile(_ user: RoomleUser, completion: ((_ user: RoomleUser?, _ error: Error?) -> Void)?)

Will update profile of given user. You have to change the data of user.

  • parameter user: given profile with values that will be changed
  • parameter completion: block which will be executed with new user profile or an error

# Parameters

Name Description
user given profile with values that will be changed
completion block which will be executed with new user profile or an error

# deleteUser(completion:)

public func deleteUser(completion: ((_ success: Bool, _ error: Error?) -> Void)?)

Will delete logged in user.

  • parameter completion: block which will be executed with a success boolean or an error

# Parameters

Name Description
completion block which will be executed with a success boolean or an error

# logout()

public func logout()

Will logout any logged in user, which means all user related data will be cleared.

# forgotPassword(email:completion:)

public func forgotPassword(email: String, completion: ((_ success: Bool, _ error: Error?) -> Void)?)

Will reset password and send a link to given email address.

  • parameter email: email of the user, which password should get reset.
  • parameter completion: block which will be executed with a success boolean and an optional error.

# Parameters

Name Description
email email of the user, which password should get reset.
completion block which will be executed with a success boolean and an optional error.

# getTenants(completion:)

public func getTenants(completion: ((_ tenants: [RoomleTenant]?, _ error: Error?) -> Void)?)

Will return all tenants, where logged in user is assigned to.

  • parameter completion: block which will be executed with either a list of tenants or an error.

# Parameters

Name Description
completion block which will be executed with either a list of tenants or an error.

# switchTo(tenant:)

public func switchTo(tenant: RoomleTenant) throws

Will switch to given tenant, except given tenant is not allowed to be switched to.

  • parameter tenant: tenant which should be switched to
  • throws: An RoomleUserManagerError.tenantSwitchNotAllowed if logged in user is not allowed to switch to given tenant.

# Parameters

Name Description
tenant tenant which should be switched to