refresh method

Future refresh()

Requests updated information from the Reddit API and updates the current object properties.

Implementation

Future<dynamic> refresh() async {
  final response = await reddit.get(infoPath, params: infoParams);
  if (response is Map) {
    _data = response;
  } else if (response is List) {
    // TODO(bkonyi): this is for populating a Submission, since requesting
    // Submission returns a list of listings, containing a Submission at [0]
    // and a listing of Comments at [1]. This probably needs to be changed
    // at some point to be a bit more robust, but it works for now.
    _data = response[0]['listing'][0].data;
    return [this, response[1]['listing']];
  } else {
    throw DRAWInternalError('Refresh response is of unknown type: '
        '${response.runtimeType}.');
  }
  return this;
}