mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-19 18:22:24 +08:00
style: clean code
This commit is contained in:
@@ -26,7 +26,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -72,7 +72,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -96,7 +96,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -121,7 +121,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -145,7 +145,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -169,7 +169,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
|
@@ -28,7 +28,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
.CreateRequest(request, HttpMethod.Get, "cgi-bin", "corp", "get_join_qrcode")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
if (request.SizeType.HasValue)
|
||||
if (request.SizeType != null)
|
||||
flurlReq.SetQueryParam("size_type", request.SizeType.Value);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGetJoinQrcodeResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
|
@@ -25,7 +25,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.ParentAgentId.HasValue)
|
||||
if (request.ParentAgentId == null)
|
||||
request.ParentAgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
|
@@ -97,7 +97,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
.CreateRequest(request, HttpMethod.Get, "cgi-bin", "department", "list")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
if (request.ParentDepartmentId.HasValue)
|
||||
if (request.ParentDepartmentId != null)
|
||||
flurlReq.SetQueryParam("id", request.ParentDepartmentId.Value);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinDepartmentListResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
|
@@ -1008,7 +1008,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
|
@@ -125,7 +125,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
|
@@ -30,7 +30,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
const string TYPE_VOICE = "voice";
|
||||
const string TYPE_VIDEO = "video";
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileName))
|
||||
if (request.FileName == null)
|
||||
{
|
||||
string ext = "";
|
||||
if (TYPE_IMAGE.Equals(request.Type))
|
||||
@@ -43,7 +43,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ext;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileContentType))
|
||||
if (request.FileContentType == null)
|
||||
{
|
||||
if (TYPE_IMAGE.Equals(request.Type))
|
||||
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
|
||||
@@ -86,10 +86,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileName))
|
||||
if (request.FileName == null)
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png";
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileContentType))
|
||||
if (request.FileContentType == null)
|
||||
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -125,7 +125,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
const string TYPE_VIDEO = "video";
|
||||
const string TYPE_FILE = "file";
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileName))
|
||||
if (request.FileName == null)
|
||||
{
|
||||
string ext = "";
|
||||
if (TYPE_IMAGE.Equals(request.Type))
|
||||
@@ -138,7 +138,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ext;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileContentType))
|
||||
if (request.FileContentType == null)
|
||||
{
|
||||
if (TYPE_IMAGE.Equals(request.Type))
|
||||
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
|
||||
|
@@ -24,7 +24,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -48,7 +48,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -72,7 +72,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
|
@@ -26,7 +26,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -50,7 +50,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -74,7 +74,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (!request.AgentId.HasValue)
|
||||
if (request.AgentId == null)
|
||||
request.AgentId = client.Credentials.AgentId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
|
@@ -135,7 +135,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
.SetQueryParam("access_token", request.AccessToken)
|
||||
.SetQueryParam("department_id", request.DeparmentId);
|
||||
|
||||
if (request.RequireFetchChild.HasValue)
|
||||
if (request.RequireFetchChild != null)
|
||||
flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinSchoolUserListResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
@@ -566,7 +566,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
.CreateRequest(request, HttpMethod.Get, "cgi-bin", "school", "department", "list")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
if (request.ParentDepartmentId.HasValue)
|
||||
if (request.ParentDepartmentId != null)
|
||||
flurlReq.SetQueryParam("id", request.ParentDepartmentId);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinSchoolDepartmentListResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
|
@@ -46,10 +46,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.SuiteId))
|
||||
if (request.SuiteId == null)
|
||||
request.SuiteId = client.Credentials.SuiteId;
|
||||
|
||||
if (string.IsNullOrEmpty(request.SuiteSecret))
|
||||
if (request.SuiteSecret == null)
|
||||
request.SuiteSecret = client.Credentials.SuiteSecret;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
@@ -246,7 +246,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
const string TYPE_VOICE = "voice";
|
||||
const string TYPE_VIDEO = "video";
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileName))
|
||||
if (request.FileName == null)
|
||||
{
|
||||
string ext = "";
|
||||
if (TYPE_IMAGE.Equals(request.Type))
|
||||
@@ -259,7 +259,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ext;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileContentType))
|
||||
if (request.FileContentType == null)
|
||||
{
|
||||
if (TYPE_IMAGE.Equals(request.Type))
|
||||
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
|
||||
|
@@ -143,7 +143,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
.SetQueryParam("access_token", request.AccessToken)
|
||||
.SetQueryParam("department_id", request.DepartmentId);
|
||||
|
||||
if (request.RequireFetchChild.HasValue)
|
||||
if (request.RequireFetchChild != null)
|
||||
flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinUserSimpleListResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
@@ -169,7 +169,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
.SetQueryParam("access_token", request.AccessToken)
|
||||
.SetQueryParam("department_id", request.DepartmentId);
|
||||
|
||||
if (request.RequireFetchChild.HasValue)
|
||||
if (request.RequireFetchChild != null)
|
||||
flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinUserListResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
@@ -324,10 +324,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
.CreateRequest(request, HttpMethod.Get, "cgi-bin", "user", "list_member_auth")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
if (!string.IsNullOrEmpty(request.NextCursor))
|
||||
if (request.NextCursor != null)
|
||||
flurlReq.SetQueryParam("cursor", request.NextCursor);
|
||||
|
||||
if (request.Limit.HasValue)
|
||||
if (request.Limit != null)
|
||||
flurlReq.SetQueryParam("limit", request.Limit);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinUserListMemberAuthResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
|
@@ -59,7 +59,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
{
|
||||
IFlurlRequest flurlRequest = FlurlClient.Request(urlSegments).WithVerb(method);
|
||||
|
||||
if (request.Timeout.HasValue)
|
||||
if (request.Timeout != null)
|
||||
{
|
||||
flurlRequest.WithTimeout(TimeSpan.FromMilliseconds(request.Timeout.Value));
|
||||
}
|
||||
|
Reference in New Issue
Block a user