createCompPlanGrant method
Create a comp_plan grant for a user or org. Plan must be one of 'professional', 'team', 'enterprise'.
Implementation
Future<AdminGrantModel> createCompPlanGrant({
String? targetUserId,
String? targetOrgId,
required String plan,
String? reason,
DateTime? endsAt,
}) async {
assert(
(targetUserId == null) ^ (targetOrgId == null),
'Exactly one of targetUserId / targetOrgId must be provided',
);
final response = await _client
.from('admin_grants')
.insert({
'target_user_id': ?targetUserId,
'target_org_id': ?targetOrgId,
'grant_type': 'comp_plan',
'plan': plan,
'reason': ?reason,
'ends_at': ?endsAt?.toUtc().toIso8601String(),
'granted_by': _client.auth.currentUser?.id,
})
.select()
.single();
return AdminGrantModel.fromJson(response);
}