Using choreo with matrix token (2) (#1242)

* using choreo with matrixç

* removed old stuff

* removed old stuff2

* merge and removed matrix-access-token header

---------

Co-authored-by: ggurdin <46800240+ggurdin@users.noreply.github.com>
Co-authored-by: ggurdin <ggurdin@gmail.com>
pull/1544/head
Brord van Wierst 10 months ago committed by GitHub
parent 2c88e6038b
commit e417af93fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3,4 +3,12 @@ CHOREO_API = 'https://api.staging.pangea.chat'
FRONTEND_URL='https://app.staging.pangea.chat' FRONTEND_URL='https://app.staging.pangea.chat'
SYNAPSE_URL = 'matrix.staging.pangea.chat' SYNAPSE_URL = 'matrix.staging.pangea.chat'
CHOREO_API_KEY = 'e6fa9fa97031ba0c852efe78457922f278a2fbc109752fe18e465337699e9873' CHOREO_API_KEY = 'e6fa9fa97031ba0c852efe78457922f278a2fbc109752fe18e465337699e9873'
RC_GOOGLE_KEY = 'goog_paQMrzFKGzuWZvcMTPkkvIsifJe'
RC_IOS_KEY = 'appl_DUPqnxuLjkBLzhBPTWeDjqNENuv'
RC_STRIPE_KEY = 'strp_YWZxWUeEfvagiefDNoofinaRCOl'
RC_OFFERING_NAME = 'test'
STRIPE_MANAGEMENT_LINK = 'https://billing.stripe.com/p/login/test_9AQaI8d3O9lmaXe5kk'
SUPPORT_SPACE_ID = '!gqSNSkvwTpgumyjLsV:staging.pangea.chat' SUPPORT_SPACE_ID = '!gqSNSkvwTpgumyjLsV:staging.pangea.chat'

@ -26,6 +26,7 @@
* Download Android File Transfer here: https://www.android.com/filetransfer/ * Download Android File Transfer here: https://www.android.com/filetransfer/
* To run the app from VSCode terminal: * To run the app from VSCode terminal:
* On web, run `flutter run -d chrome hot` * On web, run `flutter run -d chrome hot`
* Or as a web server (Usage with WSL or remote connect) `flutter run --release -d web-server -web-port=3000`
* On mobile device or simulator, run `flutter run hot -d <DEVICE_NAME>` * On mobile device or simulator, run `flutter run hot -d <DEVICE_NAME>`
# Special thanks # Special thanks

@ -1,6 +1,14 @@
BASE_API='https://api.staging.pangea.chat/api/v1'
CHOREO_API = 'https://api.staging.pangea.chat' CHOREO_API = 'https://api.staging.pangea.chat'
FRONTEND_URL='https://app.staging.pangea.chat' FRONTEND_URL = 'https://app.staging.pangea.chat'
SYNAPSE_URL = 'matrix.staging.pangea.chat' SYNAPSE_URL = 'matrix.staging.pangea.chat'
CHOREO_API_KEY = 'e6fa9fa97031ba0c852efe78457922f278a2fbc109752fe18e465337699e9873' CHOREO_API_KEY = 'e6fa9fa97031ba0c852efe78457922f278a2fbc109752fe18e465337699e9873'
SUPPORT_SPACE_ID = '!gqSNSkvwTpgumyjLsV:staging.pangea.chat'
RC_GOOGLE_KEY = 'goog_paQMrzFKGzuWZvcMTPkkvIsifJe'
RC_IOS_KEY = 'appl_DUPqnxuLjkBLzhBPTWeDjqNENuv'
RC_STRIPE_KEY = 'strp_YWZxWUeEfvagiefDNoofinaRCOl'
RC_OFFERING_NAME = 'test'
STRIPE_MANAGEMENT_LINK = 'https://billing.stripe.com/p/login/test_9AQaI8d3O9lmaXe5kk'
SUPPORT_SPACE_ID = '!gqSNSkvwTpgumyjLsV:staging.pangea.chat'

@ -46,14 +46,6 @@ class Environment {
'https://c2fd19ab2cdc4ebb939a32d01c0e9fa1@o225078.ingest.sentry.io/1376295'; 'https://c2fd19ab2cdc4ebb939a32d01c0e9fa1@o225078.ingest.sentry.io/1376295';
} }
static String get rcProjectId {
return dotenv.env["RC_PROJECT"] ?? 'a499dc21';
}
static String get rcKey {
return dotenv.env["RC_KEY"] ?? 'sk_eVGBdPyInaOfJrKlPBgFVnRynqKJB';
}
static String get rcGoogleKey { static String get rcGoogleKey {
return dotenv.env["RC_GOOGLE_KEY"] ?? 'goog_paQMrzFKGzuWZvcMTPkkvIsifJe'; return dotenv.env["RC_GOOGLE_KEY"] ?? 'goog_paQMrzFKGzuWZvcMTPkkvIsifJe';
} }

