ForstaPayloadV1

public struct ForstaPayloadV1 : CustomStringConvertible, Codable

A convenience wrapper for consuming/producing v1 of the Forsta message exchange JSON payload (see https://bit.ly/forsta-payload for details)

  • Initialize with an (optional) JSON payload string

    Declaration

    Swift

    public init(_ jsonString: String? = nil)
  • The Forsta message exchange payload version

    Declaration

    Swift

    public var version: Int?
  • The message’s globally-unique ID (required)

    Declaration

    Swift

    public var messageId: UUID?
  • A reference to another message, by ID (useful for message replies, or survey responses)

    Declaration

    Swift

    public var messageRef: UUID?
  • Optionally override the origin of the message if different from source

    Declaration

    Swift

    public var sender: ForstaPayloadV1.Address?
  • The type of payload this is (required)

    Declaration

    Swift

    public var messageType: ForstaPayloadV1.MessageType?
  • Any relevant details for this message

    Declaration

    Swift

    public var data: ForstaPayloadV1.DataElement?
  • The message’s distribution (required)

    Declaration

    Swift

    public var distribution: ForstaPayloadV1.Distribution?
  • The globally-unique thread ID (required)

    Declaration

    Swift

    public var threadId: UUID?
  • The thread title (optional)

    Declaration

    Swift

    public var threadTitle: String?
  • The thread type

    Declaration

    Swift

    public var threadType: ForstaPayloadV1.ThreadType?
  • The user agent sending this message (optional)

    Declaration

    Swift

    public var userAgent: String?
  • The identity-key-based signature for the essential parts of this message (useful for trusting forwarded/shared/replayed messages).

    The signed text is the concatenation of:

    • timestamp message ID from the envelope
    • distribution expression (i.e., a universal expression string yielded by Atlas)
    • messageId (lowercase UUID string)
    • threadId (lowercase UUID string)
    • messageRef (lowercase UUID string or empty)
    • the values of any body item(s), in order
    • the hashes (sha512 in base64) of any attachements, in order

    Declaration

    Swift

    public var signature: Data?
  • Directly manipulate the (presumed only) plain-text entry in the .data .body array

    Declaration

    Swift

    public var bodyPlain: String? { get set }
  • Directly manipulate the (presumed only) HTML entry in the .data .body array

    Declaration

    Swift

    public var bodyHtml: String? { get set }
  • Alias for .data .control – the type of this control message (meaningful only for .control messages)

    Declaration

    Swift

    public var controlType: ControlType? { get set }
  • Alias for .distribution .expression – the tag-math distribution expression for this message (required)

    Declaration

    Swift

    public var threadExpression: String? { get set }
  • Alias for .data .readMark (only relevant for .control messages of type .readMark)

    Declaration

    Swift

    public var readMark: Date? { get set }
  • Alias for .data .threadUpdate .threadTitle (only relevant for .control messages of type .threadUpdate)

    Declaration

    Swift

    public var threadUpdateTitle: String? { get set }
  • Alias for .data .threadUpdate .expression (only relevant for .control messages of type .threadUpdate)

    Declaration

    Swift

    public var threadUpdateExpression: String? { get set }
  • Alias for .data .version (only relevant for call-related .control messages)

    Declaration

    Swift

    public var callVersion: Int? { get set }
  • Alias for .data .callId (only relevant for call-related .control messages)

    Declaration

    Swift

    public var callId: UUID? { get set }
  • Alias for .data .peerId (only relevant for call-related .control messages)

    Declaration

    Swift

    public var peerId: UUID? { get set }
  • Alias for .data .originator (only relevant for .control of type .callJoin)

    Declaration

    Swift

    public var callOriginator: UUID? { get set }
  • Alias for .data .members (only relevant for .control of type .callJoin)

    Declaration

    Swift

    public var callMembers: [UUID]? { get set }
  • Alias for .data .offer .sdp (only relevant for .control messages of type .callOffer)

    Declaration

    Swift

    public var sdpOffer: String? { get set }
  • Alias for .data .answer .sdp (only relevant for .control messages of type .callAcceptOffer)

    Declaration

    Swift

    public var sdpAnswer: String? { get set }
  • Alias for .data .icecandidates (only relevant for .control messages of type .callICECandidates)

    Declaration

    Swift

    public var iceCandidates: [IceCandidate]? { get set }
  • Alias for .data .sends (only relevant for call-related .control messages)

    Declaration

    Swift

    public var callSends: [StreamType]? { get set }
  • Alias for .data .receives (only relevant for call-related .control messages)

    Declaration

    Swift

    public var callReceives: [StreamType]? { get set }
  • Alias for .data .key (only relevant for .control messages of type .provisionRequest)

    Declaration

    Swift

    public var provisioningKey: Data? { get }
  • Alias for .data .uuid (only relevant for .control messages of type .provisionRequest)

    Declaration

    Swift

    public var provisioningUuidString: String? { get }
  • A pretty-printed version of this payload’s JSON encoding

    Declaration

    Swift

    public var description: String { get }
  • Throw an error if mandatory fields are missing, etc.

    Declaration

    Swift

    public func sanityCheck() throws