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>
This commit is contained in:
parent
2c88e6038b
commit
e417af93fa
8 changed files with 31 additions and 37 deletions
8
.env
8
.env
|
|
@ -3,4 +3,12 @@ CHOREO_API = 'https://api.staging.pangea.chat'
|
|||
FRONTEND_URL='https://app.staging.pangea.chat'
|
||||
SYNAPSE_URL = 'matrix.staging.pangea.chat'
|
||||
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'
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
* Download Android File Transfer here: https://www.android.com/filetransfer/
|
||||
* To run the app from VSCode terminal:
|
||||
* 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>`
|
||||
|
||||
# Special thanks
|
||||
|
|
|
|||
14
assets/.env
14
assets/.env
|
|
@ -1,6 +1,14 @@
|
|||
BASE_API='https://api.staging.pangea.chat/api/v1'
|
||||
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'
|
||||
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';
|
||||
}
|
||||
|
||||
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 {
|
||||
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.
|
||||
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
|
||||
/// to be read in from client's account data each time it is accessed.
|
||||
Profile? _cachedProfile;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
class Requests {
|
||||
late String? baseUrl;
|
||||
// Matrix access token
|
||||
late String? accessToken;
|
||||
late String? matrixAccessToken;
|
||||
late String? choreoApiKey;
|
||||
//Question: How can we make baseUrl optional?
|
||||
Requests({
|
||||
this.accessToken,
|
||||
this.baseUrl = '',
|
||||
this.matrixAccessToken,
|
||||
this.choreoApiKey,
|
||||
});
|
||||
|
||||
|
|
@ -134,9 +132,7 @@ class Requests {
|
|||
};
|
||||
if (accessToken != null) {
|
||||
headers["Authorization"] = 'Bearer ${accessToken!}';
|
||||
}
|
||||
if (matrixAccessToken != null) {
|
||||
headers["Matrix-Access-Token"] = matrixAccessToken!;
|
||||
//headers["Matrix-Access-Token"] = accessToken!;
|
||||
}
|
||||
if (choreoApiKey != null) {
|
||||
headers['api_key'] = choreoApiKey!;
|
||||
|
|
|
|||
|
|
@ -67,12 +67,9 @@ class PApiUrls {
|
|||
static String lemmaDictionary = "${PApiUrls.choreoEndpoint}/lemma_definition";
|
||||
|
||||
///-------------------------------- revenue cat --------------------------
|
||||
|
||||
static String rcApiV1 = "https://api.revenuecat.com/v1";
|
||||
|
||||
static String rcAppsChoreo = "${PApiUrls.subscriptionEndpoint}/app_ids";
|
||||
static String rcProductsChoreo =
|
||||
"${PApiUrls.subscriptionEndpoint}/all_products";
|
||||
|
||||
static String rcSubscription = "$rcApiV1/subscribers";
|
||||
static String rcSubscription = PApiUrls.subscriptionEndpoint;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,16 +64,12 @@ class SubscriptionRepo {
|
|||
String? userId,
|
||||
List<SubscriptionDetails>? allProducts,
|
||||
) async {
|
||||
final Map<String, String> stripeHeaders = {
|
||||
'Content-type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'Authorization': 'Bearer ${Environment.rcStripeKey}',
|
||||
};
|
||||
final String url = "${PApiUrls.rcSubscription}/$userId";
|
||||
final http.Response res = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: stripeHeaders,
|
||||
final Requests req = Requests(
|
||||
choreoApiKey: Environment.choreoApiKey,
|
||||
accessToken: MatrixState.pangeaController.userController.accessToken,
|
||||
);
|
||||
|
||||
final http.Response res = await req.get(url: PApiUrls.rcSubscription);
|
||||
final Map<String, dynamic> json = jsonDecode(res.body);
|
||||
final RCSubscriptionResponseModel resp =
|
||||
RCSubscriptionResponseModel.fromJson(
|
||||
|
|
@ -156,7 +152,7 @@ class RCSubscriptionResponseModel {
|
|||
final String currentSubscriptionId = activeEntitlements[0];
|
||||
|
||||
final Map<String, dynamic> currentSubscriptionMetadata =
|
||||
json['subscriber']['subscriptions'][currentSubscriptionId];
|
||||
json['subscriptions'][currentSubscriptionId];
|
||||
|
||||
final DateTime expirationDate = DateTime.parse(
|
||||
currentSubscriptionMetadata['expires_date'],
|
||||
|
|
@ -185,7 +181,7 @@ class RCSubscriptionResponseModel {
|
|||
}
|
||||
|
||||
static List<String> getActiveEntitlements(Map<String, dynamic> json) {
|
||||
return json['subscriber']['entitlements']
|
||||
return json['entitlements']
|
||||
.entries
|
||||
.where(
|
||||
(MapEntry<String, dynamic> entitlement) => DateTime.parse(
|
||||
|
|
@ -201,7 +197,7 @@ class RCSubscriptionResponseModel {
|
|||
}
|
||||
|
||||
static List<String> getAllEntitlements(Map<String, dynamic> json) {
|
||||
return json['subscriber']['entitlements']
|
||||
return json['entitlements']
|
||||
.entries
|
||||
.map(
|
||||
(MapEntry<String, dynamic> entitlement) =>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue