add ad services and Docker configuration for web app
Some checks failed
Build Android App / build (push) Has been cancelled

This commit is contained in:
ImBenji
2026-01-02 15:21:27 +00:00
parent 7a88585b6e
commit f1ce1c77a4
22 changed files with 608 additions and 19 deletions

View File

@@ -170,7 +170,10 @@ class QuoteGeneratorApiV2 {
final response = await http.post(
url,
headers: {"Content-Type": "application/json"},
headers: {
"Content-Type": "application/json",
"User-Agent": "QuoteGen-Flutter/1.0",
},
body: jsonEncode(request.toJson()),
);
@@ -178,7 +181,7 @@ class QuoteGeneratorApiV2 {
final data = jsonDecode(response.body);
return QuoteSession.fromJson(data);
} else {
throw Exception("Failed to create sesion: ${response.statusCode}");
throw Exception("Failed to create session: ${response.statusCode}");
}
}
@@ -187,7 +190,10 @@ class QuoteGeneratorApiV2 {
static Future<QuoteSession> getSession(String sessionId) async {
final url = Uri.parse("$_baseUrl/v2/quote/$sessionId");
final response = await http.get(url);
final response = await http.get(
url,
headers: {"User-Agent": "QuoteGen-Flutter/1.0"},
);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
@@ -206,7 +212,10 @@ class QuoteGeneratorApiV2 {
final response = await http.patch(
url,
headers: {"Content-Type": "application/json"},
headers: {
"Content-Type": "application/json",
"User-Agent": "QuoteGen-Flutter/1.0",
},
body: jsonEncode(updates.toJson()),
);
@@ -214,7 +223,7 @@ class QuoteGeneratorApiV2 {
final data = jsonDecode(response.body);
return QuoteSession.fromJson(data);
} else {
throw Exception("Failed to updte session: ${response.statusCode}");
throw Exception("Failed to update session: ${response.statusCode}");
}
}
@@ -222,12 +231,15 @@ class QuoteGeneratorApiV2 {
static Future<Uint8List> generateImage(String sessionId) async {
final url = Uri.parse("$_baseUrl/v2/quote/$sessionId/image");
final response = await http.get(url);
final response = await http.get(
url,
headers: {"User-Agent": "QuoteGen-Flutter/1.0"},
);
if (response.statusCode == 200) {
return response.bodyBytes;
} else {
throw Exception("Failed to genrate image: ${response.statusCode}");
throw Exception("Failed to generate image: ${response.statusCode}");
}
}
@@ -236,15 +248,18 @@ class QuoteGeneratorApiV2 {
static Future<void> deleteSession(String sessionId) async {
final url = Uri.parse("$_baseUrl/v2/quote/$sessionId");
final response = await http.delete(url);
final response = await http.delete(
url,
headers: {"User-Agent": "QuoteGen-Flutter/1.0"},
);
if (response.statusCode != 204) {
throw Exception("Failed to delte session: ${response.statusCode}");
throw Exception("Failed to delete session: ${response.statusCode}");
}
}
// helper to get curren timestamp in seconds
// helper to get current timestamp in seconds
static int getCurrentTimestamp() {
return DateTime.now().millisecondsSinceEpoch ~/ 1000;
}