Skip to content

Commit

Permalink
Merge pull request #1964 from ably/fix/1959-realtime-rest-request-wra…
Browse files Browse the repository at this point in the history
…pper

[ECO-4932] Added a wrapper `ARTRealtime.request...` method
  • Loading branch information
maratal authored Aug 28, 2024
2 parents 55ad795 + 937f0df commit 8661e4c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Source/ARTRealtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ - (void)time:(ARTDateTimeCallback)cb {
[_internal time:cb];
}

- (BOOL)request:(NSString *)method
path:(NSString *)path
params:(nullable NSStringDictionary *)params
body:(nullable id)body
headers:(nullable NSStringDictionary *)headers
callback:(ARTHTTPPaginatedCallback)callback
error:(NSError *_Nullable *_Nullable)errorPtr {
return [_internal request:method path:path params:params body:body headers:headers callback:callback error:errorPtr];
}

- (void)ping:(ARTCallback)cb {
[_internal ping:cb];
}
Expand Down Expand Up @@ -482,6 +492,16 @@ - (void)time:(ARTDateTimeCallback)cb {
[self.rest time:cb];
}

- (BOOL)request:(NSString *)method
path:(NSString *)path
params:(nullable NSStringDictionary *)params
body:(nullable id)body
headers:(nullable NSStringDictionary *)headers
callback:(ARTHTTPPaginatedCallback)callback
error:(NSError *_Nullable *_Nullable)errorPtr {
return [self.rest request:method path:path params:params body:body headers:headers callback:callback error:errorPtr];
}

- (void)ping:(ARTCallback) cb {
if (cb) {
ARTCallback userCallback = cb;
Expand Down
21 changes: 21 additions & 0 deletions Source/include/Ably/ARTRealtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,27 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)time:(ARTDateTimeCallback)callback;

/**
* Makes a REST request to a provided path. This is provided as a convenience for developers who wish to use REST API functionality that is either not documented or is not yet included in the public API, without having to directly handle features such as authentication, paging, fallback hosts, MsgPack and JSON support.
*
* @param method The request method to use, such as GET, POST.
* @param path The request path.
* @param params The parameters to include in the URL query of the request. The parameters depend on the endpoint being queried. See the [REST API reference](https://ably.com/docs/api/rest-api) for the available parameters of each endpoint.
* @param body The JSON body of the request.
* @param headers Additional HTTP headers to include in the request.
* @param callback A callback for retriving `ARTHttpPaginatedResponse` object returned by the HTTP request, containing an empty or JSON-encodable object.
* @param errorPtr A reference to the `NSError` object where an error information will be saved in case of failure.
* @return In case of failure returns `false` and the error information can be retrived via the `error` parameter.
*/
- (BOOL)request:(NSString *)method
path:(NSString *)path
params:(nullable NSStringDictionary *)params
body:(nullable id)body
headers:(nullable NSStringDictionary *)headers
callback:(ARTHTTPPaginatedCallback)callback
error:(NSError *_Nullable *_Nullable)errorPtr;

/// :nodoc: TODO: docstring
- (void)ping:(ARTCallback)cb;

Expand Down

0 comments on commit 8661e4c

Please sign in to comment.