提交 a2d88e8b authored 作者: JarvanMo's avatar JarvanMo

optimize API

上级 d8028d7c
......@@ -35,7 +35,7 @@ class _MyAppState extends State<MyApp> {
}
_initFluwx() async {
await fluwx.registerWxApi(
await fluwx.registerApi(
appId: 'wxd930ea5d5a258f4f',
doOnAndroid: true,
doOnIOS: true,
......@@ -205,7 +205,7 @@ class ShareSelectorPage extends StatelessWidget {
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: () {
fluwx.open(OpenWeChat());
fluwx.open(WeChatApp());
},
child: const Text('Open WeChat App'),
),
......
......@@ -24,8 +24,7 @@
library fluwx;
export 'src/fluwx.dart';
export 'src/foundation/arguments.dart';
export 'src/response/wechat_response.dart';
export 'src/share/share_models.dart';
export 'src/wechat_enums.dart';
export 'src/open_command.dart';
export 'src/wechat_file.dart' hide FileSchema;
......@@ -19,198 +19,87 @@
import 'dart:async';
import '../fluwx.dart';
import 'foundation/arguments.dart';
import 'method_channel/fluwx_platform_interface.dart';
import 'response/wechat_response.dart';
class Fluwx {
late final WeakReference<void Function(WeChatResponse event)>
responseListener;
final List<Function(WeChatResponse response)> _responseListeners = [];
Fluwx() {
FluwxPlatform.instance.responseEventHandler.listen((event) {
responseListener = WeakReference((event) {
for (var listener in _responseListeners) {
listener(event);
}
});
final target = responseListener.target;
if (target != null) {
FluwxPlatform.instance.responseEventHandler.listen(target);
}
}
Future<bool> get isWeChatInstalled =>
FluwxPlatform.instance.isWeChatInstalled;
Future<bool> open(OpenCommand what) {
return FluwxPlatform.instance.open(what);
/// Open given target. See [OpenType] for more details
Future<bool> open({required OpenType target}) {
return FluwxPlatform.instance.open(target);
}
Future<bool> registerWxApi({
/// It's ok if you register multi times.
/// [appId] is not necessary.
/// if [doOnIOS] is true ,fluwx will register WXApi on iOS.
/// if [doOnAndroid] is true, fluwx will register WXApi on Android.
/// [universalLink] is required if you want to register on iOS.
Future<bool> registerApi({
required String appId,
bool doOnIOS = true,
bool doOnAndroid = true,
String? universalLink,
}) async {
return FluwxPlatform.instance.registerWxApi(
return FluwxPlatform.instance.registerApi(
appId: appId,
doOnAndroid: doOnAndroid,
doOnIOS: doOnIOS,
universalLink: universalLink);
}
/// Share your requests to WeChat.
/// This depends on the actual type of [what].
Future<bool> share(WeChatShareModel what) async {
return FluwxPlatform.instance.share(what);
}
Future<bool> sendAuth(
{required String scope,
String state = 'state',
bool nonAutomatic = false}) async {
return FluwxPlatform.instance
.sendAuth(scope: scope, nonAutomatic: nonAutomatic);
}
Future<bool> subscribeMsg({
required String appId,
required int scene,
required String templateId,
String? reserved,
}) async {
return FluwxPlatform.instance.subscribeMsg(
appId: appId, scene: scene, templateId: templateId, reserved: reserved);
}
Future<bool> autoDeDuct({
required String appId,
required String mchId,
required String planId,
required String contractCode,
required String requestSerial,
required String contractDisplayAccount,
required String notifyUrl,
required String version,
required String sign,
required String timestamp,
String returnApp = '3',
int businessType = 12,
}) async {
return FluwxPlatform.instance.autoDeDuct(
appId: appId,
mchId: mchId,
planId: planId,
contractCode: contractCode,
requestSerial: requestSerial,
contractDisplayAccount: contractDisplayAccount,
notifyUrl: notifyUrl,
version: version,
sign: sign,
timestamp: timestamp,
returnApp: returnApp,
businessType: businessType);
}
Future<bool> autoDeductV2(
Map<String, String> queryInfo, {
int businessType = 12,
}) async {
return FluwxPlatform.instance.autoDeductV2(queryInfo, businessType: 12);
/// Login by WeChat.See [AuthType] for more details.
Future<bool> authBy({required AuthType which}) async {
return FluwxPlatform.instance.authBy(which);
}
Future<bool> authByQRCode({
required String appId,
required String scope,
required String nonceStr,
required String timestamp,
required String signature,
String? schemeData,
}) async {
return FluwxPlatform.instance.authByQRCode(
appId: appId,
scope: scope,
nonceStr: nonceStr,
timestamp: timestamp,
signature: signature,
schemeData: schemeData);
/// please read * [official docs](https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_2.shtml).
Future<bool> autoDeduct({required AutoDeduct data}) async {
return FluwxPlatform.instance.autoDeduct(data);
}
/// IOS only
Future<bool> authByPhoneLogin({
required String scope,
String state = 'state',
}) async {
return FluwxPlatform.instance.authByPhoneLogin(scope: scope, state: state);
}
Future<bool> openCustomerServiceChat(
{required String url, required String corpId}) async {
return await FluwxPlatform.instance
.openCustomerServiceChat(url: url, corpId: corpId);
}
/// see * https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter6_2_1.shtml
Future<bool> openBusinessView(
{required String businessType, required String query}) async {
return await FluwxPlatform.instance
.openBusinessView(businessType: businessType, query: query);
}
Future<bool> checkSupportOpenBusinessView() async {
return await FluwxPlatform.instance.checkSupportOpenBusinessView();
}
Future<bool> openInvoice(
{required String appId,
required String cardType,
String locationId = "",
String cardId = "",
String canMultiSelect = "1"}) async {
return FluwxPlatform.instance.openInvoice(
appId: appId,
cardType: cardType,
locationId: locationId,
cardId: cardId,
canMultiSelect: canMultiSelect);
}
Future launchMiniProgram({
required String username,
String? path,
WXMiniProgramType miniProgramType = WXMiniProgramType.release,
}) async {
return FluwxPlatform.instance.launchMiniProgram(
username: username, path: path, miniProgramType: miniProgramType);
}
Future<bool> get isSupportOpenBusinessView async =>
await FluwxPlatform.instance.isSupportOpenBusinessView;
Future<String?> getExtMsg() async {
return FluwxPlatform.instance.getExtMsg();
}
Future<bool> pay({
required String appId,
required String partnerId,
required String prepayId,
required String packageValue,
required String nonceStr,
required int timestamp,
required String sign,
String? signType,
String? extData,
}) async {
return FluwxPlatform.instance.pay(
appId: appId,
partnerId: partnerId,
prepayId: prepayId,
packageValue: packageValue,
nonceStr: nonceStr,
timestamp: timestamp,
sign: sign,
signType: signType,
extData: extData);
}
Future<bool> payWithHongKongWallet({required String prepayId}) async {
return FluwxPlatform.instance.payWithHongKongWallet(prepayId: prepayId);
Future<bool> pay({required PayType which}) async {
return FluwxPlatform.instance.pay(which);
}
/// Subscribe responses from WeChat
subscribeResponse(Function(WeChatResponse response) listener) {
_responseListeners.add(listener);
}
/// Unsubscribe responses from WeChat
unsubscribeResponse(Function(WeChatResponse response) listener) {
_responseListeners.remove(listener);
}
......
/*
* Copyright (c) 2023. OpenFlutter Project
*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor
* license agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership. The ASF licenses this
* file to you under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import '../wechat_enums.dart';
import '../wechat_file.dart';
part 'auth_type.dart';
part 'auto_deduct.dart';
part 'open_type.dart';
part 'pay_type.dart';
part 'share_models.dart';
mixin _Argument {
Map<String, dynamic> get arguments => {};
}
part of 'arguments.dart';
sealed class AuthType with _Argument {}
/// The WeChat-Login is under Auth-2.0
/// This method login with native WeChat app.
/// For users without WeChat app, please use [QRCode] instead
/// This method only supports getting AuthCode,this is first step to login with WeChat
/// Once AuthCode got, you need to request Access_Token
/// For more information please visit:
/// * https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317851&token=
class NormalAuth extends AuthType {
final String scope;
final String state;
final bool nonAutomatic;
NormalAuth(
{required this.scope, this.state = 'state', this.nonAutomatic = false})
: assert(scope.trim().isNotEmpty);
@override
Map<String, dynamic> get arguments =>
{'scope': scope, 'state': state, 'nonAutomatic': nonAutomatic};
}
/// Sometimes WeChat is not installed on users's devices.However we can
/// request a QRCode so that we can get AuthCode by scanning the QRCode
/// All required params must not be null or empty
/// [schemeData] only works on iOS
/// see * https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=215238808828h4XN&token=&lang=zh_CN
class QRCode extends AuthType {
final String appId;
final String scope;
final String nonceStr;
final String timestamp;
final String signature;
final String? schemeData;
QRCode({
required this.appId,
required this.scope,
required this.nonceStr,
required this.timestamp,
required this.signature,
this.schemeData,
}) : assert(appId.isNotEmpty),
assert(scope.isNotEmpty),
assert(nonceStr.isNotEmpty),
assert(timestamp.isNotEmpty),
assert(signature.isNotEmpty);
@override
Map<String, dynamic> get arguments => {
'appId': appId,
'scope': scope,
'nonceStr': nonceStr,
'timeStamp': timestamp,
'signature': signature,
'schemeData': schemeData
};
}
/// Currently only support iOS
class PhoneLogin extends AuthType {
final String scope;
final String state;
PhoneLogin({
required this.scope,
this.state = 'state',
});
@override
Map<String, dynamic> get arguments => {'scope': scope, 'state': state};
}
part of 'arguments.dart';
class AutoDeduct with _Argument {
final Map<String, String> queryInfo;
final int businessType;
final Map<String, dynamic> _detailData;
bool get isV2 => _detailData.isEmpty;
AutoDeduct.detail({
required String appId,
required String mchId,
required String planId,
required String contractCode,
required String requestSerial,
required String contractDisplayAccount,
required String notifyUrl,
required String version,
required String sign,
required String timestamp,
String returnApp = '3',
this.businessType = 12,
}) : queryInfo = {},
_detailData = {
'appid': appId,
'mch_id': mchId,
'plan_id': planId,
'contract_code': contractCode,
'request_serial': requestSerial,
'contract_display_account': contractDisplayAccount,
'notify_url': notifyUrl,
'version': version,
'sign': sign,
'timestamp': timestamp,
'return_app': returnApp,
'businessType': businessType
};
AutoDeduct.custom({required this.queryInfo, this.businessType = 12})
: _detailData = {};
@override
Map<String, dynamic> get arguments => isV2
? {'queryInfo': queryInfo, 'businessType': businessType}
: _detailData;
}
part of 'arguments.dart';
sealed class OpenType with _Argument {}
/// Just open WeChat app.
class WeChatApp extends OpenType {}
/// Open WeChat browser with given url.
class Browser extends OpenType {
final String url;
Browser(this.url);
@override
Map<String, dynamic> get arguments => {'url': url};
}
class RankList extends OpenType {}
/// see * https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter6_2_1.shtml
class BusinessView extends OpenType {
final String businessType;
final String query;
BusinessView({required this.businessType, required this.query});
@override
Map<String, dynamic> get arguments =>
{"businessType": businessType, "query": query};
}
class Invoice extends OpenType {
final String appId;
final String cardType;
final String locationId;
final String cardId;
final String canMultiSelect;
Invoice(
{required this.appId,
required this.cardType,
this.locationId = "",
this.cardId = "",
this.canMultiSelect = "1"});
@override
Map<String, dynamic> get arguments => {
"appId": appId,
"cardType": cardType,
"locationId": locationId,
"cardId": cardId,
"canMultiSelect": canMultiSelect
};
}
class CustomerServiceChat extends OpenType {
final String corpId;
final String url;
CustomerServiceChat({required this.corpId, required this.url});
@override
Map<String, dynamic> get arguments => {"corpId": corpId, "url": url};
}
/// open mini-program
/// see [WXMiniProgramType]
class MiniProgram extends OpenType {
final String username;
final String? path;
final WXMiniProgramType miniProgramType;
MiniProgram({
required this.username,
this.path,
this.miniProgramType = WXMiniProgramType.release,
}) : assert(username.trim().isNotEmpty);
@override
Map<String, dynamic> get arguments => {
'userName': username,
'path': path,
'miniProgramType': miniProgramType.value
};
}
/// See *https://developers.weixin.qq.com/doc/oplatform/Mobile_App/One-time_subscription_info.html for more detail
class SubscribeMessage extends OpenType {
final String appId;
final int scene;
final String templateId;
final String? reserved;
SubscribeMessage({
required this.appId,
required this.scene,
required this.templateId,
this.reserved,
});
@override
Map<String, dynamic> get arguments => {
'appId': appId,
'scene': scene,
'templateId': templateId,
'reserved': reserved,
};
}
part of 'arguments.dart';
sealed class PayType with _Argument {}
/// request payment with WeChat.
/// Read the official document for more detail.
/// [timestamp] is int because [timestamp] will be mapped to Unit32.
class Payment extends PayType {
final String appId;
final String partnerId;
final String prepayId;
final String packageValue;
final String nonceStr;
final int timestamp;
final String sign;
final String? signType;
final String? extData;
Payment({
required this.appId,
required this.partnerId,
required this.prepayId,
required this.packageValue,
required this.nonceStr,
required this.timestamp,
required this.sign,
this.signType,
this.extData,
});
@override
Map<String, dynamic> get arguments => {
'appId': appId,
'partnerId': partnerId,
'prepayId': prepayId,
'packageValue': packageValue,
'nonceStr': nonceStr,
'timeStamp': timestamp,
'sign': sign,
'signType': signType,
'extData': extData,
};
}
/// request Hong Kong Wallet payment with WeChat.
/// Read the official document for more detail.
class HongKongWallet extends PayType {
final String prepayId;
HongKongWallet({required this.prepayId});
@override
Map<String, dynamic> get arguments => {
'prepayId': prepayId,
};
}
......@@ -17,7 +17,7 @@
* the License.
*/
import 'package:fluwx/fluwx.dart';
part of 'arguments.dart';
const String _scene = "scene";
const String _source = "source";
......@@ -30,9 +30,7 @@ const String _messageAction = "messageAction";
const String _compressThumbnail = "compressThumbnail";
const String _msgSignature = "msgSignature";
sealed class WeChatShareModel {
Map<String, dynamic> toMap();
}
sealed class WeChatShareModel with _Argument {}
/// [source] the text you want to send to WeChat
/// [scene] the target you want to send
......@@ -59,18 +57,16 @@ class WeChatShareTextModel extends WeChatShareModel {
final String? msgSignature;
@override
Map<String, dynamic> toMap() {
return {
_scene: scene.index,
_source: source,
_messageExt: messageExt,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_title: title,
_description: description,
_msgSignature: msgSignature
};
}
Map<String, dynamic> get arguments => {
_scene: scene.index,
_source: source,
_messageExt: messageExt,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_title: title,
_description: description,
_msgSignature: msgSignature
};
}
/// the default value is [MINI_PROGRAM_TYPE_RELEASE]
......@@ -112,23 +108,21 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
final String? msgSignature;
@override
Map<String, dynamic> toMap() {
return {
'webPageUrl': webPageUrl,
"miniProgramType": miniProgramType.value,
"userName": userName,
"path": path,
"title": title,
_description: description,
"withShareTicket": withShareTicket,
_thumbnail: thumbnail.toMap(),
"hdImagePath": hdImagePath?.toMap(),
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
Map<String, dynamic> get arguments => {
'webPageUrl': webPageUrl,
"miniProgramType": miniProgramType.value,
"userName": userName,
"path": path,
"title": title,
_description: description,
"withShareTicket": withShareTicket,
_thumbnail: thumbnail.toMap(),
"hdImagePath": hdImagePath?.toMap(),
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
/// [source] the image you want to send to WeChat
......@@ -159,19 +153,17 @@ class WeChatShareImageModel extends WeChatShareModel {
final String? msgSignature;
@override
Map<String, dynamic> toMap() {
return {
_scene: scene.index,
_source: source.toMap(),
_thumbnail: thumbnail.toMap(),
_title: title,
_description: description,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
Map<String, dynamic> get arguments => {
_scene: scene.index,
_source: source.toMap(),
_thumbnail: thumbnail.toMap(),
_title: title,
_description: description,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
/// if [musicUrl] and [musicLowBandUrl] are both provided,
......@@ -208,22 +200,20 @@ class WeChatShareMusicModel extends WeChatShareModel {
final String? msgSignature;
@override
Map<String, dynamic> toMap() {
return {
_scene: scene.index,
"musicUrl": musicUrl,
"musicDataUrl": musicDataUrl,
"musicLowBandUrl": musicLowBandUrl,
"musicLowBandDataUrl": musicLowBandDataUrl,
_thumbnail: thumbnail?.toMap(),
_title: title,
_description: description,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
Map<String, dynamic> get arguments => {
_scene: scene.index,
"musicUrl": musicUrl,
"musicDataUrl": musicDataUrl,
"musicLowBandUrl": musicLowBandUrl,
"musicLowBandDataUrl": musicLowBandDataUrl,
_thumbnail: thumbnail?.toMap(),
_title: title,
_description: description,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
/// if [videoUrl] and [videoLowBandUrl] are both provided,
......@@ -257,20 +247,18 @@ class WeChatShareVideoModel extends WeChatShareModel {
final String? msgSignature;
@override
Map<String, dynamic> toMap() {
return {
_scene: scene.index,
"videoUrl": videoUrl,
"videoLowBandUrl": videoLowBandUrl,
_thumbnail: thumbnail?.toMap(),
_title: title,
_description: description,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
Map<String, dynamic> get arguments => {
_scene: scene.index,
"videoUrl": videoUrl,
"videoLowBandUrl": videoLowBandUrl,
_thumbnail: thumbnail?.toMap(),
_title: title,
_description: description,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
/// [webPage] url you want to send to wechat
......@@ -302,19 +290,17 @@ class WeChatShareWebPageModel extends WeChatShareModel {
final String? msgSignature;
@override
Map<String, dynamic> toMap() {
return {
_scene: scene.index,
"webPage": webPage,
_thumbnail: thumbnail?.toMap(),
_title: title,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_description: description,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
Map<String, dynamic> get arguments => {
_scene: scene.index,
"webPage": webPage,
_thumbnail: thumbnail?.toMap(),
_title: title,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_description: description,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
/// [source] the file you want to share, [source.suffix] is necessary on iOS.
......@@ -346,17 +332,15 @@ class WeChatShareFileModel extends WeChatShareModel {
final String? msgSignature;
@override
Map<String, dynamic> toMap() {
return {
_scene: scene.index,
_source: source.toMap(),
_thumbnail: thumbnail?.toMap(),
_title: title,
_description: description,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
Map<String, dynamic> get arguments => {
_scene: scene.index,
_source: source.toMap(),
_thumbnail: thumbnail?.toMap(),
_title: title,
_description: description,
_messageAction: messageAction,
_mediaTagName: mediaTagName,
_compressThumbnail: compressThumbnail,
_msgSignature: msgSignature
};
}
......@@ -50,11 +50,11 @@ abstract class FluwxPlatform extends PlatformInterface {
throw UnimplementedError('isWeChatInstalled has not been implemented.');
}
Future<bool> open(OpenCommand what) {
Future<bool> open(OpenType target) {
throw UnimplementedError('open() has not been implemented.');
}
Future<bool> registerWxApi({
Future<bool> registerApi({
required String appId,
bool doOnIOS = true,
bool doOnAndroid = true,
......@@ -96,93 +96,25 @@ abstract class FluwxPlatform extends PlatformInterface {
throw UnimplementedError('authByQRCode() has not been implemented.');
}
Future<bool> stopWeChatAuthByQRCode() async {
Future<bool> stopAuthByQRCode() async {
throw UnimplementedError(
'stopWeChatAuthByQRCode() has not been implemented.');
}
Future<bool> launchMiniProgram({
required String username,
String? path,
WXMiniProgramType miniProgramType = WXMiniProgramType.release,
}) {
throw UnimplementedError('launchMiniProgram() has not been implemented.');
}
Future<bool> pay({
required String appId,
required String partnerId,
required String prepayId,
required String packageValue,
required String nonceStr,
required int timestamp,
required String sign,
String? signType,
String? extData,
}) {
Future<bool> pay(PayType which) {
throw UnimplementedError('pay() has not been implemented.');
}
Future<bool> payWithHongKongWallet({required String prepayId}) async {
throw UnimplementedError(
'payWithHongKongWallet() has not been implemented.');
}
Future<bool> subscribeMsg({
required String appId,
required int scene,
required String templateId,
String? reserved,
}) async {
throw UnimplementedError('subscribeWeChatMsg() has not been implemented.');
}
Future<bool> autoDeDuct({
required String appId,
required String mchId,
required String planId,
required String contractCode,
required String requestSerial,
required String contractDisplayAccount,
required String notifyUrl,
required String version,
required String sign,
required String timestamp,
String returnApp = '3',
int businessType = 12,
}) async {
throw UnimplementedError('autoDeDuct() has not been implemented.');
}
Future<bool> autoDeductV2(
Map<String, String> queryInfo, {
int businessType = 12,
}) async {
throw UnimplementedError('autoDeductV2() has not been implemented.');
}
Future<bool> openCustomerServiceChat(
{required String url, required String corpId}) {
throw UnimplementedError(
'openCustomerServiceChat() has not been implemented.');
Future<bool> autoDeduct(AutoDeduct data) {
throw UnimplementedError('autoDeduct() has not been implemented.');
}
Future<bool> openBusinessView(
{required String businessType, required String query}) async {
throw UnimplementedError('openBusinessView() has not been implemented.');
Future<bool> authBy(AuthType which) {
throw UnimplementedError('authBy() has not been implemented.');
}
Future<bool> checkSupportOpenBusinessView() async {
Future<bool> get isSupportOpenBusinessView async {
throw UnimplementedError(
'checkSupportOpenBusinessView() has not been implemented.');
}
Future<bool> openInvoice(
{required String appId,
required String cardType,
String locationId = "",
String cardId = "",
String canMultiSelect = "1"}) async {
throw UnimplementedError('openInvoice() has not been implemented.');
'isSupportOpenBusinessView() has not been implemented.');
}
}
sealed class OpenCommand {}
class OpenWeChat extends OpenCommand {}
class OpenUrl extends OpenCommand {
final String url;
OpenUrl(this.url);
}
class OpenRankList extends OpenCommand {}
......@@ -7,55 +7,6 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart';
class MockFluwxPlatform
with MockPlatformInterfaceMixin
implements FluwxPlatform {
@override
Future<bool> authByPhoneLogin(
{required String scope, String state = 'state'}) {
// TODO: implement authByPhoneLogin
throw UnimplementedError();
}
@override
Future<bool> authByQRCode(
{required String appId,
required String scope,
required String nonceStr,
required String timestamp,
required String signature,
String? schemeData}) {
// TODO: implement authByQRCode
throw UnimplementedError();
}
@override
Future<bool> autoDeDuct(
{required String appId,
required String mchId,
required String planId,
required String contractCode,
required String requestSerial,
required String contractDisplayAccount,
required String notifyUrl,
required String version,
required String sign,
required String timestamp,
String returnApp = '3',
int businessType = 12}) {
// TODO: implement autoDeDuct
throw UnimplementedError();
}
@override
Future<bool> autoDeductV2(Map<String, String> queryInfo,
{int businessType = 12}) {
// TODO: implement autoDeductV2
throw UnimplementedError();
}
@override
Future<bool> checkSupportOpenBusinessView() {
// TODO: implement checkSupportOpenBusinessView
throw UnimplementedError();
}
@override
Future<String?> getExtMsg() {
......@@ -67,108 +18,75 @@ class MockFluwxPlatform
Future<bool> get isWeChatInstalled => Future.value(false);
@override
Future<bool> launchMiniProgram(
{required String username,
String? path,
WXMiniProgramType miniProgramType = WXMiniProgramType.release}) {
// TODO: implement launchMiniProgram
throw UnimplementedError();
}
@override
Future<bool> openBusinessView(
{required String businessType, required String query}) {
// TODO: implement openBusinessView
Future<bool> registerApi(
{required String appId,
bool doOnIOS = true,
bool doOnAndroid = true,
String? universalLink}) {
// TODO: implement registerWxApi
throw UnimplementedError();
}
@override
Future<bool> openCustomerServiceChat(
{required String url, required String corpId}) {
// TODO: implement openCustomerServiceChat
Future<bool> sendAuth(
{required String scope,
String state = 'state',
bool nonAutomatic = false}) {
// TODO: implement sendAuth
throw UnimplementedError();
}
@override
Future<bool> openInvoice(
{required String appId,
required String cardType,
String locationId = "",
String cardId = "",
String canMultiSelect = "1"}) {
// TODO: implement openInvoice
Future<bool> share(WeChatShareModel what) {
// TODO: implement share
throw UnimplementedError();
}
@override
Future<bool> pay(
{required String appId,
required String partnerId,
required String prepayId,
required String packageValue,
required String nonceStr,
required int timestamp,
required String sign,
String? signType,
String? extData}) {
// TODO: implement pay
Future<bool> stopAuthByQRCode() {
// TODO: implement stopWeChatAuthByQRCode
throw UnimplementedError();
}
@override
Future<bool> payWithHongKongWallet({required String prepayId}) {
// TODO: implement payWithHongKongWallet
throw UnimplementedError();
}
Stream<WeChatResponse> get responseEventHandler => throw UnimplementedError();
@override
Future<bool> registerWxApi(
{required String appId,
bool doOnIOS = true,
bool doOnAndroid = true,
String? universalLink}) {
// TODO: implement registerWxApi
Future<bool> open(OpenType target) {
throw UnimplementedError();
}
@override
Future<bool> sendAuth(
{required String scope,
String state = 'state',
bool nonAutomatic = false}) {
// TODO: implement sendAuth
Future<bool> authBy(AuthType which) {
// TODO: implement authBy
throw UnimplementedError();
}
@override
Future<bool> share(WeChatShareModel what) {
// TODO: implement share
Future<bool> authByPhoneLogin({required String scope, String state = 'state'}) {
// TODO: implement authByPhoneLogin
throw UnimplementedError();
}
@override
Future<bool> stopWeChatAuthByQRCode() {
// TODO: implement stopWeChatAuthByQRCode
Future<bool> authByQRCode({required String appId, required String scope, required String nonceStr, required String timestamp, required String signature, String? schemeData}) {
// TODO: implement authByQRCode
throw UnimplementedError();
}
@override
Future<bool> subscribeMsg(
{required String appId,
required int scene,
required String templateId,
String? reserved}) {
// TODO: implement subscribeMsg
Future<bool> autoDeduct(AutoDeduct data) {
// TODO: implement autoDeduct
throw UnimplementedError();
}
@override
// TODO: implement responseEventHandler
Stream<WeChatResponse> get responseEventHandler => throw UnimplementedError();
// TODO: implement isSupportOpenBusinessView
Future<bool> get isSupportOpenBusinessView => throw UnimplementedError();
@override
Future<bool> open(OpenCommand what) {
// TODO: implement open
Future<bool> pay(PayType which) {
// TODO: implement pay
throw UnimplementedError();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论