ApiMethod.fromJson constructor
ApiMethod.fromJson(
- Map<String, dynamic> json
)
Implementation
factory ApiMethod.fromJson(Map<String, dynamic> json) {
String? response;
bool responseIsList = false;
final rawResponse = json['response'];
if (rawResponse is List && rawResponse.isNotEmpty) {
response = rawResponse.first as String;
responseIsList = true;
} else if (rawResponse is String) {
response = rawResponse;
}
return ApiMethod(
params: _optionalMap(json['params']),
body: _optionalMap(json['body']),
query: _optionalMap(json['query']),
response: response,
responseIsList: responseIsList,
);
}