/**
 * 认种记录同步事件
 * 用于同步到 mining-admin-service
 */
export class AdoptionSyncedEvent {
  static readonly EVENT_TYPE = 'AdoptionSynced';
  static readonly AGGREGATE_TYPE = 'Adoption';

  constructor(
    public readonly originalAdoptionId: bigint,
    public readonly accountSequence: string,
    public readonly treeCount: number,
    public readonly adoptionDate: Date,
    public readonly status: string | null,
    public readonly contributionPerTree: string,
  ) {}

  toPayload(): Record<string, any> {
    return {
      eventType: AdoptionSyncedEvent.EVENT_TYPE,
      originalAdoptionId: this.originalAdoptionId.toString(),
      accountSequence: this.accountSequence,
      treeCount: this.treeCount,
      adoptionDate: this.adoptionDate.toISOString(),
      status: this.status,
      contributionPerTree: this.contributionPerTree,
    };
  }
}
