chenhaozhe
4 天以前 d7f3369550e06d123fc959f8da3549535c2a5afe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using Top.Api;
 
namespace DingTalk.Api
{
    /// <summary>
    /// 基础TOP请求类,存放一些通用的请求参数。
    /// </summary>
    public abstract class BaseDingTalkRequest<T> : IDingTalkRequest<T> where T : DingTalkResponse
    {
        /// <summary>
        /// HTTP请求URL参数
        /// </summary>
        internal TopDictionary otherParams;
        /// <summary>
        /// HTTP请求头参数
        /// </summary>
        private TopDictionary headerParams;
 
        private String httpMethod = "POST";
 
        public void AddOtherParameter(string key, string value)
        {
            if (this.otherParams == null)
            {
                this.otherParams = new TopDictionary();
            }
            this.otherParams.Add(key, value);
        }
 
        public void AddHeaderParameter(string key, string value)
        {
            GetHeaderParameters().Add(key, value);
        }
 
        public IDictionary<string, string> GetHeaderParameters()
        {
            if (this.headerParams == null)
            {
                this.headerParams = new TopDictionary();
            }
            return this.headerParams;
        }
 
        public abstract string GetApiName();
 
        public abstract string GetApiCallType();
 
        public abstract void Validate();
 
        public abstract IDictionary<string, string> GetParameters();
 
        public void SetHttpMethod(String httpMethod) {
            this.httpMethod = httpMethod;
        }
 
        public string GetHttpMethod()
        {
            return httpMethod;
        }
    }
}