PrivMX DOCS
API Reference/PrivMX Endpoint Swift/Threads

ThreadApi

‘ThreadApi’ is a class representing Endpoint’s API for Threads and their messages.

Static Methods

create(connection:)

Creates an instance of ‘ThreadApi’.

Params

connection

inout Connection

instance of ‘Connection’

public static func create(
connection: inout Connection
) throws -> ThreadApi

Returns

ThreadApi · ThreadApi object

Methods

createThread(contextId:users:managers:publicMeta:privateMeta:policies:)

Creates a new Thread in given Context.

Params

contextId

std.string

ID of the Context to create the Thread in

users

privmx.UserWithPubKeyVector

vector of UserWithPubKey structs which indicates who will have access to the created Thread

managers

privmx.UserWithPubKeyVector

vector of UserWithPubKey structs which indicates who will have access (and management rights) to the created Thread

publicMeta

privmx.endpoint.core.Buffer

public (unencrypted) metadata

privateMeta

privmx.endpoint.core.Buffer

private (encrypted) metadata

policies

privmx.endpoint.core.ContainerPolicy?

Thread’s policies

public func createThread(
contextId: std.string,
users: privmx.UserWithPubKeyVector,
managers: privmx.UserWithPubKeyVector,
publicMeta: privmx.endpoint.core.Buffer,
privateMeta: privmx.endpoint.core.Buffer,
policies: privmx.endpoint.core.ContainerPolicy? = nil
)throws -> std.string

Returns

std.string · ID of the created Thread

getThread(threadId:)

Gets a Thread by given Thread ID.

Params

threadId

std.string

ID of Thread to get

public func getThread(
threadId: std.string
) throws -> privmx.endpoint.thread.Thread

Returns

privmx.endpoint.thread.Thread · Thread struct containing info about the Thread

updateThread(threadId:version:users:managers:publicMeta:privateMeta:force:forceGenerateNewKey:policies:)

Updates an existing Thread.

Params

threadId

std.string

ID of the Thread to update

version

Int64

vector of UserWithPubKey structs which indicates who will have access to the created Thread

users

privmx.UserWithPubKeyVector

vector of UserWithPubKey structs which indicates who will have access (and management rights) to

managers

privmx.UserWithPubKeyVector

public (unencrypted) metadata

publicMeta

privmx.endpoint.core.Buffer

private (encrypted) metadata

privateMeta

privmx.endpoint.core.Buffer

current version of the updated Thread

force

Bool

force update (without checking version)

forceGenerateNewKey

Bool

force to regenerate a key for the Thread

policies

privmx.endpoint.core.ContainerPolicy?

Thread’s policies

public func updateThread(
threadId : std.string,
version: Int64,
users: privmx.UserWithPubKeyVector,
managers: privmx.UserWithPubKeyVector,
publicMeta: privmx.endpoint.core.Buffer,
privateMeta: privmx.endpoint.core.Buffer,
force: Bool,
forceGenerateNewKey: Bool,
policies: privmx.endpoint.core.ContainerPolicy? = nil
) throws -> Void

deleteThread(threadId:)

Deletes a Thread by given Thread ID.

Params

threadId

std.string

ID of the Thread to delete

public func deleteThread(
threadId: std.string
) throws -> Void

listThreads(contextId:pagingQuery:)

Gets a list of Threads in given Context.

Params

contextId

std.string

ID of the Context to get the Threads from

pagingQuery

privmx.endpoint.core.PagingQuery

struct with list query parameters

public func listThreads(
contextId: std.string,
pagingQuery: privmx.endpoint.core.PagingQuery
) throws -> privmx.ThreadList

Returns

privmx.ThreadList · struct containing a list of Threads

listThreads(contextId:query:)

Params

contextId

std.string

query

privmx.endpoint.core.PagingQuery

public func listThreads(
contextId: std.string,
query: privmx.endpoint.core.PagingQuery
) throws -> privmx.ThreadList

Returns

privmx.ThreadList ·

sendMessage(threadId:publicMeta:privateMeta:data:)

Sends a message in a Thread.

Params

threadId

std.string

ID of the Thread to send message to

publicMeta

privmx.endpoint.core.Buffer

public message metadata

privateMeta

privmx.endpoint.core.Buffer

private message metadata

data

privmx.endpoint.core.Buffer

content of the message

public func sendMessage(
threadId: std.string,
publicMeta: privmx.endpoint.core.Buffer,
privateMeta: privmx.endpoint.core.Buffer,
data: privmx.endpoint.core.Buffer
) throws -> std.string

Returns

std.string · ID of the new message

deleteMessage(_:)

Deletes a message by given message ID.

Params

messageId

std.string

ID of the message to delete

public func deleteMessage(
_ messageId: std.string
) throws -> Void

getMessage(_:)

Gets a message by given message ID.

Params

messageId

std.string

of the message to get

public func getMessage(
_ messageId: std.string
) throws -> privmx.endpoint.thread.Message

Returns

privmx.endpoint.thread.Message · struct containing the message

listMessages(threadId:pagingQuery:)

Gets a list of messages from a Thread.

Params

threadId

std.string

ID of the Thread to list messages from

pagingQuery

privmx.endpoint.core.PagingQuery

struct with list query parameters

public func listMessages(
threadId: std.string,
pagingQuery: privmx.endpoint.core.PagingQuery
) throws -> privmx.MessageList

Returns

privmx.MessageList · struct containing a list of messages

listMessages(threadId:query:)

Params

threadId

std.string

query

privmx.endpoint.core.PagingQuery

public func listMessages(
threadId: std.string,
query: privmx.endpoint.core.PagingQuery
) throws -> privmx.MessageList

Returns

privmx.MessageList ·

updateMessage(messageId:publicMeta:privateMeta:data:)

Update message in a Thread.

Params

messageId

std.string

ID of the message to update

publicMeta

privmx.endpoint.core.Buffer

public message metadata

privateMeta

privmx.endpoint.core.Buffer

private message metadata

data

privmx.endpoint.core.Buffer

content of the message

public func updateMessage(
messageId: std.string,
publicMeta: privmx.endpoint.core.Buffer,
privateMeta: privmx.endpoint.core.Buffer,
data: privmx.endpoint.core.Buffer
) throws -> Void

subscribeFor(subscriptionQueries:)

Subscribe for the Thread events on the given subscription query.

Params

subscriptionQueries

privmx.SubscriptionQueryVector

list of queries

public func subscribeFor(
subscriptionQueries: privmx.SubscriptionQueryVector
) throws -> privmx.SubscriptionIdVector

Returns

privmx.SubscriptionIdVector · list of subscriptionIds in maching order to subscriptionQueries

unsubscribeFrom(subscriptionIds:)

Unsubscribe from events for the given subscriptionId.

Params

subscriptionIds

privmx.SubscriptionIdVector

list of subscriptionId

public func unsubscribeFrom(
subscriptionIds: privmx.SubscriptionIdVector
) throws -> Void

buildSubscriptionQuery(eventType:selectorType:selectorId:)

Generate subscription Query for the Thread events.

Params

eventType

privmx.endpoint.thread.EventType

type of event which you listen for

selectorType

privmx.endpoint.thread.EventSelectorType

scope on which you listen for events

selectorId

std.string

ID of the selector

public func buildSubscriptionQuery(
eventType: privmx.endpoint.thread.EventType,
selectorType: privmx.endpoint.thread.EventSelectorType,
selectorId: std.string
) throws -> privmx.SubscriptionQuery

Returns

privmx.SubscriptionQuery · a properly formatted event subscription request.

We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.