getVitalAPIHeaders function

Future<Map<String, String>> getVitalAPIHeaders()

Implementation

Future<Map<String, String>> getVitalAPIHeaders() async {
  Map<String, String> headers = {};

  String versionKey;

  if (Platform.isIOS || Platform.isMacOS) {
    versionKey = "X-Vital-iOS-SDK-Version";
  } else if (Platform.isAndroid || Platform.isLinux) {
    versionKey = "X-Vital-Android-SDK-Version";
  } else {
    throw Exception(
        "Unsupported Flutter platform: ${Platform.operatingSystem}");
  }

  headers["Authorization"] = "Bearer ${await getAccessToken()}";
  headers[versionKey] = await sdkVersion();

  return headers;
}