Message class This is only returned as an array in Client.messages() method

Hierarchy

  • Client
    • Message

Constructors

  • Parameters

    • xmlObject: {}
      • credentials: LoginCredentials
      • hostUrl: string

      Returns Message

    Properties

    attachments: Attachment[]
    beginDate: Date
    from: {
        email: string;
        name: string;
        smMsgPersonGu: string;
        staffGu: string;
    }

    Type declaration

    • email: string
    • name: string
    • smMsgPersonGu: string
    • staffGu: string
    htmlContent: string
    icon: Icon
    id: string
    module: string
    subject: {
        html: string;
        raw: string;
    }

    Type declaration

    • html: string
    • raw: string
    type: string

    Methods

    • Check if a message is deletable

      Returns

      Returns a boolean declaring whether or not the message is deletable

      Returns boolean

    • Check if a message has been read

      Returns

      Returns a boolean declaring whether or not the message has been previously read

      Returns boolean

    • Marks the message as read

      Returns

      Returns true to show that it has been marked as read

      Description

      const messages = await client.messages();
      messages.every((msg) => msg.isRead()) // -> false
      messages.forEach(async (msg) => !msg.isRead() && await msg.markAsRead());
      messages.every((msg) => msg.isRead()) // -> true
      const refetchedMessages = await client.messages(); // See if it updated on the server
      messages.every((msg) => msg.isRead()) // -> true

      Description

      // In a React project...
      import React from 'react';

      const Message = (props) => {
      const { message } = props;

      async function handleOnClick() {
      await message.markAsRead();
      }

      return (
      <button onClick={handleOnClick} style={{ color: message.isRead() ? undefined : 'red' }}>
      <p>{message.subject.raw}</p>
      </button>
      )
      }

      export default Message;

      Returns Promise<true>

    • Type Parameters

      • T extends undefined | object

      Parameters

      • url: string
      • options: Partial<RequestOptions> = {}
      • preparse: ((xml: string) => string) = ...
          • (xml: string): string
          • Parameters

            • xml: string

            Returns string

      Returns Promise<T>

    Generated using TypeDoc