handlebars.dart.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;
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;
}
}
}