先定义数据类型:

unit rtcMW.Wechat.Types;

interface

uses Generics.Collections, Rest.Json, System.Json.SerializeHelper, System.Json.Types, System.Json.Serializers;

type
TWechatTag = class
Id: Integer;
Name: string;
Count: Integer;
end; TWechatIndustryInfo = record
public
[JsonName('first_class')]
FirstClass: string; [JsonName('second_class')]
SecondClass: string;
end; TWechatIndustryItem = record
public
[JsonName('primary_industry')]
PrimaryIndustry: TWechatIndustryInfo; [JsonName('secondary_industry')]
SecondaryIndustry: TWechatIndustryInfo;
end; TWechatArticle = record
public
[JsonName('title')]
Title: string; [JsonName('description')]
Description: string; [JsonName('url')]
URL: string; [JsonName('picurl')]
PicURL: string;
end; TWechatTags = TArray<TWechatTag>;
TWechatIPList = TArray<string>;
TWechatOpenIdList = TArray<string>;
TWechatQRCodeType = (QR_SCENE, QR_LIMIT_SCENE);
TWechatBlacklistAction = (baAdd, baRemove);
TWechatTagAction = (taAdd, taRemove);
TWechatHeadImageSize = (hi46, hi64, hi96, hi132, hi640);
TWechatMediaType = (mtImage, mtVoice, mtVideo, mtThumb);
TWechatMessageType = (mtCustomMessage, mtTemplateMessage); TWechatUser = class; TWechatUsers = TArray<TWechatUser>;
TWechatUserType = (utNormal, utBlocked); // https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839
[JsonSerialize(TJsonMemberSerialization.&Public)]
TWechatUser = class
private
FCountry: string;
FCity: string;
FProvince: string;
FGroupID: Integer;
FGropName: string;
FHeadimgURL: string;
FLanguage: string;
FName: string;
FOpenid: string;
FQRScene: Integer;
FQRSceneStr: string;
FRemark: string;
FSex: Integer;
FSubscribe: Integer;
FSubscribeScene: string;
FSubscribeTime: int64;
FTagidList: TArray<Integer>;
FUnionID: string;
FAccountID: int64;
FUserid: int64;
FBlocked: Byte;
public
[JsonName('country')]
property Country: string read FCountry write FCountry; [JsonName('province')]
property Province: string read FProvince write FProvince; [JsonName('city')]
property City: string read FCity write FCity; [JsonName('groupid')]
property GroupID: Integer read FGroupID write FGroupID; [JsonName('headimgurl')]
property HeadimgURL: string read FHeadimgURL write FHeadimgURL; [JsonName('language')]
property Language: string read FLanguage write FLanguage; [JsonName('nickname')]
property NickName: string read FName write FName; [JsonName('openid')]
property OpenID: String read FOpenid write FOpenid; [JsonName('qr_scene')]
property QRScene: Integer read FQRScene write FQRScene; [JsonName('qr_scene_str')]
property QRSceneStr: string read FQRSceneStr write FQRSceneStr; [JsonName('remark')]
property Remark: string read FRemark write FRemark; [JsonName('sex')]
property Sex: Integer read FSex write FSex; [JsonName('subscribe')]
property Subscribe: Integer read FSubscribe write FSubscribe; [JsonName('subscribe_scene')]
property SubscribeScene: String read FSubscribeScene write FSubscribeScene; [JsonName('subscribe_time')]
property SubscribeTime: int64 read FSubscribeTime write FSubscribeTime; [JsonName('tagid_list')]
property TagIDList: TArray<Integer> read FTagidList write FTagidList; [JsonName('unionid')]
property UnionID: string read FUnionID write FUnionID; [JsonName('account_id')]
property AccountID: int64 read FAccountID write FAccountID; [JsonName('userid')]
property UserID: int64 read FUserid write FUserid; [JsonName('blocked')]
property Blocked: Byte read FBlocked write FBlocked; [JsonName('group_name')]
property GroupName: string read FGropName write FGropName; function ToJsonString: string;
class function FromJsonString(const AJsonString: string): TWechatUser;
end; TWechatAccount = class;
TWechatAccounts = TArray<TWechatAccount>; [JsonSerialize(TJsonMemberSerialization.&Public)]
TWechatAccount = class
private
FAccountID: int64;
FAppid: string;
FAppsecret: string;
FToken: string;
FEncodingAESKey: string;
FPrimaryIndustryID: Integer;
FSecondaryIndustryID: Integer;
FWechatID: string;
FName: string;
FServer: string;
FExpireTime: TDateTime;
FModified: TDateTime;
FAccessToken: string;
FRemark: string;
FAvailable: Byte;
public
[JsonName('account_id')]
property AccountID: int64 read FAccountID write FAccountID; [JsonName('appid')]
property AppId: String read FAppid write FAppid; [JsonName('appsecret')]
property Appsecret: String read FAppsecret write FAppsecret; [JsonName('token')]
property Token: String read FToken write FToken; [JsonName('aes_key')]
property AESKey: String read FEncodingAESKey write FEncodingAESKey; [JsonName('access_token')]
property AccessToken: String read FAccessToken write FAccessToken; [JsonName('wechat_id')]
property WechatID: String read FWechatID write FWechatID; [JsonName('name')]
property Name: String read FName write FName; [JsonName('server')]
property Server: String read FServer write FServer; [JsonName('modified')]
property Modified: TDateTime read FModified write FModified; [JsonName('expire_time')]
property ExpireTime: TDateTime read FExpireTime write FExpireTime; [JsonName('remark')]
property Remark: String read FRemark write FRemark; [JsonName('primary_industry_id')]
property PrimaryIndustryID: Integer read FPrimaryIndustryID write FPrimaryIndustryID; [JsonName('secondary_industry_id')]
property SecondaryIndustryID: Integer read FSecondaryIndustryID write FSecondaryIndustryID; property Available: Byte read FAvailable write FAvailable; function ToJsonString: string;
class function FromJsonString(const AJsonString: string): TWechatAccount;
end; TWechatTemplate = class;
TWechatTemplates = TArray<TWechatTemplate>; [JsonSerialize(TJsonMemberSerialization.&Public)]
TWechatTemplate = class
private
FContent: string;
FDeputyIndustry: string;
FExample: string;
FPrimaryIndustry: string;
FTemplateId: string;
FTitle: string;
public
[JsonName('content')]
property Content: String read FContent write FContent; [JsonName('deputy_industry')]
property DeputyIndustry: String read FDeputyIndustry write FDeputyIndustry; [JsonName('example')]
property Example: String read FExample write FExample; [JsonName('primary_industry')]
property PrimaryIndustry: String read FPrimaryIndustry write FPrimaryIndustry; [JsonName('template_id')]
property Id: String read FTemplateId write FTemplateId; [JsonName('title')]
property Title: String read FTitle write FTitle; function ToJsonString: string;
class function FromJsonString(const AJsonString: string): TWechatTemplate;
end; const
MediaTypeNames: array [TWechatMediaType] of string = ('image', 'voice', 'video', 'thumb');
SubscribeNames: array [ .. ] of string = ('未订阅', '已订阅');
SexNames: array [ .. ] of string = ('未知', '男', '女'); implementation { TWechatUser } function TWechatUser.ToJsonString: string;
begin
Result := TJson.Object2Json<TWechatUser>(Self);
end; class function TWechatUser.FromJsonString(const AJsonString: string): TWechatUser;
begin
Result := TJson.Json2Object<TWechatUser>(AJsonString);
end; { TWechatAccount } class function TWechatAccount.FromJsonString(const AJsonString: string): TWechatAccount;
begin
Result := TJson.Json2Object<TWechatAccount>(AJsonString);
end; function TWechatAccount.ToJsonString: string;
begin
Result := TJson.Object2Json<TWechatAccount>(Self);
end; { TWechatTemplate } function TWechatTemplate.ToJsonString: string;
begin
Result := TJson.Object2Json<TWechatTemplate>(Self);
end; class function TWechatTemplate.FromJsonString(const AJsonString: string): TWechatTemplate;
begin
Result := TJson.Json2Object<TWechatTemplate>(AJsonString);
end; end.

