applyToParams method

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

Apply authentication settings to header and query params.

Implementation

@override
void applyToParams(
    List<QueryParam> queryParams, Map<String, String> headerParams) {
  final value = apiKeyPrefix == null ? apiKey : '$apiKeyPrefix $apiKey';

  if (location == 'query' && value != null) {
    queryParams.add(QueryParam(paramName, value));
  } else if (location == 'header' && value != null) {
    headerParams[paramName] = value;
  } else if (location == 'cookie' && value != null) {
    headerParams.update(
      'Cookie',
      (existingCookie) => '$existingCookie; $paramName=$value',
      ifAbsent: () => '$paramName=$value',
    );
  }
}