SudoDIRelayClient
public protocol SudoDIRelayClient : AnyObject
Client used to interface with the Sudo Relay Platform service.
It is recommended to code to this interface, rather than the implementation class (DefaultSudoDIRelayClient
) as
the implementation class is only meant to be used for initializing an instance of the client.
-
Clear all locally cached apppsync data
Throws
ClearCacheErrorDeclaration
Swift
func reset() throws
-
listPostboxes(limit:
AsynchronousnextToken: ) Get a list of postboxes associated with the current user, ordered from oldest to newest.
Declaration
Swift
func listPostboxes(limit: Int?, nextToken: String?) async throws -> ListOutput<Postbox>
Parameters
limit
The maximum number of postboxes to return from this query; if not supplied the service will determine an appropriate limit.
nextToken
If more than
limit
postboxes are available, pass the value returned in a previous response to allow pagination.Return Value
- Success: The list of postboxes.
- Failure:
SudoDIRelayError
-
listMessages(limit:
AsynchronousnextToken: ) Get all messages from all postboxes associated with the current user, ordered from oldest to newest.
Declaration
Swift
func listMessages(limit: Int?, nextToken: String?) async throws -> ListOutput<Message>
Parameters
limit
The maximum number of messages to return from this query; if not supplied the service will determine an appropriate limit.
nextToken
If more than
limit
messages are available, pass the value returned in a previous response to allow pagination.Return Value
- Success: The list of messages.
- Failure:
SudoDIRelayError
-
Creates a Postbox associated with the given connection identifier.
Declaration
Swift
func createPostbox(withConnectionId connectionId: String, ownershipProofToken: String, isEnabled: Bool?) async throws -> Postbox
Parameters
connectionId
The connection id, unique to the current sudo, with which to associate the postbox.
ownershipProofToken
A token identifying the current sudo and its authorization to create a postbox.
isEnabled
Whether the postbox should be created in an enabled state. If not supplied, the default is true.
Return Value
- Success: The newly created postbox.
- Failure:
SudoDIRelayError
-
updatePostbox(withPostboxId:
AsynchronousisEnabled: ) Updates the Postbox associated with the given identifier.
Declaration
Swift
func updatePostbox(withPostboxId postboxId: String, isEnabled: Bool?) async throws -> Postbox
Parameters
postboxId
The postbox id of the postbox to be updated.
isEnabled
The new setting for the postbox isEnabled flag. If not supplied, no change will be made to the postbox setting.
Return Value
- Success: The updated postbox.
- Failure:
SudoDIRelayError
-
deletePostbox(withPostboxId:
Asynchronous) Deletes the postbox associated with the given postbox identifier, including all messages stored inside that postbox.
Declaration
Swift
func deletePostbox(withPostboxId postboxId: String) async throws -> String
Parameters
postboxId
The identifier of the postbox to be deleted.
Return Value
- Success: identifier of deleted postbox
- Failure:
SudoDIRelayError
-
deleteMessage(withMessageId:
Asynchronous) Deletes the message associated with the given message identifier
Declaration
Swift
func deleteMessage(withMessageId messageId: String) async throws -> String
Parameters
messageId
The identifier of the message to be deleted.
Return Value
- Success: identifier of deleted message
- Failure:
SudoDIRelayError
-
bulkDeleteMessage(withMessageIds:
Asynchronous) Deletes the messages associated with the given message identifiers
Declaration
Swift
func bulkDeleteMessage(withMessageIds messageIds: [String]) async throws -> [String]
Parameters
messageIds
The identifiers of the messages to be deleted.
Return Value
- Success: identifiers of deleted messages
- Failure:
SudoDIRelayError
-
Subscribe to message creation events for the current user. Subscription events will be delivered as long as the returned token remains in scope and the connection status remains .connected.
Declaration
Swift
func subscribeToMessageCreated( statusChangeHandler: SudoSubscriptionStatusChangeHandler?, resultHandler: @escaping ClientCompletion<Message> ) async throws -> SubscriptionToken?
Parameters
statusChangeHandler
Optional handler for connection status change.
resultHandler
On success, the created message; on failure an error.
Return Value
SubscriptionToken
object to allow management of the subscription. -
Unsubscribe from all subscriptions
Declaration
Swift
func unsubscribeAll()