Skip to content

AdLoader

Anirudh Ramanan edited this page Jan 22, 2020 · 1 revision

The AdLoader is responsible for fetching the ad response from network (by delegating to network layer) or local cache, and then delegates it to the parser and validator for parsing and validation.

The requestAds method expects the request object along with the success and error callbacks as parameters.

API:

  • requestAds(param: T, onSuccess: (data: VMAPData) -> Unit, onFailure: (errorType: AdErrorType, message: String?) -> Unit)

    • param: is one of StringAdRequest or NetworkAdRequest
    • onSuccess: function which is called on successful fetching and parsing of the response. It has VMAPData object as a parameter
    • onFailure: function which is called for failure cases. Failure can happen for multiple reasons: network failure, parsing failure, validation failure etc

Flow:

  • StringAdLoader: It expects the xml response to be already provided by the client. Hence it is directly delegated to the parser.

  • NetworkAdLoader: It expects a url to be present. It interacts with the network layer to fetch the response and then delegates it to the parser.

Clone this wiki locally