You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
|
2 years ago
|
import 'dart:convert';
|
||
|
|
|
||
|
|
import 'package:http/http.dart';
|
||
|
|
|
||
|
10 months ago
|
import 'package:fluffychat/pangea/common/config/environment.dart';
|
||
|
10 months ago
|
import 'package:fluffychat/widgets/matrix.dart';
|
||
|
10 months ago
|
import '../../common/network/requests.dart';
|
||
|
|
import '../../common/network/urls.dart';
|
||
|
2 years ago
|
import '../models/custom_input_translation_model.dart';
|
||
|
|
import '../models/it_response_model.dart';
|
||
|
10 months ago
|
import 'system_choice_translation_model.dart';
|
||
|
2 years ago
|
|
||
|
|
class ITRepo {
|
||
|
|
static Future<ITResponseModel> customInputTranslate(
|
||
|
2 years ago
|
CustomInputRequestModel initalText,
|
||
|
|
) async {
|
||
|
2 years ago
|
final Requests req = Requests(
|
||
|
2 years ago
|
choreoApiKey: Environment.choreoApiKey,
|
||
|
1 year ago
|
accessToken: MatrixState.pangeaController.userController.accessToken,
|
||
|
2 years ago
|
);
|
||
|
2 years ago
|
final Response res =
|
||
|
|
await req.post(url: PApiUrls.firstStep, body: initalText.toJson());
|
||
|
|
|
||
|
|
final json = jsonDecode(utf8.decode(res.bodyBytes).toString());
|
||
|
|
|
||
|
|
return ITResponseModel.fromJson(json);
|
||
|
|
}
|
||
|
|
|
||
|
|
static Future<ITResponseModel> systemChoiceTranslate(
|
||
|
2 years ago
|
SystemChoiceRequestModel subseqText,
|
||
|
|
) async {
|
||
|
2 years ago
|
final Requests req = Requests(
|
||
|
2 years ago
|
choreoApiKey: Environment.choreoApiKey,
|
||
|
1 year ago
|
accessToken: MatrixState.pangeaController.userController.accessToken,
|
||
|
2 years ago
|
);
|
||
|
2 years ago
|
|
||
|
|
final Response res =
|
||
|
|
await req.post(url: PApiUrls.subseqStep, body: subseqText.toJson());
|
||
|
|
|
||
|
|
final decodedBody = jsonDecode(utf8.decode(res.bodyBytes).toString());
|
||
|
|
|
||
|
|
return ITResponseModel.fromJson(decodedBody);
|
||
|
|
}
|
||
|
|
}
|