
enum TraktResponseClass {

  success,


  duplicate,


  invalid,


  rateLimited,


  unauthorized,


  transient,
}


class TraktScrobbleOutcome {
  final TraktResponseClass cls;


  final Duration? retryAfter;

  const TraktScrobbleOutcome(this.cls, {this.retryAfter});
}


TraktResponseClass classifyTraktStatus(int statusCode) {
  if (statusCode >= 200 && statusCode < 300) return TraktResponseClass.success;
  switch (statusCode) {
    case 401:
      return TraktResponseClass.unauthorized;
    case 409:
      return TraktResponseClass.duplicate;
    case 422:
      return TraktResponseClass.invalid;
    case 429:
      return TraktResponseClass.rateLimited;
    default:
      return TraktResponseClass.transient;
  }
}
