fixed some incorrect URLs and request setups
This commit is contained in:
parent
21641f514a
commit
e7debbdd39
7 changed files with 32 additions and 13 deletions
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
|
import 'package:fluffychat/pangea/config/environment.dart';
|
||||||
import 'package:fluffychat/pangea/constants/local.key.dart';
|
import 'package:fluffychat/pangea/constants/local.key.dart';
|
||||||
import 'package:fluffychat/pangea/controllers/base_controller.dart';
|
import 'package:fluffychat/pangea/controllers/base_controller.dart';
|
||||||
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
|
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
|
||||||
|
|
@ -308,7 +309,10 @@ class SubscriptionController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getPaymentLink(String duration, {bool isPromo = false}) async {
|
Future<String> getPaymentLink(String duration, {bool isPromo = false}) async {
|
||||||
final Requests req = Requests();
|
final Requests req = Requests(
|
||||||
|
choreoApiKey: Environment.choreoApiKey,
|
||||||
|
accessToken: _pangeaController.userController.accessToken,
|
||||||
|
);
|
||||||
final String reqUrl = Uri.encodeFull(
|
final String reqUrl = Uri.encodeFull(
|
||||||
"${PApiUrls.paymentLink}?pangea_user_id=${_pangeaController.matrixState.client.userID}&duration=$duration&redeem=$isPromo",
|
"${PApiUrls.paymentLink}?pangea_user_id=${_pangeaController.matrixState.client.userID}&duration=$duration&redeem=$isPromo",
|
||||||
);
|
);
|
||||||
|
|
@ -323,7 +327,6 @@ class SubscriptionController extends BaseController {
|
||||||
return paymentLink;
|
return paymentLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> redeemPromoCode(BuildContext context) async {
|
Future<void> redeemPromoCode(BuildContext context) async {
|
||||||
final List<String>? promoCode = await showTextInputDialog(
|
final List<String>? promoCode = await showTextInputDialog(
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
|
|
|
||||||
|
|
@ -52,14 +52,14 @@ class PApiUrls {
|
||||||
|
|
||||||
static String itFeedback = "${PApiUrls.choreoEndpoint}/translation/feedback";
|
static String itFeedback = "${PApiUrls.choreoEndpoint}/translation/feedback";
|
||||||
|
|
||||||
static String firstStep = "/it_initialstep";
|
static String firstStep = "${PApiUrls.choreoEndpoint}/it_initialstep";
|
||||||
static String subseqStep = "/it_step";
|
static String subseqStep = "${PApiUrls.choreoEndpoint}/it_step";
|
||||||
|
|
||||||
static String textToSpeech = "${PApiUrls.choreoEndpoint}/text_to_speech";
|
static String textToSpeech = "${PApiUrls.choreoEndpoint}/text_to_speech";
|
||||||
static String speechToText = "${PApiUrls.choreoEndpoint}/speech_to_text";
|
static String speechToText = "${PApiUrls.choreoEndpoint}/speech_to_text";
|
||||||
|
|
||||||
static String messageActivityGeneration =
|
static String messageActivityGeneration =
|
||||||
"${Environment.choreoApi}/practice/message";
|
"${PApiUrls.choreoEndpoint}/practice/message";
|
||||||
|
|
||||||
///-------------------------------- revenue cat --------------------------
|
///-------------------------------- revenue cat --------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||||
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
|
@ -44,9 +45,12 @@ class GenerateImageRequest {
|
||||||
|
|
||||||
class ImageRepo {
|
class ImageRepo {
|
||||||
static Future<GenerateImageeResponse> fetchImage(
|
static Future<GenerateImageeResponse> fetchImage(
|
||||||
GenerateImageRequest request) async {
|
GenerateImageRequest request,
|
||||||
final Requests req =
|
) async {
|
||||||
Requests(baseUrl: Environment.choreoApi); // Set your API base URL
|
final Requests req = Requests(
|
||||||
|
choreoApiKey: Environment.choreoApiKey,
|
||||||
|
accessToken: MatrixState.pangeaController.userController.accessToken,
|
||||||
|
); // Set your API base URL
|
||||||
final requestBody = request.toJson();
|
final requestBody = request.toJson();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -58,7 +62,8 @@ class ImageRepo {
|
||||||
if (res.statusCode == 200) {
|
if (res.statusCode == 200) {
|
||||||
final decodedBody = jsonDecode(utf8.decode(res.bodyBytes));
|
final decodedBody = jsonDecode(utf8.decode(res.bodyBytes));
|
||||||
return GenerateImageeResponse.fromJson(
|
return GenerateImageeResponse.fromJson(
|
||||||
decodedBody); // Convert response to ImageModel
|
decodedBody,
|
||||||
|
); // Convert response to ImageModel
|
||||||
} else {
|
} else {
|
||||||
throw Exception('Failed to load image');
|
throw Exception('Failed to load image');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:fluffychat/pangea/config/environment.dart';
|
||||||
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/pangea/config/environment.dart';
|
|
||||||
import '../models/custom_input_translation_model.dart';
|
import '../models/custom_input_translation_model.dart';
|
||||||
import '../models/it_response_model.dart';
|
import '../models/it_response_model.dart';
|
||||||
import '../models/system_choice_translation_model.dart';
|
import '../models/system_choice_translation_model.dart';
|
||||||
|
|
@ -14,8 +15,8 @@ class ITRepo {
|
||||||
CustomInputRequestModel initalText,
|
CustomInputRequestModel initalText,
|
||||||
) async {
|
) async {
|
||||||
final Requests req = Requests(
|
final Requests req = Requests(
|
||||||
baseUrl: Environment.choreoApi,
|
|
||||||
choreoApiKey: Environment.choreoApiKey,
|
choreoApiKey: Environment.choreoApiKey,
|
||||||
|
accessToken: MatrixState.pangeaController.userController.accessToken,
|
||||||
);
|
);
|
||||||
final Response res =
|
final Response res =
|
||||||
await req.post(url: PApiUrls.firstStep, body: initalText.toJson());
|
await req.post(url: PApiUrls.firstStep, body: initalText.toJson());
|
||||||
|
|
@ -29,8 +30,8 @@ class ITRepo {
|
||||||
SystemChoiceRequestModel subseqText,
|
SystemChoiceRequestModel subseqText,
|
||||||
) async {
|
) async {
|
||||||
final Requests req = Requests(
|
final Requests req = Requests(
|
||||||
baseUrl: Environment.choreoApi,
|
|
||||||
choreoApiKey: Environment.choreoApiKey,
|
choreoApiKey: Environment.choreoApiKey,
|
||||||
|
accessToken: MatrixState.pangeaController.userController.accessToken,
|
||||||
);
|
);
|
||||||
|
|
||||||
final Response res =
|
final Response res =
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:fluffychat/pangea/config/environment.dart';
|
||||||
import 'package:fluffychat/pangea/models/language_model.dart';
|
import 'package:fluffychat/pangea/models/language_model.dart';
|
||||||
import 'package:fluffychat/pangea/network/urls.dart';
|
import 'package:fluffychat/pangea/network/urls.dart';
|
||||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||||
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
|
@ -11,7 +13,10 @@ import '../network/requests.dart';
|
||||||
|
|
||||||
class LanguageRepo {
|
class LanguageRepo {
|
||||||
static Future<List<LanguageModel>> fetchLanguages() async {
|
static Future<List<LanguageModel>> fetchLanguages() async {
|
||||||
final Requests req = Requests();
|
final Requests req = Requests(
|
||||||
|
choreoApiKey: Environment.choreoApiKey,
|
||||||
|
accessToken: MatrixState.pangeaController.userController.accessToken,
|
||||||
|
);
|
||||||
final Response res = await req.get(url: PApiUrls.getLanguages);
|
final Response res = await req.get(url: PApiUrls.getLanguages);
|
||||||
|
|
||||||
final decodedBody =
|
final decodedBody =
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import 'package:fluffychat/pangea/controllers/subscription_controller.dart';
|
||||||
import 'package:fluffychat/pangea/network/requests.dart';
|
import 'package:fluffychat/pangea/network/requests.dart';
|
||||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||||
import 'package:fluffychat/pangea/utils/subscription_app_id.dart';
|
import 'package:fluffychat/pangea/utils/subscription_app_id.dart';
|
||||||
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
@ -17,6 +18,7 @@ class SubscriptionRepo {
|
||||||
try {
|
try {
|
||||||
final Requests req = Requests(
|
final Requests req = Requests(
|
||||||
choreoApiKey: Environment.choreoApiKey,
|
choreoApiKey: Environment.choreoApiKey,
|
||||||
|
accessToken: MatrixState.pangeaController.userController.accessToken,
|
||||||
);
|
);
|
||||||
final http.Response res = await req.get(
|
final http.Response res = await req.get(
|
||||||
url: PApiUrls.rcAppsChoreo,
|
url: PApiUrls.rcAppsChoreo,
|
||||||
|
|
@ -38,6 +40,7 @@ class SubscriptionRepo {
|
||||||
try {
|
try {
|
||||||
final Requests req = Requests(
|
final Requests req = Requests(
|
||||||
choreoApiKey: Environment.choreoApiKey,
|
choreoApiKey: Environment.choreoApiKey,
|
||||||
|
accessToken: MatrixState.pangeaController.userController.accessToken,
|
||||||
);
|
);
|
||||||
final http.Response res = await req.get(
|
final http.Response res = await req.get(
|
||||||
url: PApiUrls.rcProductsChoreo,
|
url: PApiUrls.rcProductsChoreo,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:fluffychat/pangea/config/environment.dart';
|
||||||
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
|
@ -20,6 +21,7 @@ class PUserRepo {
|
||||||
}) async {
|
}) async {
|
||||||
final Requests req = Requests(
|
final Requests req = Requests(
|
||||||
accessToken: accessToken,
|
accessToken: accessToken,
|
||||||
|
choreoApiKey: Environment.choreoApiKey,
|
||||||
);
|
);
|
||||||
final Map<String, dynamic> body = {};
|
final Map<String, dynamic> body = {};
|
||||||
// if (interests != null) body[ModelKey.userInterests] = interests.toString();
|
// if (interests != null) body[ModelKey.userInterests] = interests.toString();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue