guru_sdk/guru_app/lib/api/modules/guru_api_extension.dart

54 lines
2.0 KiB
Dart

/// Created by Haoyi on 6/4/21
///
part of "../guru_api.dart";
extension GuruApiExtension on GuruApi {
// Future<GuruUser> signInWithAnonymous({required String secret}) async {
// return await methods.signInWithAnonymous(AnonymousLoginReqBody(secret: secret));
// }
Future<GuruUser> loginGuruWithCredential({required Credential credential}) async {
switch (credential.authType) {
case AuthType.facebook:
return await methods
.signInWithFacebook(FacebookLoginReqBody(accessToken: credential.token));
case AuthType.google:
return await methods.signInWithGoogle(GoogleLoginReqBody(idToken: credential.token));
case AuthType.apple:
return await methods.signInWithApple(AppleLoginReqBody(token: credential.token));
case AuthType.anonymous:
return await methods.signInWithAnonymous(AnonymousLoginReqBody(secret: credential.token));
}
}
Future<GuruUser> associateCredential({required Credential credential}) async {
switch (credential.authType) {
case AuthType.facebook:
return await methods
.associateWithFacebook(FacebookLoginReqBody(accessToken: credential.token));
case AuthType.google:
return await methods.associateWithGoogle(GoogleLoginReqBody(idToken: credential.token));
case AuthType.apple:
return await methods.associateWithApple(AppleLoginReqBody(token: credential.token));
case AuthType.anonymous:
return await methods.signInWithAnonymous(AnonymousLoginReqBody(secret: credential.token));
}
}
Future reportDevice(DeviceInfo deviceInfo) async {
return await methods.reportDevice(deviceInfo);
}
Future<FirebaseTokenData> renewFirebaseToken() async {
return await methods.renewFirebaseToken();
}
Future<OrdersResponse> reportOrders(OrdersReport body) async {
if (Platform.isAndroid) {
return await methods.androidOrdersReport(body);
} else {
return await methods.iOSOrdersReport(body);
}
}
}