PrivMX DOCS
API Reference/PrivMX Endpoint Swift/Inboxes

InboxApi

Swift wrapper for privmx.NativeInboxApiWrapper, providing methods to manage Inboxes and entries within PrivMX platform.

Static Methods

create(connection:threadApi:storeApi:)

Creates an instance of ‘InboxApi’.

Params

connection

inout Connection

instance of ‘Connection’

threadApi

inout ThreadApi

instance of ‘ThreadApi’

storeApi

inout StoreApi

instance of ‘StoreApi’

public static func create(
connection:inout Connection,
threadApi: inout ThreadApi,
storeApi: inout StoreApi
) throws -> InboxApi

Returns

InboxApi · InboxApi object

Methods

createInbox(contextId:users:managers:publicMeta:privateMeta:filesConfig:policies:)

Creates a new Inbox.

Params

contextId

std.string

ID of the Context of the new Inbox

users

privmx.UserWithPubKeyVector

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

managers

privmx.UserWithPubKeyVector

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

publicMeta

privmx.endpoint.core.Buffer

public (unencrypted) metadata

privateMeta

privmx.endpoint.core.Buffer

private (encrypted) metadata

filesConfig

privmx.endpoint.inbox.FilesConfig?

struct to override default file configuration

policies

privmx.endpoint.core.ContainerPolicyWithoutItem?

Inbox policies

public func createInbox(
contextId: std.string,
users: privmx.UserWithPubKeyVector,
managers: privmx.UserWithPubKeyVector,
publicMeta: privmx.endpoint.core.Buffer,
privateMeta: privmx.endpoint.core.Buffer,
filesConfig: privmx.endpoint.inbox.FilesConfig?,
policies: privmx.endpoint.core.ContainerPolicyWithoutItem? = nil
) throws -> std.string

Returns

std.string · ID of the created Inbox

updateInbox(inboxId:users:managers:publicMeta:privateMeta:filesConfig:version:force:forceGenerateNewKey:policies:)

Updates an existing Inbox.

Params

inboxId

std.string

ID of the Inbox to update

users

privmx.UserWithPubKeyVector

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

managers

privmx.UserWithPubKeyVector

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

publicMeta

privmx.endpoint.core.Buffer

public (unencrypted) metadata

privateMeta

privmx.endpoint.core.Buffer

private (encrypted) metadata

filesConfig

privmx.endpoint.inbox.FilesConfig?

struct to override default files configuration

version

Int64

current version of the updated Inbox

force

Bool

force update (without checking version)

forceGenerateNewKey

Bool

force to regenerate a key for the Inbox

policies

privmx.endpoint.core.ContainerPolicyWithoutItem?

Inbox policies

public func updateInbox(
inboxId: std.string,
users: privmx.UserWithPubKeyVector,
managers: privmx.UserWithPubKeyVector,
publicMeta: privmx.endpoint.core.Buffer,
privateMeta: privmx.endpoint.core.Buffer,
filesConfig: privmx.endpoint.inbox.FilesConfig?,
version: Int64,
force: Bool,
forceGenerateNewKey: Bool,
policies: privmx.endpoint.core.ContainerPolicyWithoutItem? = nil
) throws -> Void

getInbox(inboxId:)

Gets a single Inbox by given Inbox ID.

Params

inboxId

std.string

ID of the Inbox to get

public func getInbox(
inboxId: std.string
) throws -> privmx.endpoint.inbox.Inbox

Returns

privmx.endpoint.inbox.Inbox · struct containing information about the Inbox

listInboxes(contextId:pagingQuery:)

Gets s list of Inboxes in given Context.

Params

contextId

std.string

ID of the Context to get Inboxes from

pagingQuery

privmx.endpoint.core.PagingQuery

struct with list query parameters

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

Returns

privmx.InboxList · struct containing list of Inboxes

getInboxPublicView(inboxId:)

Gets public data of given Inbox. You do not have to be logged in to call this function.

Params

inboxId

std.string

ID of the Inbox to get

public func getInboxPublicView(
inboxId: std.string
) throws -> privmx.endpoint.inbox.InboxPublicView

Returns

privmx.endpoint.inbox.InboxPublicView · struct containing public accessible information about the Inbox

deleteInbox(inboxId:)

Deletes an Inbox by given Inbox ID.

Params

inboxId

std.string

ID of the Inbox to delete

public func deleteInbox(
inboxId: std.string
) throws -> Void

prepareEntry(inboxId:data:inboxFileHandles:userPrivKey:)

Prepares a request to send data to an Inbox. You do not have to be logged in to call this function.

Params

inboxId

std.string

ID of the Inbox to which the request applies

data

privmx.endpoint.core.Buffer

entry data to send

inboxFileHandles

privmx.InboxFileHandleVector

optional list of file handles that will be sent with the request

userPrivKey

std.string?

sender can optionally provide a private key, which will be used: 1) to sign the sent data, 2) to derivation of the public key, which will then be transferred along with the sent data and can be used in the future for further secure communication with the sender

