switchToOrganization method

void switchToOrganization(
  1. FakeAgent a, {
  2. required String actor,
  3. required String reason,
  4. required String correlationId,
})

Switches a to organization for resolve_i1 with one audit row agent.billing_mode.set (10 11: an agent already there keeps its row and gets a row with no_change).

Implementation

void switchToOrganization(
  FakeAgent a, {
  required String actor,
  required String reason,
  required String correlationId,
}) {
  final from = a.billingMode;
  final holder = holderOf(a);
  final details = policyDetails(from, holder, 'organization', null, reason);
  if (from != 'organization') setPolicy(a, 'organization', null);
  audit.add(
    world,
    action: 'agent.billing_mode.set',
    actor: actor,
    resourceKind: 'agent',
    resourceId: a.id,
    details: {...details, if (from == 'organization') 'no_change': true},
    correlationId: correlationId,
  );
}