loadByEventId method

Future loadByEventId({
  1. required String eventId,
  2. required String accessKey,
})

Implementation

Future<dynamic> loadByEventId(
    {required String eventId, required String accessKey}) async {
  Uri uri1 = Uri.parse("https://api.vimeo.com/me/live_events/$eventId");

  Uri uri2 = Uri.parse(
      "https://api.vimeo.com/me/live_events/$eventId/m3u8_playback");
  var res = await Future.wait([
    http.get(uri1, headers: {"Authorization": "Bearer $accessKey"}),
    http.get(uri2, headers: {"Authorization": "Bearer $accessKey"})
  ]);

  if (res[1].statusCode != 200) {
    throw VimeoError(
        error: res[1].reasonPhrase,
        developerMessage: "Please check your video id",
        errorCode: res[1].statusCode);
  }

  return [jsonDecode(res[0].body), jsonDecode(res[1].body)];
}