杨锴
2024-10-09 e987bc09f955e01c2835f01e3a6af20723a579f9
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// Copyright 2019 Huawei Technologies Co.,Ltd.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License.  You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations under the License.
 
#ifndef OBSBaseModel_h
#define OBSBaseModel_h
 
#import "OBSBaseCategory.h"
#import "OBSBaseConstDefinition.h"
#import "OBSMantle.h"
#import "OBSXMLDictionary.h"
 
@class OBSRequestConverter;
@protocol OBSNetworkingRequestPostProcessor;
 
//#pragma mark - OBSSafeMutableDictionary
//@interface OBSSafeMutableDictionary<KeyType, ObjectType>:NSMutableDictionary
//- (id) objectForKey:(id)aKey;
//- (void)setObject:(ObjectType)anObject forKey:(KeyType <NSCopying>) aKey;
//- (void)removeObjectForKey:(KeyType)aKey;
//@end
//#pragma mark - OBSOrderedMutableDictionary
//@interface OBSOrderedMutableDictionary<KeyType, ObjectType>:NSMutableDictionary
//- (id) objectForKey:(id)aKey;
//- (void)setObject:(ObjectType)anObject forKey:(KeyType <NSCopying>) aKey;
//- (void)removeObjectForKey:(KeyType)aKey;
//- (NSEnumerator*)keyEnumerator;
//- (NSUInteger)count;
//@end
 
#pragma mark - OBSWeakMutableArray
@interface OBSWeakMutableArray<ObjectType>:NSMutableArray
-(instancetype)initWithCapacity:(NSUInteger)numItems;
-(NSUInteger)count;
-(void)addObject:(id)anObject;
-(void)removeObject:(id)anObject;
-(void)removeObjectAtIndex:(NSUInteger)index;
-(id)objectAtIndex:(NSUInteger)index;
@end
 
@protocol OBSGetBodyTypeProtocol<NSObject>
+(OBSBodyType)GetBodyType;
@end
 
#pragma mark configuration
@interface OBSHTTPProxyConfiguration : NSObject
@property (nonatomic, assign) OBSHTTPProxyType proxyType;
@property (nonatomic, strong, nonnull) NSString  *proxyHost;
@property (nonatomic, strong, nonnull) NSNumber  *proxyPort;
@property (nonatomic, strong, nonnull) NSString  *username;
@property (nonatomic, strong, nonnull) NSString  *password;
 
/**
 端口代理初始化
 
 @param proxyType 请求类型(OBSHTTPRroxyTypeNull0 OBSHTTPRroxyTypeHTTP OBSHTTPRroxyTypeHTTPS OBSHTTPRroxyTypeHTTPAndHTTPS)
 @param host host
 @param port port
 @return 代理对象
 */
-(instancetype)initWithType:(OBSHTTPProxyType) proxyType proxyHost:(NSString*) host proxyPort:(NSUInteger) port;
-(NSDictionary*) getProxyDict;
@end
 
@interface OBSBaseConfiguration : NSObject
@property (nonatomic, strong, readonly, nonnull) NSURL *url;
@property (nonatomic, strong) NSString *lastUploadPath;
@property (nonatomic, strong) NSData *uploadAllData;
@property (nonatomic, assign) BOOL trustUnsafeCert;
@property (nonatomic, assign) uint32_t maxConcurrentCommandRequestCount;
@property (nonatomic, assign) uint32_t maxConcurrentUploadRequestCount;
@property (nonatomic, assign) uint32_t maxConcurrentDownloadRequestCount;
 
@property (nonatomic, strong) NSURLSessionConfiguration * commandSessionConfiguration;
@property (nonatomic, strong) NSURLSessionConfiguration * uploadSessionConfiguration;
@property (nonatomic, strong) NSURLSessionConfiguration * downloadSessionConfiguration;
@property (nonatomic, strong) NSURLSessionConfiguration * backgroundUploadSessionConfiguration;
@property (nonatomic, strong) NSURLSessionConfiguration * backgroundDownloadSessionConfiguration;
 
