ChatResource

Person-to-person chat between patients and their care team under /v1/chat.

  • Stable unknown
  • Release candidate not available
  • Development since 0.2.0-dev.33+8af64df
public final class ChatResource

Person-to-person chat between patients and their care team under /v1/chat. Get it from Ovok.chat().

Methods

threads

public ChatResource.Threads threads()

Returns the signed-in person's threads.

Returns: the thread routes

messages

public ChatResource.Messages messages()

Returns the messages in a thread.

Returns: the message routes

attachments

public ChatResource.Attachments attachments()

Returns the files to send in threads.

Returns: the attachment routes

read

public void read(
        String threadId,
        Object request,
        RequestOptions options) throws IOException, InterruptedException

Marks a thread read by the signed-in person, now or at readAt (POST /v1/chat/threads/{threadId}/read).

Parameters:

  • threadId: the thread id
  • request: the optional readAt time; null marks it read now
  • options: per-request options, such as the timeout

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

ChatResource.Threads

public static final class Threads

The signed-in person's chat threads.

Threads.open

public JsonNode open(
        Object request,
        RequestOptions options) throws IOException, InterruptedException

Opens a thread about a patient, or answers the one these participants already have; every participant must be allowed to read the patient (POST /v1/chat/threads).

Parameters:

  • request: the patient, participants and optional title
  • options: per-request options, such as the timeout

Returns: the thread

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

Threads.list

public Page<JsonNode> list(
        Map<String, ?> params,
        RequestOptions options) throws IOException, InterruptedException

Lists the signed-in person's threads, newest message first (GET /v1/chat/threads).

Parameters:

  • params: optional patient, updatedSince and limit
  • options: per-request options, such as the timeout

Returns: the first page; iterating it loads the next pages

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

Threads.retrieve

public JsonNode retrieve(
        String threadId,
        RequestOptions options) throws IOException, InterruptedException

Reads one thread (GET /v1/chat/threads/{threadId}).

Parameters:

  • threadId: the thread id
  • options: per-request options, such as the timeout

Returns: the thread

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

ChatResource.Messages

public static final class Messages

Messages in a chat thread.

Messages.list

public Page<JsonNode> list(
        String threadId,
        Map<String, ?> params,
        RequestOptions options) throws IOException, InterruptedException

Lists a thread's messages, newest first; later pages go further back (GET /v1/chat/threads/{threadId}/messages).

Parameters:

  • threadId: the thread id
  • params: optional since and limit
  • options: per-request options, such as the timeout

Returns: the first page; iterating it loads the next pages

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

Messages.send

public JsonNode send(
        String threadId,
        Map<String, ?> message,
        RequestOptions options) throws IOException, InterruptedException

Sends a message, with any of the signed-in person's own uploads (POST /v1/chat/threads/{threadId}/messages). It carries a client id the server remembers, so a retried send is stored once.

Parameters:

  • threadId: the thread id
  • message: the text, optional attachments (upload ids), replyTo and clientId; a missing clientId is generated
  • options: per-request options, such as the timeout

Returns: the message

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
public JsonNode attachmentLink(
        String threadId,
        String messageId,
        String attachmentId,
        RequestOptions options) throws IOException, InterruptedException

Returns a link that downloads a file sent with a message, for the next hour (GET /v1/chat/threads/{threadId}/messages/{messageId}/attachments/{attachmentId}).

Parameters:

  • threadId: the thread id
  • messageId: the message id
  • attachmentId: the attachment id
  • options: per-request options, such as the timeout

Returns: the url and expiresAt

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

ChatResource.Attachments

public static final class Attachments

Files the signed-in person uploads to send in their chat threads.

Attachments.upload

public JsonNode upload(
        byte[] file,
        String fileName,
        String contentType,
        RequestOptions options) throws IOException, InterruptedException

Uploads a PDF, PNG, JPEG or WebP of up to 10 MB, kept private (POST /v1/chat/attachments), then stores the file where the server says. Send it with messages().send(threadId, Map.of("text", text, "attachments", List.of(attachmentId)), options), in as many threads as you like.

Parameters:

  • file: the file's bytes
  • fileName: the file name
  • contentType: application/pdf, image/png, image/jpeg or image/webp
  • options: per-request options, such as the timeout

Returns: the attachment's id, title and contentType

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokServiceException: if the store refuses the file, for example because it is larger than 10 MB
public JsonNode link(
        String attachmentId,
        RequestOptions options) throws IOException, InterruptedException

Returns a link that downloads one of the signed-in person's own uploads for the next hour (GET /v1/chat/attachments/{attachmentId}).

Parameters:

  • attachmentId: the attachment id
  • options: per-request options, such as the timeout

Returns: the url and expiresAt

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

Last updated on

On this page