Space Service

Last Updated on : 2024-05-28 03:36:45download

Add space

Parameters

Parameter Type Required Description
name String Yes The name of the space.
parentSpaceId String No The ID of the parent space.
success (() -> Void)? No The success callback.
failure ((Error) -> Void)? No The failure callback.

Example

SpaceService.shared.create(name: text, parentSpaceId: self.spaceId) {
    print("Success")
    self.requestSpaceList()
} failure: { error in
    print("Failure: \(error.localizedDescription)")
}

Rename space

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.
name String Yes The new name.
success (() -> Void)? No The success callback.
failure ((Error) -> Void)? No The failure callback.

Example

SpaceService.shared.update(spaceId: space.spaceId, name: text) {
    print("Success")
    self.requestSpaceList()
} failure: { error in
    print("Failure: \(error.localizedDescription)")
}

Delete space

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.
success (() -> Void)? No The success callback.
failure ((Error) -> Void)? No The failure callback.

Example

SpaceService.shared.remove(spaceId: spaceId) {
    print("Success")
} failure: { error in
    print("Failure: \(error.localizedDescription)")
}

Get the property of a single space

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.
success ((ISpace) -> Void)? No The success callback, returning the queried space instance.
failure ((Error) -> Void)? No The failure callback.

Example

SpaceService.shared.space(spaceId: "123", success: { space in
    print("The name of the space: \(space.name)")
}, failure: { error in
    print("Failure: \(error.localizedDescription)")
})

Get the list of sub-space properties

Parameters

Parameter Type Required Description
spaceId String? No The ID of the target space. If the value is nil, all sub-spaces will be queried.
success (([ISpace]) -> Void)? No The success callback, returning an array of the queried sub-space instance.
failure ((Error) -> Void)? No The failure callback.

Example

SpaceService.shared.subSpaces(spaceId: "123", success: { spaces in
    print("The number of sub-spaces: \(spaces.count)")
}, failure: { error in
    print("Failure: \(error.localizedDescription)")
})

Query device list by space ID

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.
lastRowKey String? No The RowKey of the last row returned from the previous query, used for pagination.
success ((ISpaceDeviceListResult) -> Void)? No The success callback, returning the list of devices.
failure ((Error) -> Void)? No The failure callback.

Example

SpaceService.shared.devices(spaceId: "123", lastRowKey: nil, success: { result in
    print("The number of devices: \(result.devices.count)")
    if let nextRowKey = result.nextRowKey {
        print("The lastRowKey of the next page: \(nextRowKey)")
    }
}, failure: { error in
    print("Failure: \(error.localizedDescription)")
})

Get the management instance of a single space

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.
success ((IAssociatedModel) -> Void)? No The success callback, returning the queried associated model.
failure ((Error) -> Void)? No The failure callback.

Example

SpaceService.shared.associatedModel(spaceId: "123", success: { model in
    print("The associated model: \(model)")
}, failure: { error in
    print("Failure: \(error.localizedDescription)")
})