Skip to main content

Overview

The ReturnType model represents a generic response structure used by various API methods to indicate the success or failure of an operation.

Properties

code
int
Response code indicating the status of the operation. A value of 0 typically indicates success, while non-zero values indicate errors.
data
string
Additional data or message describing the result of the operation

Example JSON

{
  "code": 0,
  "data": "Operation completed successfully"
}

Usage Example

use D4T\MT5Sdk\Models\ReturnType;

// Most API methods return specific types, but ReturnType is used for generic responses
try {
    $result = $api->someOperation();
    
    if ($result->getCode() === 0) {
        echo "Success: " . $result->getData();
    } else {
        echo "Error (code " . $result->getCode() . "): " . $result->getData();
    }
} catch (Exception $e) {
    echo 'Operation failed: ' . $e->getMessage();
}

Methods

Getters

  • getCode(): int - Get the response code
  • getData(): string - Get the response data

Setters

  • setCode(int $code): self - Set the response code
  • setData(string $data): self - Set the response data

Common Response Codes

CodeMeaning
0Success
1General error
401Authentication failed
404Resource not found
500Internal server error