Loading Data

All requests for weather data to the Aeris API from within your application are made using a series of object loaders, one object loader for each API endpoint. These loaders automatically handle the request and parsing of API responses and return consistent, easy-to-use object models back to your application, preventing you from having to worry about response property or format changes from the API.

Each object model that is returned to your application from object loaders is a subclass of AWFObject whose data is transformed into the appropriate model class based on the loader requesting it. Additionally, even if your object loader is configured to only request a single item (setting a limit of 1 or the API’s response is a single object), the object loader will still return an array in its completion block.

To use an object loader, just create an instance of the object loader corresponding to the API endpoint you wish to request data for:

AWFPlacesLoader *loader = [[AWFPlacesLoader alloc] init];
let loader = AWFPlacesLoader()

Then provide any additional options to the object loader’s options property, which is an instance of AWFRequestOptions:


loader.options.limit = 5;
[loader.options addFilter:[AWFRequestFilter filterWithName:@“poi”]];
loader.options.limit = 5
loader.options.addFilter(AWFRequestFilter(name: "poi"))

Finally, perform the request on the object loader. The parsed data will be returned as an array of AWFObject subclass instances tied to the specific object loader to the completion block you provide, along with any error that occurred during the request:

AWFPlace *place = [AWFPlace placeWithCity:@"seattle" state:@"wa" country:@"us"];
[loader getPlace:place options:nil completion:^(NSArray *objects, NSError *error) {
	if ([objects count] > 0) {
		// do something
	}
}];
let place = AWFPlace(city: "seattle", state: "wa", country: "us")
loader.getPlace(place, options: nil) { (objects, error) in
	if let objects = objects, objects.count > 0 {
		// do something
	}
}

You can also assign a new AWFRequestOptions instance on your loader and each request thereafter will use the new options. Alternatively, you can remove all default options for a loader's request by setting the options property to nil:

AWFRequestOptions *newOptions = [AWFRequestOptions options];
newOptions.limit = 50;
loader.options = newOptions;
loader.options = nil;
let newOptions = AWFRequestOptions()
newOptions.limit = 50
loader.options = newOptions
loader.options = nil

If you want to apply additional options to a specific request that aren't the assigned on the default options property of your loader, you can also provide an AWFRequestOptions instance to the actual request. Using this method will not override the default values on the loader's options instance:

AWFRequestOptions *tempOptions = [AWFRequestOptions options];
tempOptions.limit = 50;

[loader getPlace:place options:tempOptions completion:^(NSArray *objects, NSError *error) {
	if ([objects count] > 0) {
		// do something
	}
}];
let tempOptions = AWFRequestOptions()
tempOptions.limit = 50

loader.getPlace(place, options: tempOptions) { (objects, error) in
	if let objects = objects, objects.count > 0 {
		// do something
	}
}

Object Loaders

For the full listing of object loaders and models currently supported, review the Object Loaders reference matrix.

Last modified: November 02, 2017