Options
All
  • Public
  • Public/Protected
  • All
Menu

This class supports create messages within threads.
Do not create it directly; Get it from AinftJs instance.

Hierarchy

Index

Constructors

  • new Messages(baseUrl: string, route: null | string, ain: default, ainize?: default): Messages

Properties

ain: default

The Ain object for sign and send transaction to AIN blockchain.

ainize?: default

The Ainize object for send request to AIN blockchain.

baseUrl: string = ''

The base url of api server of AINFT Factory.

route: string

The subpath of api server request url.

Methods

  • buildTxBodyForCreateMessage(address: string, objectId: string, tokenId: string, threadId: string, messages: any): Promise<TransactionInput>
  • Parameters

    • address: string
    • objectId: string
    • tokenId: string
    • threadId: string
    • messages: any

    Returns Promise<TransactionInput>

  • buildTxBodyForUpdateMessage(__namedParameters: Message, objectId: string, tokenId: string, address: string): Promise<TransactionInput>
  • Parameters

    • __namedParameters: Message
    • objectId: string
    • tokenId: string
    • address: string

    Returns Promise<TransactionInput>

  • Create a message.

    Parameters

    • objectId: string

      The ID of AINFT object.

    • tokenId: string

      The ID of AINFT token.

    • threadId: string

      The ID of thread.

    • body: MessageCreateParams

    Returns Promise<MessagesTransactionResult>

    A promise that resolves with both the transaction result and a list including the new message.

  • findMessageKey(messages: MessageMap, messageId: string): string
  • get(objectId: string, tokenId: string, threadId: string, messageId: string, address: string): Promise<Message>
  • Retrieves a message.

    Parameters

    • objectId: string

      The ID of AINFT object.

    • tokenId: string

      The ID of AINFT token.

    • threadId: string

      The ID of thread.

    • messageId: string

      The ID of message.

    • address: string

      The checksum address of account.

    Returns Promise<Message>

    A promise that resolves with the message.

  • getAllMessages(appId: string, tokenId: string, address: string, threadId: string, newMessages: MessageMap): Promise<{}>
  • list(objectId: string, tokenId: string, threadId: string, address: string): Promise<MessageMap>
  • Retrieves a list of messages.

    Parameters

    • objectId: string

      The ID of AINFT object.

    • tokenId: string

      The ID of AINFT token.

    • threadId: string

      The ID of thread.

    • address: string

      The checksum address of account.

    Returns Promise<MessageMap>

    A promise that resolves with the list of messages.

  • sendFormRequest(method: POST | PUT, trailingUrl: string, stringFields: {}, fileFields: {}): Promise<any>
  • Sends request that include form to api server of AINFT Factory. Used to upload asset data.

    Parameters

    • method: POST | PUT

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • stringFields: {}

      The string fields of form.

      • [key: string]: string
    • fileFields: {}

      The file fields of form.

      • [key: string]: { buffer: Buffer; filename: string }
        • buffer: Buffer
        • filename: string

    Returns Promise<any>

    Returns response of api request.

  • sendMessage(serviceName: string, threadId: string, objectId: string, tokenId: string, assistantId: string, address: string, params: MessageCreateParams): Promise<any>
  • sendRequest(method: HttpMethod, trailingUrl: string, data?: Record<string, any>): Promise<any>
  • Sends request to api server of AINFT Factory. Authenticate by signing data.

    Parameters

    • method: HttpMethod

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • Optional data: Record<string, any>

      The data to be included in the api request.

    Returns Promise<any>

    Returns response of api request.

  • sendRequestWithoutSign(method: HttpMethod, trailingUrl: string, data?: Record<string, any>, headers?: AxiosRequestHeaders): Promise<any>
  • Sends request to api server of AINFT Factory. Used when authentication is not required.

    Parameters

    • method: HttpMethod

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • Optional data: Record<string, any>

      The data to be included in the api request.

    • Optional headers: AxiosRequestHeaders

      The headers of Http api request.

    Returns Promise<any>

    Returns response of api request.

  • setBaseUrl(baseUrl: string): void
  • signData(data: any): string | Promise<string>
  • Sign the data with the private key that the user has registered.

    Parameters

    • data: any

      The data to sign.

    Returns string | Promise<string>

    Returns signature string.

  • Updates a thread.

    Parameters

    • objectId: string

      The ID of AINFT object.

    • tokenId: string

      The ID of AINFT token.

    • threadId: string

      The ID of thread.

    • messageId: string

      The ID of message.

    • MessageUpdateParams: MessageUpdateParams

      The parameters to update message.

    Returns Promise<MessageTransactionResult>

    A promise that resolves with both the transaction result and the updated message.

Generated using TypeDoc