APIRequest constructor
APIRequest({})
Implementation
APIRequest({
required this.endpoint,
this.method = HTTPMethod.get,
Map<String, String>? headers,
this.query = const {},
this.body,
this.contentType = "application/json",
this.isLogResponse = false,
String? baseUrl,
this.isBaseResponse = true,
this.isMultiLanguage = true,
}) {
String langCode = 'vi';
switch (locale?.languageCode) {
case "en":
langCode = 'en';
break;
case "vi":
langCode = 'vi';
break;
case "ja":
langCode = 'jp';
break;
}
final baseHeaders = {
if (apiToken != null) 'Authorization': "Bearer $apiToken",
if (xApplication != null) 'X-AICycle-Application': xApplication!,
if (isMultiLanguage) "lang": langCode,
};
this.headers = baseHeaders;
this.headers?.addAll(headers ?? {});
if (baseUrl != null) {
this.baseUrl = baseUrl;
}
}