JubeatPlus 3.9.11
Loading...
Searching...
No Matches
ApplilinkWebAPI Class Reference

Applilink SDK HTTP transport, retry policy, and response parsing. More...

#include <ApplilinkWebAPI.h>

Inheritance diagram for ApplilinkWebAPI:
Collaboration diagram for ApplilinkWebAPI:

Instance Methods

(instancetype) - init
 Initialise the transport with a cleared retry counter.
(nullable NSDictionary *) - commonParameters
 The parameters common to every applilink request.
(nullable NSMutableURLRequest *) - requestWithURL:method:parameters:timeout:cachePolicy:
 Build a request for a URL, method, parameters, timeout, and cache policy.
(nullable NSMutableURLRequest *) - requestForGetWithURL:parameters:
 Build a GET request, appending the parameters to the URL as a query string.
(nullable NSMutableURLRequest *) - requestForPostWithURL:parameters:
 Build a POST request, serialising the parameters into a form-encoded body.
(void) - requestAsynchronousWithURL:method:parameters:userInfo:tag:cachePolicy:timeout:retry:finishedBlock:failedBlock:
 Send a request asynchronously with a bounded timeout-retry policy.
(nullable id) - responseFromContentsServer:request:data:finishedBlock:failedBlock:
 Parse a contents-server response and dispatch any failure.
(nullable id) - requestSynchronousWithURL:method:parameters:cachePolicy:error:
 Send a request synchronously with a bounded timeout-retry loop and parse the JSON body.
(BOOL) - canUseNetworkRetry
 Whether this device's operating-system version supports the network-retry policy.

Class Methods

(void) + requestAsynchronousWithURL:method:parameters:userInfo:tag:cachePolicy:timeout:retry:finishedBlock:failedBlock:
 Convenience class factory for the asynchronous request.
(nullable id) + requestSynchronousWithURL:method:parameters:cachePolicy:error:
 Convenience class factory for requestSynchronousWithURL:method:parameters:cachePolicy: error:.
(nullable id) + responseFromContentsServer:request:data:finishedBlock:failedBlock:
 Convenience class factory for responseFromContentsServer:request:data:finishedBlock: failedBlock:.
(void) + retryCancel
 Cancel the timeout-retry policy for outstanding requests.
(void) + setSessionConnectionWait:
 Arm or disarm the session-connection wait gate.
(void) + calcelSessionConnection
 Clear the session-connection wait gate.
(void) + setSessionStatus:
 Set whether the session is established, gating the session-regeneration short circuit.

Detailed Description

Applilink SDK HTTP transport, retry policy, and response parsing.

Method Documentation

◆ calcelSessionConnection

+ (void) calcelSessionConnection

Clear the session-connection wait gate.

The binary spells this selector calcelSessionConnection without correcting the cancel typo.

Ghidra address:
0x253bd0

◆ canUseNetworkRetry

- (BOOL) canUseNetworkRetry

Whether this device's operating-system version supports the network-retry policy.

Returns
YES when the operating-system version is at least 6.0.
Ghidra address:
0x253bf0

◆ commonParameters

- (NSDictionary *) commonParameters

The parameters common to every applilink request.

Returns
A dictionary carrying cr=0 and format=json .
Ghidra address:
0x2512ac

◆ init

