let streams = zulip.streams()
Gets all of the streams that a user can access.
includePublic
(optional, defaulttrue
): Whether all public streams should be included.includeSubscribed
(optional, defaulttrue
): Whether all subscribed-to streams should be includedincludeDefault
(optional, defaultfalse
): Whether all default streams should be included.includeActive
(optional, defaultfalse
): Whether all active streams should be included. This option will cause aZulipError
if the user not an admin.callback
: A callback, which will be passed the streams, or an error.
Gets the ID of a stream.
name
: The name of the stream.callback
: A callback, which will be passed the ID, or an error.
Gets the user's subscribed streams.
callback
: A callback, which will be passed the streams, or an error.
Subscribes a user to streams, or creates them if they do not exist yet.
-
streams
: The streams to subscribe a user to.- example:
[["name": "test here"]]
- example:
["name": "test here"], ["name": "announce"]]
- example:
-
inviteOnly
(optional, defaultfalse
): Whether the streams are invite only or not. -
announce
(optional, defaultfalse
): Whether an announcement should be made that a new stream is created, if it is. -
principals
: The users to subscribe to the streams. Ifprincipals
is empty, the current user will be subscribed. -
authorizationErrorsFatal
(optional, defaultfalse
): Whether authorization errors should be reported in the response. -
callback
: A callback, which will be passed- a dictionary where the key is user's email, and the value is a list of streams they were subscribed to;
- a dictionary where the key is a user's email, and the value is a list of streams they were already subscribed to; and
- a list of names of streams that could not be subscribed to because the user was unauthorized;
or an error if there is one.
Unsubscribes a user from streams.
-
streamNames
: The names of the streams to unsubscribe a user from.- example:
["test here"]
- example:
["test here", "announce"]
- example:
-
principals
: The users to unsubscribe from the streams. Ifprincipals
is empty, the current user will be subscribed. Unsubscribing other users will cause aZulipError
if the current user is not an admin. -
callback
: A callback, which will be passed- a list of names of the streams that were unsubscribed from and
- a list of names of the streams that could not be unsubscribed from because the user was already subscribed,
or an error if there is one.
streams.getAll(
includePublic: true,
includeSubscribed: true,
includeDefault: false,
includeActive: false,
callback: { (streams, error) in
// Prints a list of streams with various properties.
print(streams)
}
)
streams.getID(
name: "test here",
callback: { (id, error) in
// Prints a number, like 13.
print(streams)
}
)
streams.getSubscribed(
callback: { (streams, error) in
// Prints a list of streams with various properties.
print(streams)
}
)
streams.subscribe(
streams: [["name": "test here"]],
principals: ["[email protected]", "[email protected]"]
callback: { (subscribed, alreadySubscribed, unauthorized, error) in
// Prints something like
//
// [
// "[email protected]": "test here"
// ]
print(subscribed)
// Prints something like
//
// [
// "[email protected]": "test here"
// ]
print(alreadySubscribed)
// Prints something like
//
// []
//
// if no streams are unauthorized.
print(unauthorized)
}
)
streams.unsubscribe(
streamsNames: ["test here", "announce"],
principals: ["[email protected]", "[email protected]"]
callback: { (unsubscribed, notSubscribed, error) in
// Prints something like
//
// ["test here"]
print(unsubscribed)
// Prints something like
//
// ["announce"]
print(notSubscribed)
}
)