public func prepareEntry(
inboxId: std.string,
data: privmx.endpoint.core.Buffer,
inboxFileHandles: privmx.InboxFileHandleVector = [],
userPrivKey: std.string? = nil
) throws -> privmx.EntryHandle

Returns

privmx.EntryHandle · handle

sendEntry(entryHandle:)

Sends data to an Inbox. You do not have to be logged in to call this function.

Params

entryHandle

privmx.EntryHandle

ID of the Inbox to which the request applies

public func sendEntry(
entryHandle: privmx.EntryHandle
) throws -> Void

sendEntry(inboxHandle:)

Params

inboxHandle

privmx.InboxHandle

public func sendEntry(
inboxHandle: privmx.InboxHandle
) throws -> Void

readEntry(inboxEntryId:)

Gets an entry from an Inbox.

Params

inboxEntryId

std.string

ID of an entry to read from the Inbox

public func readEntry(
inboxEntryId: std.string
) throws -> privmx.endpoint.inbox.InboxEntry

Returns

privmx.endpoint.inbox.InboxEntry · struct containing data of the selected entry stored in the Inbox

listEntries(inboxId:pagingQuery:)

Gets list of entries in given Inbox.

Params

inboxId

std.string

ID of the Inbox

pagingQuery

privmx.endpoint.core.PagingQuery

struct with list query parameters

public func listEntries(
inboxId: std.string,
pagingQuery: privmx.endpoint.core.PagingQuery
) throws -> privmx.InboxEntryList

Returns

privmx.InboxEntryList · struct containing list of entries

deleteEntry(inboxEntryId:)

Deletes a specified entry from an Inbox.

Params

inboxEntryId

std.string

The ID of the entry to delete.

public func deleteEntry(
inboxEntryId: std.string
) throws -> Void

createFileHandle(publicMeta:privateMeta:fileSize:)

Creates a file handle to send a file to an Inbox. You do not have to be logged in to call this function.

Params

publicMeta

privmx.endpoint.core.Buffer

file’s public metadata

privateMeta

privmx.endpoint.core.Buffer

file’s private metadata

fileSize

Int64

size of the file to send

public func createFileHandle(
publicMeta:privmx.endpoint.core.Buffer,
privateMeta:privmx.endpoint.core.Buffer,
fileSize: Int64
) throws -> privmx.InboxFileHandle

Returns

privmx.InboxFileHandle · file handle

writeToFile(entryHandle:inboxFileHandle:dataChunk:)

Sends file’s data chunk to an Inbox. (note: To send the entire file - divide it into pieces of the desired size and call the function for each fragment.) You do not have to be logged in to call this function.

Params

entryHandle

privmx.EntryHandle

Handle to the prepared Inbox entry

inboxFileHandle

privmx.InboxFileHandle

handle to the file where the uploaded chunk belongs

dataChunk

privmx.endpoint.core.Buffer

public func writeToFile(
entryHandle: privmx.EntryHandle,
inboxFileHandle: privmx.InboxFileHandle,
dataChunk: privmx.endpoint.core.Buffer
) throws -> Void

writeToFile(inboxHandle:inboxFileHandle:dataChunk:)

Params

inboxHandle

privmx.EntryHandle

inboxFileHandle

privmx.InboxFileHandle

dataChunk

privmx.endpoint.core.Buffer

public func writeToFile(
inboxHandle: privmx.EntryHandle,
inboxFileHandle: privmx.InboxFileHandle,
dataChunk: privmx.endpoint.core.Buffer
) throws -> Void

openFile(fileId:)

Opens a file to read.

Params

fileId

std.string

ID of the file to read

public func openFile(
fileId: std.string
) throws -> privmx.InboxFileHandle

Returns

privmx.InboxFileHandle · handle to read file data

readFromFile(fileHandle:length:)

Reads file data. Single read call moves the files’s cursor position by declared length or set it at the end of the file.

Params

fileHandle

privmx.InboxFileHandle

handle to the file

length

Int64

size of data to read

public func readFromFile(
fileHandle: privmx.InboxFileHandle,
length: Int64
) throws -> privmx.endpoint.core.Buffer

Returns

privmx.endpoint.core.Buffer · buffer with file data chunk

seekInFile(fileHandle:position:)

Moves file’s read cursor.

Params

fileHandle

privmx.InboxFileHandle

handle to the file

position

Int64

sets new cursor position

public func seekInFile(
fileHandle: privmx.InboxFileHandle,
position: Int64
) throws -> Void

closeFile(fileHandle:)

Closes a file by given handle.

Params

fileHandle

privmx.InboxFileHandle

handle to the file

public func closeFile(
fileHandle: privmx.InboxFileHandle
) throws -> std.string

Returns

std.string · ID of closed file

subscribeFor(subscriptionQueries:)

Subscribe for the Inbox 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 Inbox events.

Params

eventType

privmx.endpoint.inbox.EventType

type of event which you listen for

selectorType

privmx.endpoint.inbox.EventSelectorType

scope on which you listen for events

selectorId

std.string

ID of the selector

public func buildSubscriptionQuery(
eventType: privmx.endpoint.inbox.EventType,
selectorType: privmx.endpoint.inbox.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.