# Task ID: 7
# Title: Implement, Document, & Test `getMessageById` Endpoint
# Status: done
# Dependencies: 1
# Priority: medium
# Description: Implement the `getMessageById` method, write JSDoc/TSDoc documentation, and develop unit tests. Ensure adherence to SDK conventions for API calls, error handling, and authentication.
# Details:
Functional Requirement 4.6: Method: getMessageById(session: string, chatId: string, messageId: string, options?: { downloadMedia?: boolean }): Promise. API Call: GET /api/{session}/chats/{chatId}/messages/{messageId}. Parameters: session (path, required), chatId (path, required), messageId (path, required), downloadMedia (query, optional). Response: WAMessage object. Adhere to NFRs.

# Test Strategy:
Unit tests for retrieving a specific message, media download option, error cases (message not found), and parameter validation.

# Subtasks:
## 1. Implement `getMessageById` Method and Parameter Handling [done]
### Dependencies: None
### Description: Implement the core logic for the `getMessageById` method, including the API call to GET /api/{session}/chats/{chatId}/messages/{messageId}. Handle path parameters (session, chatId, messageId) and the optional `downloadMedia` query parameter.
### Details:
Define the function signature: `getMessageById(session: string, chatId: string, messageId: string, options?: { downloadMedia?: boolean }): Promise<WAMessage>`. Implement the API call, ensuring `downloadMedia` is passed as a query parameter if provided. The method should process and return the `WAMessage` object from the response.

## 2. Integrate Error Handling and Authentication for `getMessageById` [done]
### Dependencies: None
### Description: Integrate SDK-standard error handling for API responses (e.g., message not found, invalid parameters) and network issues. Ensure authentication is handled by the HTTP client.
### Details:
Wrap the API call in a try/catch block. Handle potential errors by throwing a new, descriptive `Error` object, consistent with SDK conventions. Authentication is typically managed by the `httpClient`.

## 3. Write JSDoc/TSDoc Documentation for `getMessageById` [done]
### Dependencies: None
### Description: Write comprehensive JSDoc/TSDoc documentation for the `getMessageById` method, its parameters (session, chatId, messageId, options.downloadMedia), return type (`WAMessage`), and potential error conditions.
### Details:
Document the method's purpose, all parameters including the optional `downloadMedia` flag, the structure of the resolved `Promise<WAMessage>`, and common errors like message not found.

## 4. Develop Unit Tests for `getMessageById` (Success Scenarios and `downloadMedia` option) [done]
### Dependencies: None
### Description: Develop unit tests for `getMessageById` covering successful message retrieval, including variations with the `downloadMedia` option (true and false).
### Details:
Create test cases to verify that a `WAMessage` object is correctly returned upon successful API calls. Test scenarios with and without the `downloadMedia` query parameter, mocking API responses as needed to simulate these conditions.

## 5. Develop Unit Tests for `getMessageById` (Error Scenarios and Parameter Validation) [done]
### Dependencies: None
### Description: Develop unit tests for `getMessageById` covering error scenarios (e.g., message not found, invalid parameters, API errors, authentication failures) and parameter validation.
### Details:
Create test cases to ensure proper error reporting for invalid input parameters. Test how the method handles simulated API errors (e.g., 401, 403, 404 for message not found, 500) and authentication failures. Mock API responses to simulate these error conditions.