@property (nonatomic, strong) OBSHTTPProxyConfiguration * proxyConfig;
@property (nonatomic, strong) NSMutableArray<id<OBSNetworkingRequestPostProcessor>> * customProcessors;
@property (nonatomic, assign) BOOL enableURLEncoding;
-(instancetype) initWithURL:(NSURL*) url;
-(NSArray*)getDefaultPostProcessors;
@end
 
#pragma mark MTLJSONAdaptor and XML Parser
 
@protocol OBSMTLDictionaryItemOrderProtocol <NSObject>
@required
+(NSArray*)DictionaryOrderList;
@end
 
@interface OBSMTLJSONAdapterCustomized: OBSMTLJSONAdapter
 
-(void)setModelClass:(Class)clazz;
-(Class)modelClass;
 
-(void)setJSONKeyPathsByPropertyKey:(NSDictionary*)dict;
-(NSDictionary*)JSONKeyPathsByPropertyKey;
 
-(void)setValueTransformersByPropertyKey:(NSDictionary*)dict;
-(NSDictionary*)valueTransformersByPropertyKey;
 
-(void)setJSONAdaptersByModelClass:(NSMapTable*)dict;
-(NSMapTable*)JSONAdaptersByModelClass;
 
- (OBSMTLJSONAdapter *)JSONAdapterForModelClass:(Class)modelClass error:(NSError **)error;
@end
 
@interface OBSXMLDictionaryParserWithFormat: OBSXMLDictionaryParser
+ (NSString *)OBSXMLStringForNode:(id)node withNodeName:(NSString *)nodeName ident:(NSInteger) ident;
- (void)endText;
-(void)setRoot:(NSMutableDictionary<NSString *, id>*) root;
-(NSMutableDictionary<NSString *, id>*)root;
-(void)setStack:(NSMutableArray*) stack;
-(NSMutableArray*)stack;
@end
 
#pragma mark - Base Model
 
 
@protocol OBSRequestConvert
@required
-(OBSBaseNetworkingRequest*)convertToNetworkingRequest:(OBSBaseConfiguration*) configuration error:(NSError**) error;
@end
 
@interface OBSAbstractModel : OBSMTLModel<OBSMTLJSONSerializing>
@end
 
@interface OBSBaseEntity: OBSAbstractModel
@end
 
@interface OBSResponseHeaderEntity: OBSBaseEntity
@end
 
@interface OBSResponseURLEntity: OBSBaseEntity
@end
 
@interface OBSResponseBodyEntity: OBSBaseEntity
@end
 
#pragma mark - Base Requests
 
 
/**
 OBS网络请求基类
 */
@interface OBSBaseRequest: OBSAbstractModel<OBSRequestConvert>
 
/**
 请求ID
 */
@property (nonatomic, strong, nonnull) NSString *requestID;
 
/**
 是否取消
 */
@property (readonly, nonatomic, assign) BOOL isCancelled;
 
/**
 请求类型
 */
@property (nonatomic, assign) OBSProtocolType protocolType;
 
 
/**
 取消请求
 */
-(void)cancel;
 
/**
 判断是否是一个合法的请求
 
 @param error 抛出的错误
 @return 返回是否为合法请求
 */
-(BOOL)validateRequest:(NSError**)error;
@end
 
#pragma mark - Base Response
 
/**
 OBS网络响应基类
 */
@interface OBSBaseResponse: OBSAbstractModel<OBSGetBodyTypeProtocol>
 
/**
 响应状态码
 */
@property (nonatomic, strong, nonnull)  NSString *statusCode;
 
/**
 响应头部
 */
@property (nonatomic, strong, nullable) NSDictionary *headers;
 
/**
 请求ID
 */
@property (nonatomic, strong, nullable) NSString *requestID;
@end
 
 
#endif  /* OBSBaseModel_h */