commit | author | age
|
2e29a3
|
1 |
/* |
L |
2 |
* Copyright (c) Meta Platforms, Inc. and affiliates. |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* This source code is licensed under the license found in the |
|
6 |
* LICENSE file in the root directory of this source tree. |
|
7 |
*/ |
|
8 |
|
|
9 |
#import <Foundation/Foundation.h> |
|
10 |
|
|
11 |
#import <FBSDKCoreKit/FBSDKGraphRequestConnecting.h> |
|
12 |
#import <FBSDKCoreKit/FBSDKGraphRequestConnectionFactoryProtocol.h> |
|
13 |
#import <FBSDKCoreKit/FBSDKGraphRequestHTTPMethod.h> |
|
14 |
#import <FBSDKCoreKit/FBSDKGraphRequestProtocol.h> |
|
15 |
#import <FBSDKCoreKit/FBSDKTokenStringProviding.h> |
e0ec42
|
16 |
|
L |
17 |
@protocol FBSDKSettings; |
2e29a3
|
18 |
|
L |
19 |
NS_ASSUME_NONNULL_BEGIN |
|
20 |
/** |
e0ec42
|
21 |
Represents a request to the Facebook Graph API. |
2e29a3
|
22 |
|
L |
23 |
`FBSDKGraphRequest` encapsulates the components of a request (the |
|
24 |
Graph API path, the parameters, error recovery behavior) and should be |
|
25 |
used in conjunction with `FBSDKGraphRequestConnection` to issue the request. |
|
26 |
|
|
27 |
Nearly all Graph APIs require an access token. Unless specified, the |
|
28 |
`[FBSDKAccessToken currentAccessToken]` is used. Therefore, most requests |
|
29 |
will require login first (see `FBSDKLoginManager` in FBSDKLoginKit.framework). |
|
30 |
|
|
31 |
A `- start` method is provided for convenience for single requests. |
|
32 |
|
|
33 |
By default, FBSDKGraphRequest will attempt to recover any errors returned from |
|
34 |
Facebook. You can disable this via `disableErrorRecovery:`. |
|
35 |
|
e0ec42
|
36 |
See FBSDKGraphErrorRecoveryProcessor |
2e29a3
|
37 |
*/ |
L |
38 |
NS_SWIFT_NAME(GraphRequest) |
|
39 |
@interface FBSDKGraphRequest : NSObject <FBSDKGraphRequest> |
|
40 |
|
|
41 |
- (instancetype)init NS_UNAVAILABLE; |
|
42 |
+ (instancetype)new NS_UNAVAILABLE; |
|
43 |
|
|
44 |
/** |
|
45 |
Internal method exposed to facilitate transition to Swift. |
|
46 |
API Subject to change or removal without warning. Do not use. |
|
47 |
|
|
48 |
@warning INTERNAL - DO NOT USE |
|
49 |
*/ |
|
50 |
// UNCRUSTIFY_FORMAT_OFF |
|
51 |
+ (void) configureWithSettings:(id<FBSDKSettings>)settings |
|
52 |
currentAccessTokenStringProvider:(Class<FBSDKTokenStringProviding>)accessTokenProvider |
|
53 |
graphRequestConnectionFactory:(id<FBSDKGraphRequestConnectionFactory>)_graphRequestConnectionFactory |
|
54 |
NS_SWIFT_NAME(configure(settings:currentAccessTokenStringProvider:graphRequestConnectionFactory:)); |
|
55 |
// UNCRUSTIFY_FORMAT_ON |
|
56 |
|
|
57 |
/** |
|
58 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
59 |
@param graphPath the graph path (e.g., @"me"). |
|
60 |
*/ |
|
61 |
- (instancetype)initWithGraphPath:(NSString *)graphPath; |
|
62 |
|
|
63 |
/** |
|
64 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
65 |
@param graphPath the graph path (e.g., @"me"). |
|
66 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
67 |
*/ |
|
68 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
69 |
HTTPMethod:(FBSDKHTTPMethod)method; |
|
70 |
|
|
71 |
/** |
e0ec42
|
72 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
2e29a3
|
73 |
@param graphPath the graph path (e.g., @"me"). |
L |
74 |
@param parameters the optional parameters dictionary. |
|
75 |
*/ |
|
76 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
77 |
parameters:(NSDictionary<NSString *, id> *)parameters; |
|
78 |
|
|
79 |
/** |
e0ec42
|
80 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
2e29a3
|
81 |
@param graphPath the graph path (e.g., @"me"). |
L |
82 |
@param parameters the optional parameters dictionary. |
|
83 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
84 |
*/ |
|
85 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
86 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
87 |
HTTPMethod:(FBSDKHTTPMethod)method; |
|
88 |
|
|
89 |
/** |
e0ec42
|
90 |
Initializes a new instance. |
2e29a3
|
91 |
@param graphPath the graph path (e.g., @"me"). |
L |
92 |
@param parameters the optional parameters dictionary. |
|
93 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
94 |
@param version the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`. |
|
95 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
96 |
*/ |
|
97 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
98 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
99 |
tokenString:(nullable NSString *)tokenString |
|
100 |
version:(nullable NSString *)version |
|
101 |
HTTPMethod:(FBSDKHTTPMethod)method |
|
102 |
NS_DESIGNATED_INITIALIZER; |
|
103 |
|
|
104 |
/** |
e0ec42
|
105 |
Initializes a new instance. |
2e29a3
|
106 |
@param graphPath the graph path (e.g., @"me"). |
L |
107 |
@param parameters the optional parameters dictionary. |
|
108 |
@param requestFlags flags that indicate how a graph request should be treated in various scenarios |
|
109 |
*/ |
|
110 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
111 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
112 |
flags:(FBSDKGraphRequestFlags)requestFlags; |
|
113 |
|
|
114 |
/** |
e0ec42
|
115 |
Initializes a new instance. |
2e29a3
|
116 |
@param graphPath the graph path (e.g., @"me"). |
L |
117 |
@param parameters the optional parameters dictionary. |
|
118 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
119 |
@param HTTPMethod the HTTP method. Empty String defaults to @"GET". |
|
120 |
@param flags flags that indicate how a graph request should be treated in various scenarios |
|
121 |
*/ |
|
122 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
123 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
124 |
tokenString:(nullable NSString *)tokenString |
|
125 |
HTTPMethod:(nullable NSString *)HTTPMethod |
|
126 |
flags:(FBSDKGraphRequestFlags)flags; |
|
127 |
|
e0ec42
|
128 |
/// The request parameters. |
2e29a3
|
129 |
@property (nonatomic, copy) NSDictionary<NSString *, id> *parameters; |
L |
130 |
|
e0ec42
|
131 |
/// The access token string used by the request. |
2e29a3
|
132 |
@property (nullable, nonatomic, readonly, copy) NSString *tokenString; |
L |
133 |
|
e0ec42
|
134 |
/// The Graph API endpoint to use for the request, for example "me". |
2e29a3
|
135 |
@property (nonatomic, readonly, copy) NSString *graphPath; |
L |
136 |
|
e0ec42
|
137 |
/// The HTTPMethod to use for the request, for example "GET" or "POST". |
2e29a3
|
138 |
@property (nonatomic, readonly, copy) FBSDKHTTPMethod HTTPMethod; |
L |
139 |
|
e0ec42
|
140 |
/// The Graph API version to use (e.g., "v2.0") |
2e29a3
|
141 |
@property (nonatomic, readonly, copy) NSString *version; |
L |
142 |
|
|
143 |
/** |
e0ec42
|
144 |
If set, disables the automatic error recovery mechanism. |
2e29a3
|
145 |
@param disable whether to disable the automatic error recovery mechanism |
L |
146 |
|
|
147 |
By default, non-batched FBSDKGraphRequest instances will automatically try to recover |
|
148 |
from errors by constructing a `FBSDKGraphErrorRecoveryProcessor` instance that |
|
149 |
re-issues the request on successful recoveries. The re-issued request will call the same |
|
150 |
handler as the receiver but may occur with a different `FBSDKGraphRequestConnection` instance. |
|
151 |
|
|
152 |
This will override [FBSDKSettings setGraphErrorRecoveryDisabled:]. |
|
153 |
*/ |
|
154 |
|
|
155 |
// UNCRUSTIFY_FORMAT_OFF |
|
156 |
- (void)setGraphErrorRecoveryDisabled:(BOOL)disable |
|
157 |
NS_SWIFT_NAME(setGraphErrorRecovery(disabled:)); |
|
158 |
// UNCRUSTIFY_FORMAT_ON |
|
159 |
|
|
160 |
/** |
e0ec42
|
161 |
Starts a connection to the Graph API. |
2e29a3
|
162 |
@param completion The handler block to call when the request completes. |
L |
163 |
*/ |
|
164 |
- (id<FBSDKGraphRequestConnecting>)startWithCompletion:(nullable FBSDKGraphRequestCompletion)completion; |
|
165 |
|
|
166 |
@end |
|
167 |
|
|
168 |
NS_ASSUME_NONNULL_END |