最新文章

  1. 1000行代码实现MVVM (类似Angular1.x.x , Vue)
  2. uva12546. LCM Pair Sum
  3. 一:【nopcommerce系列】Nop整体架构的简单介绍,在看nop代码之前,你需要懂哪些东西
  4. C Primer Plus(第五版)3
  5. cocos2d-html5的jsb模式下如何在编译时自动将js编译为jsc
  6. Eclipse 代码提示功能设置。
  7. jsp的include两种使用方法区别
  8. js添加遮罩层
  9. ecshop给虚拟商品添加出售和未出售的导出xlc
  10. ListView的cacheColorHint与listSelector物业和fragment里面onActivityResult问题没有响应
  11. 跨站脚本攻击(Cross‐Site Scripting (XSS))
  12. bzoj1027 [HNOI2004]打鼹鼠
  13. java:构造方法:无参构造/有参构造 this static关键字 静态变量 静态方法 代码块 封装 静态常量。
  14. Eclipse+Servlet+jsp+MySql
  15. python数据库进阶
  16. Android JNI 学习(六):Object Operations Api
  17. 《pyhton语言程序设计》_第一章笔记
  18. how to get ubuntu current default runlevel
  19. 小而美的ghost driver
  20. 转载:GBDT算法梳理

热门文章

  1. Bootstrap Method
  2. js 做留言提交
  3. 洛谷 P1379 八数码难题 题解
  4. 浏览器端使用less
  5. CF1237E 【Balanced Binary Search Trees】
  6. SQL基础-汇总统计及GROUP BY
  7. centos 7 下安装 redis
  8. GUI引发的一场脑部大战|wine、wsl、mono、gtk、qt
  9. Alibaba Nacos:搭建Nacos平台
  10. js十大排序算法收藏