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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
* @brief The access token to use.
*
* Some requests are unauthenticated - for those, the access token is `nil`.
*/
@property (readonly, nonatomic, nullable) OFString *accessToken;
/**
* @brief The URL of the homeserver to send the request to.
* @brief The IRI of the homeserver to send the request to.
*/
@property (readonly, nonatomic) OFURL *homeserver;
@property (readonly, nonatomic) OFIRI *homeserver;
/**
* @brief The HTTP request method.
*
* Defaults to `OF_HTTP_REQUEST_METHOD_GET`.
*/
@property (nonatomic) OFHTTPRequestMethod method;
/**
* @brief The path of the request.
*/
@property (copy, nonatomic) OFString *path;
/**
* @brief The query for the request.
* @brief The query items for the request.
*/
@property (copy, nullable, nonatomic)
OFDictionary<OFString *, OFString *> *query;
OFArray<OFPair<OFString *, OFString *> *> *queryItems;
/**
* @brief An optional body to send along with the request.
*
* This is a dictionary that gets serialized to JSON when the request is sent.
*/
@property (copy, nullable, nonatomic) OFDictionary<OFString *, id> *body;
/**
* @brief Creates a new request with the specified access token and homeserver.
*
* @param accessToken An (optional) access token to use
* @param homeserver The homeserver the request will be sent to
* @return An autoreleased MTXRequest
*/
+ (instancetype)requestWithPath: (OFString *)path
accessToken: (nullable OFString *)accessToken
homeserver: (OFURL *)homeserver;
homeserver: (OFIRI *)homeserver;
/**
* @brief Initializes an already allocated request with the specified access
* token and homeserver.
*
* @param accessToken An (optional) access token to use
* @param homeserver The homeserver the request will be sent to
* @return An initialized MTXRequest
*/
- (instancetype)initWithPath: (OFString *)path
accessToken: (nullable OFString *)accessToken
homeserver: (OFURL *)homeserver;
homeserver: (OFIRI *)homeserver;
/**
* @brief Performs the request and calls the specified block once the request
* succeeded or failed.
*
* @param block The block to call once the request succeeded or failed
*/
- (void)performWithBlock: (MTXRequestBlock)block;
@end
OF_ASSUME_NONNULL_END
|