AWFBatchRequest

Objective-C

@interface AWFBatchRequest : NSObject

Swift

class AWFBatchRequest : NSObject

AWFBatchLoader provides convenience methods for combining multiple endpoint requests into a single HTTP request using Aeris API’s batch endpoint. This request allows you to easily add and remove existing specific endpoints before performing a request.

  • An array of AWFWeatherEndpoint instances currently associated with this batch request.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) NSArray<AWFWeatherEndpoint *> *endpoints;

    Swift

    var endpoints: [AWFWeatherEndpoint]? { get }
  • The chained request string used by the requests parameter.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *_Nonnull URLPath;

    Swift

    var urlPath: String { get }
  • Initializes and returns a batch request instance with the specified array of endpoint instances.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithEndpoints:
        (nullable NSArray<AWFWeatherEndpoint *> *)endpoints;

    Swift

    init(endpoints: [AWFWeatherEndpoint]?)

    Parameters

    endpoints

    The array of endpoint instances to initialize the batch request with.

    Return Value

    The initialized batch request instance.

Managing Endpoints

  • Adds an endpoint to the batch request.

    Declaration

    Objective-C

    - (void)addEndpoint:(nonnull AWFWeatherEndpoint *)endpoint;

    Swift

    func addEndpoint(_ endpoint: AWFWeatherEndpoint)

    Parameters

    endpoint

    The endpoint to add

  • Adds an endpoint to the batch request.

    Declaration

    Objective-C

    - (void)addEndpoint:(nonnull AWFWeatherEndpoint *)endpoint
                options:(nullable AWFWeatherRequestOptions *)options;

    Swift

    func addEndpoint(_ endpoint: AWFWeatherEndpoint, options: AWFWeatherRequestOptions?)

    Parameters

    endpoint

    The endpoint to add

  • Adds an endpoint to the batch request and assigns a reference key to it.

    The reference key is a convenient way to get a reference to a specific endpoint in the batch using objectLoaderForKey: or to return all of the available objects from a endpoint using objectsForLoaderWithKey:.

    Declaration

    Objective-C

    - (void)addEndpoint:(nonnull AWFWeatherEndpoint *)endpoint
                 forKey:(nullable NSString *)key;

    Swift

    func addEndpoint(_ endpoint: AWFWeatherEndpoint, forKey key: String?)

    Parameters

    endpoint

    The endpoint to add

    key

    The reference key for the endpoint

  • Adds an endpoint to the batch request and assigns a reference key to it.

    The reference key is a convenient way to get a reference to a specific endpoint in the batch using objectLoaderForKey: or to return all of the available objects from a endpoint using objectsForLoaderWithKey:.

    Declaration

    Objective-C

    - (void)addEndpoint:(nonnull AWFWeatherEndpoint *)endpoint
                 forKey:(nullable NSString *)key
                options:(nullable AWFWeatherRequestOptions *)options;

    Swift

    func addEndpoint(_ endpoint: AWFWeatherEndpoint, forKey key: String?, options: AWFWeatherRequestOptions?)

    Parameters

    endpoint

    The endpoint to add

    key

    The reference key for the endpoint

  • Adds an endpoint to the batch request with the given endpoint action.

    Declaration

    Objective-C

    - (void)addEndpoint:(nonnull AWFWeatherEndpoint *)endpoint
                 action:(nullable NSString *)action
                options:(nullable AWFWeatherRequestOptions *)options;

    Swift

    func addEndpoint(_ endpoint: AWFWeatherEndpoint, action: String?, options: AWFWeatherRequestOptions?)

    Parameters

    endpoint

    The endpoint to add

    action

    The endpoint action to use with the endpoint

  • Adds an endpoint to the batch request with the given endpoint action and reference key.

    The reference key is a convenient way to get a reference to a specific endpoint in the batch using objectLoaderForKey: or to return all of the available objects from a endpoint using objectsForLoaderWithKey:.

    Declaration

    Objective-C

    - (void)addEndpoint:(nonnull AWFWeatherEndpoint *)endpoint
                 action:(nullable NSString *)action
                 forKey:(nullable NSString *)key
                options:(nullable AWFWeatherRequestOptions *)options;

    Swift

    func addEndpoint(_ endpoint: AWFWeatherEndpoint, action: String?, forKey key: String?, options: AWFWeatherRequestOptions?)

    Parameters

    endpoint

    The endpoint to add

    action

    The endpoint action to use with the endpoint

    key

    The reference key for the endpoint.

  • Removes an endpoint from the batch request.

    Declaration

    Objective-C

    - (void)removeEndpoint:(nonnull AWFWeatherEndpoint *)endpoint;

    Swift

    func removeEndpoint(_ endpoint: AWFWeatherEndpoint)

    Parameters

    endpoint

    The endpoint to remove

  • Removes an endpoint from the batch request associated with the specific reference key.

    Declaration

    Objective-C

    - (void)removeEndpointForKey:(nonnull NSString *)key;

    Swift

    func removeEndpoint(forKey key: String)

    Parameters

    key

    The reference key associated with the endpoint to remove

  • Removes all endpoints from the batch request.

    Declaration

    Objective-C

    - (void)removeAllEndpoints;

    Swift

    func removeAllEndpoints()
  • Updates the place option value on all endpoints currently within the batch request.

    Declaration

    Objective-C

    - (void)setPlaceForAllEndpoints:(nonnull AWFPlace *)place;

    Swift

    func setPlaceForAllEndpoints(_ place: AWFPlace)

    Parameters

    place

    The place to use for all endpoints

