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

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

part of {{pubName}}.api;

class ApiKeyAuth implements Authentication {

  final String location;
  final String paramName;
  String _apiKey;
  String apiKeyPrefix;

  set apiKey(String key) => _apiKey = key;

  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(QueryParam(paramName, value));
    } else if (location == 'header' && value != null) {
      headerParams[paramName] = value;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy