listAllLicenseKeyInstances method

Future<Map<String, dynamic>> listAllLicenseKeyInstances({
  1. int? licenseKeyId,
})

Implementation

Future<Map<String, dynamic>> listAllLicenseKeyInstances(
    {int? licenseKeyId}) async {
  if (apiKey.isEmpty) {
    return {'error': 'API key is empty'};
  }

  Options dioOptions = Options(
    headers: {
      "Authorization": "Bearer $apiKey",
      "Accept": "application/vnd.api+json",
      "Content-Type": "application/vnd.api+json",
    },
  );

  String url = "https://api.lemonsqueezy.com/v1/license-key-instances";

  if (licenseKeyId != null) {
    url += "?filter[license_key_id]=$licenseKeyId";
  }

  try {
    Response response = await dio.get(
      url,
      options: dioOptions,
    );

    return response.data;
  } catch (e) {
    return {'error': e.toString()};
  }
}