Requesting Data

  • Performs the request by combining each internal endpoint’s associated enpoint and options into a single batch request.

    Declaration

    Objective-C

    - (id)getWithOptions:(nullable AWFBatchRequestOptions *)options
              completion:(nonnull AWFBatchRequestCompletionBlock)completionBlock;

    Swift

    func get(options: AWFBatchRequestOptions?, completion completionBlock: @escaping AWFBatchRequestCompletionBlock) -> Any!

    Parameters

    completionBlock

    The block to be executed on the completion or failure of a request. This block has no return value and takes two arguments: the batch request that performed the request and the error that occurred during the request, if any.

  • Performs the request by combining each internal endpoint’s associated endpoint and options into a single batch request. Cached data will be used when available and not older than the specified expirationInterval.

    Declaration

    Objective-C

    - (id)getWithOptions:(nullable AWFBatchRequestOptions *)options
              expiration:(NSTimeInterval)expirationInterval
              completion:(nonnull AWFBatchRequestCompletionBlock)completionBlock;

    Swift

    func get(options: AWFBatchRequestOptions?, expiration expirationInterval: TimeInterval, completion completionBlock: @escaping AWFBatchRequestCompletionBlock) -> Any!

    Parameters

    expirationInterval

    The maximum age allowed to use previously cached data for the request. If the data is older than this value, new remote data will be requested.

    completionBlock

    The block to be executed on the completion or failure of a request. This block has no return value and takes two arguments: the batch request that performed the request and the error that occurred during the request, if any.

Accessing Results

  • Returns an array of AWFWeatherObject instances that were returned with the request for a specific endpoint used with the batch request.

    Declaration

    Objective-C

    - (nullable NSArray<AWFWeatherObject *> *)resultsForEndpoint:
        (nonnull AWFWeatherEndpoint *)endpoint;

    Swift

    func results(for endpoint: AWFWeatherEndpoint) -> [AWFWeatherObject]?

    Parameters

    endpoint

    The endpoint to return results for

    Return Value

    An array of AWFWeatherObject instances for the endpoint, or nil if no results were loaded

  • Returns all objects loaded from the batch request for the endpoint associated with the specified reference key.

    Declaration

    Objective-C

    - (nullable NSArray<AWFWeatherObject *> *)resultsForEndpointWithKey:
        (nonnull NSString *)key;

    Swift

    func resultsForEndpoint(withKey key: String) -> [AWFWeatherObject]?

    Parameters

    key

    The reference key associated with the endpoint to return available results for

    Return Value

    An array of AWFWeatherObject instances returned for the endpoint

  • Returns the endpoint within the batch associated with the specified reference key.

    Declaration

    Objective-C

    - (nullable AWFWeatherEndpoint *)endpointForKey:(nonnull NSString *)key;

    Swift

    func endpoint(forKey key: String) -> AWFWeatherEndpoint?

    Parameters

    key

    The reference key associated with the endpoint

    Return Value

    The endpoint for the reference key

  • Returns the url path for the specified endpoint instance by combining the endpoint’s path and request options.

    Declaration

    Objective-C

    - (nullable NSString *)URLPathForEndpoint:(nonnull AWFWeatherEndpoint *)endpoint
                            appendQueryString:(BOOL)queryString;

    Swift

    func urlPath(for endpoint: AWFWeatherEndpoint, appendQueryString queryString: Bool) -> String?

    Parameters

    endpoint

    The endpoint to return the url path for

    queryString

    Whether or not the options query string should be included in the url path