Wow, fuck autogenerators

This commit is contained in:
Andrew 2023-04-25 02:03:12 +07:00
parent ebfafea617
commit 2d44d22f5f
46 changed files with 630 additions and 3139 deletions

View file

@ -1,37 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:tuuli_api/src/auth/auth.dart';
class BasicAuthInfo {
final String username;
final String password;
const BasicAuthInfo(this.username, this.password);
}
class BasicAuthInterceptor extends AuthInterceptor {
final Map<String, BasicAuthInfo> authInfo = {};
@override
void onRequest(
RequestOptions options,
RequestInterceptorHandler handler,
) {
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
for (final info in metadataAuthInfo) {
final authName = info['name'] as String;
final basicAuthInfo = authInfo[authName];
if (basicAuthInfo != null) {
final basicAuth = 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}';
options.headers['Authorization'] = basicAuth;
break;
}
}
super.onRequest(options, handler);
}
}

View file

@ -1,26 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:dio/dio.dart';
import 'package:tuuli_api/src/auth/auth.dart';
class BearerAuthInterceptor extends AuthInterceptor {
final Map<String, String> tokens = {};
@override
void onRequest(
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
options.headers['Authorization'] = 'Bearer ${token}';
break;
}
}
super.onRequest(options, handler);
}
}

View file

@ -1,26 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:dio/dio.dart';
import 'package:tuuli_api/src/auth/auth.dart';
class OAuthInterceptor extends AuthInterceptor {
final Map<String, String> tokens = {};
@override
void onRequest(
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'oauth' || secure['type'] == 'oauth2');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
options.headers['Authorization'] = 'Bearer ${token}';
break;
}
}
super.onRequest(options, handler);
}
}