Files
wechat_kit/example/lib/api/model/wechat_user_info_resp.dart
2021-07-21 11:09:19 +08:00

48 lines
1.1 KiB
Dart
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:json_annotation/json_annotation.dart';
import 'package:wechat_kit_example/api/model/wechat_api_resp.dart';
part 'wechat_user_info_resp.g.dart';
@JsonSerializable(
explicitToJson: true,
fieldRename: FieldRename.snake,
)
class WechatUserInfoResp extends WechatApiResp {
const WechatUserInfoResp({
required int errcode,
String? errmsg,
this.openid,
this.nickname,
this.sex,
this.province,
this.city,
this.country,
this.headimgurl,
this.privilege,
this.unionid,
}) : super(
errcode: errcode,
errmsg: errmsg,
);
factory WechatUserInfoResp.fromJson(Map<String, dynamic> json) =>
_$WechatUserInfoRespFromJson(json);
final String? openid;
final String? nickname;
final int? sex; // 1为男性2为女性
final String? province;
final String? city;
final String? country;
final String? headimgurl;
final List<dynamic>? privilege;
final String? unionid;
bool get isMale => sex == 1;
bool get isFemale => sex == 2;
@override
Map<String, dynamic> toJson() => _$WechatUserInfoRespToJson(this);
}