MockResponse class final

A canned reply produced by MockWordpressAdapter.

Constructors

MockResponse({int statusCode = 200, dynamic body, Map<String, String> headers = const {}, Duration delay = Duration.zero, String? error, DioExceptionType errorType = DioExceptionType.connectionError})
const
MockResponse.connectionError([String message = 'Connection reset'])
A transport level failure (no HTTP response), e.g. a connection reset.
factory
MockResponse.paged(List items, {required int total, required int totalPages, Map<String, String> headers = const {}, Duration delay = Duration.zero})
A paginated list response carrying X-WP-Total and X-WP-TotalPages.
factory
MockResponse.timeout([String message = 'Receive timeout'])
A receive timeout (no HTTP response).
factory
MockResponse.wpError({required int statusCode, required String code, String message = ''})
A WordPress-style JSON error, e.g. rest_post_invalid_id.
factory

Properties

body → dynamic
Either a String (sent verbatim) or any JSON encodable value.
final
delay → Duration
Artificial latency before the response is delivered.
final
error → String?
When set, the adapter throws a DioException of errorType with this message instead of answering.
final
errorType → DioExceptionType
The kind of DioException thrown when error is set.
final
hashCode → int
The hash code for this object.
no setterinherited
headers → Map<String, String>
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
statusCode → int
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited