commit | author | age
|
655e66
|
1 |
/* |
H |
2 |
* Copyright (C) 2017 Twitter, Inc. |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
* |
|
16 |
*/ |
|
17 |
|
a0a843
|
18 |
#import <Foundation/Foundation.h> |
H |
19 |
|
|
20 |
NS_ASSUME_NONNULL_BEGIN |
|
21 |
|
|
22 |
typedef void (^TWTRMultipartFormDocumentLoadDataCallback)(NSData *data); |
|
23 |
|
|
24 |
@interface TWTRMultipartFormElement : NSObject |
|
25 |
|
|
26 |
/** |
|
27 |
* The name of the form element. |
|
28 |
*/ |
|
29 |
@property (nonatomic, copy, readonly) NSString *name; |
|
30 |
|
|
31 |
/** |
|
32 |
* The content type of the form element. |
|
33 |
*/ |
|
34 |
@property (nonatomic, copy, readonly) NSString *contentType; |
|
35 |
|
|
36 |
/** |
|
37 |
* An optional filename for this element. |
|
38 |
*/ |
|
39 |
@property (nonatomic, copy, readonly, nullable) NSString *fileName; |
|
40 |
|
|
41 |
/** |
|
42 |
* The content's data. |
|
43 |
*/ |
|
44 |
@property (nonatomic, copy, readonly) NSData *content; |
|
45 |
|
|
46 |
/** |
|
47 |
* Returns a fully initialized form element to be used in a multipart for document. |
|
48 |
* |
|
49 |
* @param name the name of the element |
|
50 |
* @param contentType the elements content type |
|
51 |
* @param fileName an optional file name |
|
52 |
* @param content the data associated with this item |
|
53 |
*/ |
|
54 |
- (instancetype)initWithName:(NSString *)name contentType:(NSString *)contentType fileName:(nullable NSString *)fileName content:(NSData *)content NS_DESIGNATED_INITIALIZER; |
|
55 |
|
|
56 |
- (instancetype)init NS_UNAVAILABLE; |
|
57 |
|
|
58 |
@end |
|
59 |
|
|
60 |
/** |
|
61 |
* A class representing a multipart form document. |
|
62 |
*/ |
|
63 |
@interface TWTRMultipartFormDocument : NSObject |
|
64 |
|
|
65 |
/** |
|
66 |
* The forms boundary |
|
67 |
*/ |
|
68 |
@property (nonatomic, copy, readonly) NSString *boundary; |
|
69 |
|
|
70 |
/** |
|
71 |
* Returns a value appropriate for the Content-Type header field |
|
72 |
*/ |
|
73 |
@property (nonatomic, copy, readonly) NSString *contentTypeHeaderField; |
|
74 |
|
|
75 |
/** |
|
76 |
* Instantiates the document with the given elements. |
|
77 |
* |
|
78 |
* @param formElements the elements to append to this document |
|
79 |
*/ |
|
80 |
- (instancetype)initWithFormElements:(NSArray *)formElements NS_DESIGNATED_INITIALIZER; |
|
81 |
|
|
82 |
/** |
|
83 |
* Asynchrounously loads the body data. |
|
84 |
* |
|
85 |
* @param callbackQueue the queue to invoke the handler on |
|
86 |
* @param completion the completion block to call with the loaded data. |
|
87 |
*/ |
|
88 |
- (void)loadBodyDataWithCallbackQueue:(dispatch_queue_t)callbackQueue completion:(TWTRMultipartFormDocumentLoadDataCallback)completion; |
|
89 |
|
|
90 |
@end |
|
91 |
|
|
92 |
NS_ASSUME_NONNULL_END |