exmail/useroption.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 77 CC 5 SCAR 19.5
CC
5
Cov
0%
get
12.0
update
12.0
BEGIN
2.0
CRAP 7.0
1 package QQ::exmail::useroption;
2
3 =encoding utf8
4
5 =head1 Name
6
7 QQ::exmail::useroption
8
9 =head1 DESCRIPTION
10
11 功能设置
12
13 =cut
14
15 use strict;
16 use base qw(QQ::exmail);
17 use Encode;
18 use LWP::UserAgent;
19 use JSON;
20 use utf8;
21
22 our $VERSION = '1.10';
23 our @EXPORT = qw/ get update /;
24
25 =head1 FUNCTION
26
27 =head2 get(access_token, hash);
28
29 获取功能属性
30
31 =head2 SYNOPSIS
32
33 L<https://exmail.qq.com/qy_mng_logic/doc#10020>
34
35 =head3 请求说明:
36
37 =head4 请求包结构体为:
38
39 {
40 "userid": "zhangsan@gzdev.com",
41 "type":[1,2,3]
42 }
43
44 =head4 参数说明:
45
46 参数 必须 说明
47 access_token 是 调用接口凭证
48 userid 是 成员UserID
49 type 是 功能设置属性类型
50 1: 强制启用安全登录
51 2: IMAP/SMTP服务
52 3: POP/SMTP服务
53 4: 是否启用安全登录
54
55 =head3 权限说明
56
57 系统应用须拥有指定成员的查看权限
58
59 =head3 RETURN 返回结果
60
61 {
62 "errcode": 0,
63 "errmsg": "ok",
64 "option":[{"type":1,"value":"0"}, {"type":2,"value":"1"}, {"type":3,"value":"0"}]}
65 }
66
67 =head4 RETURN 参数说明
68
69 参数 说明
70 errcode 返回码
71 errmsg 对返回码的文本描述内容
72 option 功能设置属性
73 type:属性类型。value:属性值(字符型)
74 1: 强制微信动态码
75 2: IMAP/SMTP服务
76 3: POP/SMTP服务
77 4: 是否启用微信动态码
78
79 =cut
80
81 sub get {
82 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
83 my $access_token = $_[0];
84 my $json = $_[1];
85 my $ua = LWP::UserAgent->new;
86 $ua->timeout(30);
87 $ua->env_proxy;
88
89 my $response = $ua->post("https://api.exmail.qq.com/cgi-bin/useroption/get?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
90 if ($response->is_success) {
91 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
92 }
93
94 }
95 return 0;
96 }
97
98 =head2 update(access_token, hash);
99
100 更改功能属性
101
102 =head2 SYNOPSIS
103
104 L<https://exmail.qq.com/qy_mng_logic/doc#10020>
105
106 =head3 请求说明:
107
108 =head4 请求包结构体为:
109
110 {
111 "userid": "zhangsan@gzdev.com",
112 "option": [{"type":1,"value":"0"},{"type":2,"value":"1"},{"type":3,"value":"0"}]}
113 }
114
115 =head4 参数说明:
116
117 参数 必须 说明
118 access_token 是 调用接口凭证
119 userid 是 成员UserID。企业邮帐号名,邮箱格式
120 option 是 功能设置属性
121 type:属性类型。value:属性值(字符型)
122 1: 强制启用安全登录
123 2: IMAP/SMTP服务
124 3: POP/SMTP服务
125 4: 是否启用安全登录,不可用
126
127 =head3 权限说明
128
129 系统应用须拥有指定成员的查看权限
130
131 =head3 RETURN 返回结果
132
133 {
134 "errcode": 0,
135 "errmsg": "update"
136 }
137
138 =head4 RETURN 参数说明
139
140 参数 说明
141 errcode 返回码
142 errmsg 对返回码的文本描述内容
143
144 =cut
145
146 sub update {
147 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
148 my $access_token = $_[0];
149 my $json = $_[1];
150 my $ua = LWP::UserAgent->new;
151 $ua->timeout(30);
152 $ua->env_proxy;
153
154 my $response = $ua->post("https://api.exmail.qq.com/cgi-bin/useroption/update?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
155 if ($response->is_success) {
156 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
157 }
158
159 }
160 return 0;
161 }
162
163
164 1;
165 __END__