updateLicenseKey method

Future<void> updateLicenseKey(
  1. int id, {
  2. int? activationLimit,
  3. bool? disabled,
})

Implementation

Future<void> updateLicenseKey(
  int id, {
  int? activationLimit,
  bool? disabled,
}) async {
  if (apiKey.isEmpty) {
    throw Exception('API key is empty');
  }

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

  try {
    await dio.patch(
      "https://api.lemonsqueezy.com/v1/license-keys/$id",
      options: dioOptions,
      data: {
        "data": {
          "type": "license-keys",
          "id": "$id",
          "attributes": {
            "activation_limit": activationLimit,
            "disabled": disabled,
          }
        }
      },
    );
  } catch (e) {
    throw Exception('Failed to update license key: $e');
  }
}