@ -21,10 +21,6 @@ class UserController extends BaseController {
/// Convenience function that returns the user ID currently stored in the client. /// Convenience function that returns the user ID currently stored in the client.
String? get userId => _pangeaController.matrixState.client.userID; String? get userId => _pangeaController.matrixState.client.userID;
/// Convenience function that returns the accessToken currently stored in the client.
String? get _matrixAccessToken =>
_pangeaController.matrixState.client.accessToken;
/// Cached version of the user profile, so it doesn't have /// Cached version of the user profile, so it doesn't have
/// to be read in from client's account data each time it is accessed. /// to be read in from client's account data each time it is accessed.
Profile? _cachedProfile; Profile? _cachedProfile;

@ -1,20 +1,18 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/sentry_flutter.dart';
class Requests { class Requests {
late String? baseUrl; late String? baseUrl;
// Matrix access token
late String? accessToken; late String? accessToken;
late String? matrixAccessToken;
late String? choreoApiKey; late String? choreoApiKey;
//Question: How can we make baseUrl optional? //Question: How can we make baseUrl optional?
Requests({ Requests({
this.accessToken, this.accessToken,
this.baseUrl = '', this.baseUrl = '',
this.matrixAccessToken,
this.choreoApiKey, this.choreoApiKey,
}); });
@ -134,9 +132,7 @@ class Requests {
}; };
if (accessToken != null) { if (accessToken != null) {
headers["Authorization"] = 'Bearer ${accessToken!}'; headers["Authorization"] = 'Bearer ${accessToken!}';
} //headers["Matrix-Access-Token"] = accessToken!;
if (matrixAccessToken != null) {
headers["Matrix-Access-Token"] = matrixAccessToken!;
} }
if (choreoApiKey != null) { if (choreoApiKey != null) {
headers['api_key'] = choreoApiKey!; headers['api_key'] = choreoApiKey!;

@ -67,12 +67,9 @@ class PApiUrls {
static String lemmaDictionary = "${PApiUrls.choreoEndpoint}/lemma_definition"; static String lemmaDictionary = "${PApiUrls.choreoEndpoint}/lemma_definition";
///-------------------------------- revenue cat -------------------------- ///-------------------------------- revenue cat --------------------------
static String rcApiV1 = "https://api.revenuecat.com/v1";
static String rcAppsChoreo = "${PApiUrls.subscriptionEndpoint}/app_ids"; static String rcAppsChoreo = "${PApiUrls.subscriptionEndpoint}/app_ids";
static String rcProductsChoreo = static String rcProductsChoreo =
"${PApiUrls.subscriptionEndpoint}/all_products"; "${PApiUrls.subscriptionEndpoint}/all_products";
static String rcSubscription = "$rcApiV1/subscribers"; static String rcSubscription = PApiUrls.subscriptionEndpoint;
} }

@ -64,16 +64,12 @@ class SubscriptionRepo {
String? userId, String? userId,
List<SubscriptionDetails>? allProducts, List<SubscriptionDetails>? allProducts,
) async { ) async {
final Map<String, String> stripeHeaders = { final Requests req = Requests(
'Content-type': 'application/json', choreoApiKey: Environment.choreoApiKey,
'Accept': 'application/json', accessToken: MatrixState.pangeaController.userController.accessToken,
'Authorization': 'Bearer ${Environment.rcStripeKey}',
};
final String url = "${PApiUrls.rcSubscription}/$userId";
final http.Response res = await http.get(
Uri.parse(url),
headers: stripeHeaders,
); );
final http.Response res = await req.get(url: PApiUrls.rcSubscription);
final Map<String, dynamic> json = jsonDecode(res.body); final Map<String, dynamic> json = jsonDecode(res.body);
final RCSubscriptionResponseModel resp = final RCSubscriptionResponseModel resp =
RCSubscriptionResponseModel.fromJson( RCSubscriptionResponseModel.fromJson(
@ -156,7 +152,7 @@ class RCSubscriptionResponseModel {
final String currentSubscriptionId = activeEntitlements[0]; final String currentSubscriptionId = activeEntitlements[0];
final Map<String, dynamic> currentSubscriptionMetadata = final Map<String, dynamic> currentSubscriptionMetadata =
json['subscriber']['subscriptions'][currentSubscriptionId]; json['subscriptions'][currentSubscriptionId];
final DateTime expirationDate = DateTime.parse( final DateTime expirationDate = DateTime.parse(
currentSubscriptionMetadata['expires_date'], currentSubscriptionMetadata['expires_date'],
@ -185,7 +181,7 @@ class RCSubscriptionResponseModel {
} }
static List<String> getActiveEntitlements(Map<String, dynamic> json) { static List<String> getActiveEntitlements(Map<String, dynamic> json) {
return json['subscriber']['entitlements'] return json['entitlements']
.entries .entries
.where( .where(
(MapEntry<String, dynamic> entitlement) => DateTime.parse( (MapEntry<String, dynamic> entitlement) => DateTime.parse(
@ -201,7 +197,7 @@ class RCSubscriptionResponseModel {
} }
static List<String> getAllEntitlements(Map<String, dynamic> json) { static List<String> getAllEntitlements(Map<String, dynamic> json) {
return json['subscriber']['entitlements'] return json['entitlements']
.entries .entries
.map( .map(
(MapEntry<String, dynamic> entitlement) => (MapEntry<String, dynamic> entitlement) =>

Loading…
Cancel
Save