- (instancetype) init
Initial value:
{
int retryCount

Initialise the transport with a cleared retry counter.

Returns
The initialised instance.
Ghidra address:
0x251250

◆ requestAsynchronousWithURL:method:parameters:userInfo:tag:cachePolicy:timeout:retry:finishedBlock:failedBlock: [1/2]

+ (void) requestAsynchronousWithURL: (nullable NSString *) URL
method: (nullable NSString *) method
parameters: (nullable NSDictionary *) parameters
userInfo: (nullable id) userInfo
tag: (NSInteger) tag
cachePolicy: (nullable NSNumber *) cachePolicy
timeout: (float) timeout
retry: (BOOL) retry
finishedBlock: (nullable ApplilinkWebAPIFinishedBlock) finishedBlock
failedBlock: (nullable ApplilinkWebAPIFailedBlock) failedBlock 

Convenience class factory for the asynchronous request.

The work is dispatched to a global concurrent queue, where a throwaway instance sends the request through the instance method of the same selector.

Parameters
URLThe base URL string.
methodThe HTTP method.
parametersThe request parameters.
userInfoCaller context; the callback blocks are instead handed the sent request.
tagA caller-supplied request tag.
cachePolicyThe cache policy as a boxed NSNumber , or nil for the default policy.
timeoutThe request timeout, in seconds.
retryWhether the request participates in the timeout-retry policy.
finishedBlockThe success callback.
failedBlockThe failure callback.
Ghidra address:
0x253604

◆ requestAsynchronousWithURL:method:parameters:userInfo:tag:cachePolicy:timeout:retry:finishedBlock:failedBlock: [2/2]

- (void) requestAsynchronousWithURL: (nullable NSString *) URL
method: (nullable NSString *) method
parameters: (nullable NSDictionary *) parameters
userInfo: (nullable id) userInfo
tag: (NSInteger) tag
cachePolicy: (nullable NSNumber *) cachePolicy
timeout: (float) timeout
retry: (BOOL) retry
finishedBlock: (nullable ApplilinkWebAPIFinishedBlock) finishedBlock
failedBlock: (nullable ApplilinkWebAPIFailedBlock) failedBlock 

Send a request asynchronously with a bounded timeout-retry policy.

The request is blocked while a session regeneration is in flight, short-circuited when it is itself the session-regeneration request, then sent through NSURLConnection on the main queue. On older operating-system versions, or when retry is set, a GCD timer re-issues the request up to the retry cap. The completion handler parses the JSON body and invokes finishedBlock or failedBlock .

Parameters
URLThe base URL string.
methodThe HTTP method.
parametersThe request parameters.
userInfoCaller context; the callback blocks are instead handed the sent request.
tagA caller-supplied request tag.
cachePolicyThe cache policy as a boxed NSNumber , or nil for the default policy.
timeoutThe request timeout, in seconds.
retryWhether the request participates in the timeout-retry policy.
finishedBlockThe success callback.
failedBlockThe failure callback.
Ghidra address:
0x251a30

◆ requestForGetWithURL:parameters:

- (nullable NSMutableURLRequest *) requestForGetWithURL: (nullable NSString *) URL
parameters: (nullable NSDictionary *) parameters 

Build a GET request, appending the parameters to the URL as a query string.

Parameters
URLThe base URL string.
parametersThe parameters to append.
Returns
The GET request.
Ghidra address:
0x2514cc

◆ requestForPostWithURL:parameters:

- (nullable NSMutableURLRequest *) requestForPostWithURL: (nullable NSString *) URL
parameters: (nullable NSDictionary *) parameters 

Build a POST request, serialising the parameters into a form-encoded body.

Each value is percent-joined into a key=value pair; an array value expands into repeated key[]=value pairs. The pairs are joined with & and set as the request body with a Content-Type of application/x-www-form-urlencoded .

Parameters
URLThe URL string.
parametersThe parameters to serialise.
Returns
The POST request.
Ghidra address:
0x25159c

◆ requestSynchronousWithURL:method:parameters:cachePolicy:error: [1/2]

+ (nullable id) requestSynchronousWithURL: (nullable NSString *) URL
method: (nullable NSString *) method
parameters: (nullable NSDictionary *) parameters
cachePolicy: (nullable NSNumber *) cachePolicy
error: (NSError *_Nullable *_Nullable) error 

Convenience class factory for requestSynchronousWithURL:method:parameters:cachePolicy: error:.

Parameters
URLThe base URL string.
methodThe HTTP method.
parametersThe request parameters.
cachePolicyThe cache policy as a boxed NSNumber , or nil for the default policy.
errorOn failure, the localised error; may be nullptr.
Returns
The parsed JSON response, or nil on failure.
Ghidra address:
0x253930

◆ requestSynchronousWithURL:method:parameters:cachePolicy:error: [2/2]

- (nullable id) requestSynchronousWithURL: (nullable NSString *) URL
method: (nullable NSString *) method
parameters: (nullable NSDictionary *) parameters
cachePolicy: (nullable NSNumber *) cachePolicy
error: (NSError *_Nullable *_Nullable) error 

Send a request synchronously with a bounded timeout-retry loop and parse the JSON body.

The request is sent through NSURLConnection with a ten-second timeout. Server errors in the 400-599 range, and connection timeouts, are retried up to the retry cap; on final failure a localised ApplilinkNetworkError is written to error . On success the parsed JSON object is returned.

Parameters
URLThe base URL string.
methodThe HTTP method.
parametersThe request parameters.
cachePolicyThe cache policy as a boxed NSNumber , or nil for the default policy.
errorOn failure, the localised error; may be nullptr.
Returns
The parsed JSON response, or nil on failure.
Ghidra address:
0x253270

◆ requestWithURL:method:parameters:timeout:cachePolicy:

- (nullable NSMutableURLRequest *) requestWithURL: (nullable NSString *) URL
method: (nullable NSString *) method
parameters: (nullable NSDictionary *) parameters
timeout: (float) timeout
cachePolicy: (nullable NSNumber *) cachePolicy 

Build a request for a URL, method, parameters, timeout, and cache policy.

The parameters are merged with commonParameters , then dispatched to requestForGetWithURL:parameters: or requestForPostWithURL:parameters: depending on whether method equals "POST". The HTTP method, timeout, and cache policy are then applied. The timeout is a float and the cache policy is an object (a boxed NSNumber ), both taken from the selector's type encoding @52@0:8@16@24@32f40@44 rather than an NSTimeInterval or an NSURLRequestCachePolicy .

Parameters
URLThe base URL string.
methodThe HTTP method; "POST" selects the POST body path, anything else the GET query path.
parametersThe request parameters.
timeoutThe request timeout, in seconds.
cachePolicyThe cache policy as a boxed NSNumber , or nil for the default policy.
Returns
The configured request.
Ghidra address:
0x251304

◆ responseFromContentsServer:request:data:finishedBlock:failedBlock: [1/2]

+ (nullable id) responseFromContentsServer: (nullable NSString *) response
request: (nullable id) request
data: (nullable NSData *) data
finishedBlock: (nullable ApplilinkWebAPIFinishedBlock) finishedBlock
failedBlock: (nullable ApplilinkWebAPIFailedBlock) failedBlock 

Convenience class factory for responseFromContentsServer:request:data:finishedBlock: failedBlock:.

Parameters
responseThe request URL, matched against the contents-server URL.
requestThe request that was sent, handed back to failedBlock .
dataThe raw response data.
finishedBlockThe success callback (unused on this path).
failedBlockThe failure callback.
Returns
The value forwarded from the instance method.
Ghidra address:
0x253a30

◆ responseFromContentsServer:request:data:finishedBlock:failedBlock: [2/2]

- (nullable id) responseFromContentsServer: (nullable NSString *) response
request: (nullable id) request
data: (nullable NSData *) data
finishedBlock: (nullable ApplilinkWebAPIFinishedBlock) finishedBlock
failedBlock: (nullable ApplilinkWebAPIFailedBlock) failedBlock 

Parse a contents-server response and dispatch any failure.

When response equals the reward contents-server URL (the ApplilinkReward.appliURL default) and data is non-empty, the newline-delimited body is parsed: the first line carries the status and the remaining lines are accumulated. A status of "1" returns the accumulated body encoded as NSData without invoking finishedBlock ; any other status delivers a localised ApplilinkNetworkError to failedBlock . A malformed or missing body delivers a localised error too. When response is not the contents-server URL, data is returned unchanged; the asynchronous completion handler then JSON-parses that returned value.

Parameters
responseThe request URL, matched against the contents-server URL.
requestThe request that was sent, handed back to failedBlock .
dataThe raw response data.
finishedBlockThe success callback (unused on this path).
failedBlockThe failure callback.
Returns
The accumulated body data on the contents-server success path, otherwise data .
Ghidra address:
0x252c58

◆ retryCancel

+ (void) retryCancel

Cancel the timeout-retry policy for outstanding requests.

Ghidra address:
0x253b44

◆ setSessionConnectionWait:

+ (void) setSessionConnectionWait: (BOOL) sessionConnectionWait

Arm or disarm the session-connection wait gate.

When set, asynchronous requests block until the gate clears; the gate is auto-cleared after ten seconds through calcelSessionConnection .

Parameters
sessionConnectionWaitYES to arm the gate, NO to clear it.
Ghidra address:
0x253b54

◆ setSessionStatus:

+ (void) setSessionStatus: (BOOL) sessionStatus

Set whether the session is established, gating the session-regeneration short circuit.

Parameters
sessionStatusYES when the session is established.
Ghidra address:
0x253be0

The documentation for this class was generated from the following files: