applyToParams method

  1. @override
void applyToParams(
  1. List<MmQueryParam> queryParams,
  2. Map<String, String> headerParams
)
override

Apply authentication settings to header and query params.

Implementation

@override
void applyToParams(List<MmQueryParam> queryParams, Map<String, String> headerParams) {
  final paramValue = apiKeyPrefix.isEmpty ? apiKey : '$apiKeyPrefix $apiKey';

  if (paramValue.isNotEmpty) {
    if (location == MmHttpLocation.query) {
      queryParams.add(MmQueryParam(paramName, paramValue));
    } else if (location == MmHttpLocation.header) {
      headerParams[paramName] = paramValue;
    } else if (location == MmHttpLocation.cookie) {
      headerParams.update(
        'Cookie',
        (existingCookie) => '$existingCookie; $paramName=$paramValue',
        ifAbsent: () => '$paramName=$paramValue',
      );
    }
  }
}