redeem method

Future<Redemption> redeem(
  1. String code
)

Redeems code (3-30 characters after trimming; case-insensitive, spaces and dashes ignored server-side). Errors: code_not_found, code_expired, code_disabled, redemption_limit_reached, rate_limited, and for referral codes the referral errors of applyCode with ClikgateException.offlineTouchId set. Clears the read cache.

Implementation

Future<Redemption> redeem(String code) async {
  final trimmed = code.trim();
  if (trimmed.length < 3 || trimmed.length > 30) {
    throw _invalid('The code must be 3-30 characters', 'code');
  }
  final j = await _client.call(
    feature: ClikgateFeatures.offlineCodes,
    method: 'POST',
    path: '/v1/sdk/codes/redeem',
    body: {'code': trimmed},
    write: true,
  );
  return Redemption.fromJson(j);
}