removed old code
This commit is contained in:
parent
f14e14023d
commit
14475a9d64
8 changed files with 42 additions and 134 deletions
|
|
@ -56,6 +56,7 @@ class Environment {
|
|||
return dotenv.env["RC_IOS_KEY"] ?? 'appl_DUPqnxuLjkBLzhBPTWeDjqNENuv';
|
||||
}
|
||||
|
||||
// This is a public key
|
||||
static String get rcStripeKey {
|
||||
return dotenv.env["RC_STRIPE_KEY"] ?? 'strp_YWZxWUeEfvagiefDNoofinaRCOl';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ class SubscriptionController extends BaseController {
|
|||
}
|
||||
|
||||
Future<String> getPaymentLink(String duration, {bool isPromo = false}) async {
|
||||
final Requests req = Requests(baseUrl: PApiUrls.baseAPI);
|
||||
final Requests req = Requests();
|
||||
final String reqUrl = Uri.encodeFull(
|
||||
"${PApiUrls.paymentLink}?pangea_user_id=${_pangeaController.matrixState.client.userID}&duration=$duration&redeem=$isPromo",
|
||||
);
|
||||
|
|
@ -323,30 +323,6 @@ class SubscriptionController extends BaseController {
|
|||
return paymentLink;
|
||||
}
|
||||
|
||||
Future<bool> fetchSubscriptionStatus() async {
|
||||
final Requests req = Requests(baseUrl: PApiUrls.baseAPI);
|
||||
final String reqUrl = Uri.encodeFull(
|
||||
"${PApiUrls.subscriptionExpiration}?pangea_user_id=${_pangeaController.matrixState.client.userID}",
|
||||
);
|
||||
|
||||
DateTime? expiration;
|
||||
try {
|
||||
final Response res = await req.get(url: reqUrl);
|
||||
final json = jsonDecode(res.body);
|
||||
if (json["premium_expires_date"] != null) {
|
||||
expiration = DateTime.parse(json["premium_expires_date"]);
|
||||
}
|
||||
} catch (err) {
|
||||
ErrorHandler.logError(
|
||||
e: "Failed to fetch subscripton status for user ${_pangeaController.matrixState.client.userID}",
|
||||
s: StackTrace.current,
|
||||
);
|
||||
}
|
||||
final bool subscribed =
|
||||
expiration == null ? false : DateTime.now().isBefore(expiration);
|
||||
GoogleAnalytics.updateUserSubscriptionStatus(subscribed);
|
||||
return subscribed;
|
||||
}
|
||||
|
||||
Future<void> redeemPromoCode(BuildContext context) async {
|
||||
final List<String>? promoCode = await showTextInputDialog(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import 'package:jwt_decode/jwt_decode.dart';
|
|||
import 'package:matrix/matrix.dart' as matrix;
|
||||
|
||||
import '../models/user_model.dart';
|
||||
import '../repo/user_repo.dart';
|
||||
|
||||
/// Controller that manages saving and reading of user/profile information
|
||||
class UserController extends BaseController {
|
||||
|
|
@ -122,21 +121,6 @@ class UserController extends BaseController {
|
|||
/// data to profile, and migrating from the pangea profile if the account data is not present.
|
||||
Future<void> _initialize() async {
|
||||
await _pangeaController.matrixState.client.waitForAccountData();
|
||||
if (profile.userSettings.dateOfBirth != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PangeaProfileResponse? resp = await PUserRepo.fetchPangeaUserInfo(
|
||||
userID: userId!,
|
||||
matrixAccessToken: _matrixAccessToken!,
|
||||
);
|
||||
if (resp?.profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final userSetting = UserSettings.fromJson(resp!.profile.toJson());
|
||||
final newProfile = Profile(userSettings: userSetting);
|
||||
await newProfile.saveProfileData(waitForDataInSync: true);
|
||||
}
|
||||
|
||||
/// Reinitializes the user's profile
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class MobileSubscriptionInfo extends SubscriptionInfo {
|
|||
);
|
||||
return;
|
||||
}
|
||||
const accessToken = "";
|
||||
final accessToken = super.pangeaController.userController.accessToken;
|
||||
await setAppIds(accessToken);
|
||||
await setAllProducts(accessToken);
|
||||
await setCustomerInfo();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class WebSubscriptionInfo extends SubscriptionInfo {
|
|||
|
||||
@override
|
||||
Future<void> configure() async {
|
||||
const accessToken = "";
|
||||
final accessToken = super.pangeaController.userController.accessToken;
|
||||
await setAppIds(accessToken);
|
||||
await setAllProducts(accessToken);
|
||||
await setCustomerInfo();
|
||||
|
|
|
|||
|
|
@ -9,58 +9,65 @@ import 'package:fluffychat/pangea/config/environment.dart';
|
|||
///
|
||||
/// https://api.staging.pangea.chat/api/v1/
|
||||
class PApiUrls {
|
||||
static String baseAPI = Environment.baseAPI;
|
||||
static String choreoPrefix = "/choreo";
|
||||
static String revenuePrefix = "/revenue";
|
||||
static String accountPrefix = "/account";
|
||||
|
||||
static String choreoEndpoint =
|
||||
"${Environment.choreoApi}${PApiUrls.choreoPrefix}";
|
||||
static String revenueEndpoint =
|
||||
"${Environment.choreoApi}${PApiUrls.revenuePrefix}";
|
||||
static String accountEndpoint =
|
||||
"${Environment.choreoApi}${PApiUrls.accountPrefix}";
|
||||
|
||||
/// ---------------------- Languages --------------------------------------
|
||||
static String getLanguages = "${Environment.choreoApi}/choreo/languages";
|
||||
static String getLanguages = "${PApiUrls.choreoEndpoint}/languages";
|
||||
|
||||
/// ---------------------- Users --------------------------------------
|
||||
static String paymentLink = "/account/payment_link";
|
||||
static String userDetails = "/account/get_user_access_token?pangea_user_id=";
|
||||
|
||||
// USED ??
|
||||
static String createUser = "/account/create";
|
||||
static String updateUserProfile = "/account/update";
|
||||
static String subscriptionExpiration = "/account/premium_expires_date";
|
||||
static String paymentLink = "${PApiUrls.accountEndpoint}/payment_link";
|
||||
|
||||
/// ---------------------- Conversation Partner -------------------------
|
||||
static String searchUserProfiles = "/account/search";
|
||||
/// PTODO: Migrate or remove
|
||||
static String searchUserProfiles = "${PApiUrls.accountEndpoint}/search";
|
||||
|
||||
///-------------------------------- choreo --------------------------
|
||||
static String igc = "${Environment.choreoApi}/grammar";
|
||||
static String igc = "${PApiUrls.choreoEndpoint}/grammar";
|
||||
|
||||
static String languageDetection =
|
||||
"${Environment.choreoApi}/language_detection";
|
||||
"${PApiUrls.choreoEndpoint}/language_detection";
|
||||
|
||||
static String igcLite = "${Environment.choreoApi}/grammar_lite";
|
||||
static String spanDetails = "${Environment.choreoApi}/span_details";
|
||||
static String igcLite = "${PApiUrls.choreoEndpoint}/grammar_lite";
|
||||
static String spanDetails = "${PApiUrls.choreoEndpoint}/span_details";
|
||||
|
||||
static String wordNet = "${Environment.choreoApi}/wordnet";
|
||||
static String wordNet = "${PApiUrls.choreoEndpoint}/wordnet";
|
||||
static String contextualizedTranslation =
|
||||
"${Environment.choreoApi}/translation/contextual";
|
||||
"${PApiUrls.choreoEndpoint}/translation/contextual";
|
||||
static String simpleTranslation =
|
||||
"${Environment.choreoApi}/translation/direct";
|
||||
static String tokenize = "${Environment.choreoApi}/tokenize";
|
||||
"${PApiUrls.choreoEndpoint}/translation/direct";
|
||||
static String tokenize = "${PApiUrls.choreoEndpoint}/tokenize";
|
||||
static String contextualDefinition =
|
||||
"${Environment.choreoApi}/contextual_definition";
|
||||
static String similarity = "${Environment.choreoApi}/similarity";
|
||||
static String topicInfo = "${Environment.choreoApi}/vocab_list";
|
||||
"${PApiUrls.choreoEndpoint}/contextual_definition";
|
||||
static String similarity = "${PApiUrls.choreoEndpoint}/similarity";
|
||||
static String topicInfo = "${PApiUrls.choreoEndpoint}/vocab_list";
|
||||
|
||||
static String itFeedback = "${Environment.choreoApi}/translation/feedback";
|
||||
static String itFeedback = "${PApiUrls.choreoEndpoint}/translation/feedback";
|
||||
|
||||
static String firstStep = "/it_initialstep";
|
||||
static String subseqStep = "/it_step";
|
||||
|
||||
static String textToSpeech = "${Environment.choreoApi}/text_to_speech";
|
||||
static String speechToText = "${Environment.choreoApi}/speech_to_text";
|
||||
static String textToSpeech = "${PApiUrls.choreoEndpoint}/text_to_speech";
|
||||
static String speechToText = "${PApiUrls.choreoEndpoint}/speech_to_text";
|
||||
|
||||
static String messageActivityGeneration =
|
||||
"${Environment.choreoApi}/practice/message";
|
||||
|
||||
///-------------------------------- revenue cat --------------------------
|
||||
|
||||
static String rcAppsChoreo = "${Environment.choreoApi}/revenue/app_ids";
|
||||
static String rcApiV1 = "https://api.revenuecat.com/v1";
|
||||
|
||||
static String rcAppsChoreo = "${PApiUrls.revenueEndpoint}/app_ids";
|
||||
static String rcProductsChoreo =
|
||||
"${Environment.choreoApi}/revenue/all_products";
|
||||
static String rcSubscriptionChoreo =
|
||||
"${Environment.choreoApi}/revenue/subscription";
|
||||
"${PApiUrls.revenueEndpoint}/all_products";
|
||||
|
||||
static String rcSubscription = "$rcApiV1/subscribers";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,17 +13,11 @@ import 'package:http/http.dart' as http;
|
|||
import '../network/urls.dart';
|
||||
|
||||
class SubscriptionRepo {
|
||||
static final Map<String, String> requestHeaders = {
|
||||
'Content-type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'Authorization': 'Bearer ${Environment.rcKey}',
|
||||
};
|
||||
|
||||
static Future<SubscriptionAppIds?> getAppIds(String accessToken) async {
|
||||
try {
|
||||
final Requests req = Requests(
|
||||
choreoApiKey: Environment.choreoApiKey,
|
||||
accessToken: accessToken,
|
||||
matrixAccessToken: accessToken,
|
||||
);
|
||||
final http.Response res = await req.get(
|
||||
url: PApiUrls.rcAppsChoreo,
|
||||
|
|
@ -47,7 +41,7 @@ class SubscriptionRepo {
|
|||
try {
|
||||
final Requests req = Requests(
|
||||
choreoApiKey: Environment.choreoApiKey,
|
||||
accessToken: accessToken,
|
||||
matrixAccessToken: accessToken,
|
||||
);
|
||||
final http.Response res = await req.get(
|
||||
url: PApiUrls.rcProductsChoreo,
|
||||
|
|
@ -74,7 +68,7 @@ class SubscriptionRepo {
|
|||
'Accept': 'application/json',
|
||||
'Authorization': 'Bearer ${Environment.rcStripeKey}',
|
||||
};
|
||||
final String url = "${PApiUrls.rcSubscribers}/$userId";
|
||||
final String url = "${PApiUrls.rcSubscription}/$userId";
|
||||
final http.Response res = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: stripeHeaders,
|
||||
|
|
|
|||
|
|
@ -1,66 +1,13 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../models/user_model.dart';
|
||||
import '../models/user_profile_search_model.dart';
|
||||
import '../network/requests.dart';
|
||||
import '../network/urls.dart';
|
||||
|
||||
class PUserRepo {
|
||||
// static Future<PangeaProfileResponse?> repoCreatePangeaUser({
|
||||
// required String userID,
|
||||
// required String dob,
|
||||
// required fullName,
|
||||
// required String matrixAccessToken,
|
||||
// }) async {
|
||||
// try {
|
||||
// final Requests req = Requests(
|
||||
// baseUrl: PApiUrls.baseAPI,
|
||||
// matrixAccessToken: matrixAccessToken,
|
||||
// );
|
||||
|
||||
// final Map<String, dynamic> body = {
|
||||
// ModelKey.userFullName: fullName,
|
||||
// ModelKey.userPangeaUserId: userID,
|
||||
// ModelKey.userDateOfBirth: dob,
|
||||
// };
|
||||
// final resp = await req.post(
|
||||
// url: PApiUrls.createUser,
|
||||
// body: body,
|
||||
// );
|
||||
// return PangeaProfileResponse.fromJson(jsonDecode(resp.body));
|
||||
// } catch (err, s) {
|
||||
// ErrorHandler.logError(e: err, s: s);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
static Future<PangeaProfileResponse?> fetchPangeaUserInfo({
|
||||
required String userID,
|
||||
required String matrixAccessToken,
|
||||
}) async {
|
||||
Response res;
|
||||
try {
|
||||
final Requests req = Requests(
|
||||
baseUrl: PApiUrls.baseAPI,
|
||||
matrixAccessToken: matrixAccessToken,
|
||||
);
|
||||
res = await req.get(
|
||||
url: PApiUrls.userDetails,
|
||||
objectId: userID,
|
||||
);
|
||||
|
||||
return PangeaProfileResponse.fromJson(jsonDecode(res.body));
|
||||
} catch (err) {
|
||||
//status code should be 400 - PTODO - check ffor this.
|
||||
log("Most likely a first signup and needs to make an account");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<UserProfileSearchResponse> searchUserProfiles({
|
||||
// List<String>? interests,
|
||||
String? targetLanguage,
|
||||
|
|
@ -72,7 +19,6 @@ class PUserRepo {
|
|||
required int limit,
|
||||
}) async {
|
||||
final Requests req = Requests(
|
||||
baseUrl: PApiUrls.baseAPI,
|
||||
accessToken: accessToken,
|
||||
);
|
||||
final Map<String, dynamic> body = {};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue