All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dart.auth.api_key_auth.mustache Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
part of {{pubName}}.api;

class ApiKeyAuth implements Authentication {

  final String location;
  final String paramName;
  String apiKey;
  String apiKeyPrefix;

  ApiKeyAuth(this.location, this.paramName);

  @override
  void applyToParams(List queryParams, Map headerParams) {
    String value;
    if (apiKeyPrefix != null) {
      value = '$apiKeyPrefix $apiKey';
    } else {
      value = apiKey;
    }

    if (location == 'query' && value != null) {
      queryParams.add(new QueryParam(paramName, value));
    } else if (location == 'header' && value != null) {
      headerParams[paramName] = value;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy