import { GenericVerifiableCredential } from "./common";

export interface AgreeVerifiableCredential {
  "@context": string;
  "@type": string;
  object: Record<string, unknown>;
}

// Note that previous VCs may have additional fields.
// https://endorser.ch/doc/html/transactions.html#id4
export interface GiveVerifiableCredential extends GenericVerifiableCredential {
  "@context"?: string;
  "@type": "GiveAction";
  agent?: { identifier: string };
  description?: string;
  fulfills?: { "@type": string; identifier?: string; lastClaimId?: string }[];
  identifier?: string;
  image?: string;
  object?: { amountOfThisGood: number; unitCode: string };
  provider?: GenericVerifiableCredential;
  recipient?: { identifier: string };
}

// Note that previous VCs may have additional fields.
// https://endorser.ch/doc/html/transactions.html#id8
export interface OfferVerifiableCredential extends GenericVerifiableCredential {
  "@context"?: string;
  "@type": "Offer";
  description?: string;
  includesObject?: { amountOfThisGood: number; unitCode: string };
  itemOffered?: {
    description?: string;
    isPartOf?: {
      identifier?: string;
      lastClaimId?: string;
      "@type"?: string;
      name?: string;
    };
  };
  offeredBy?: { identifier: string };
  recipient?: { identifier: string };
  validThrough?: string;
}

// Note that previous VCs may have additional fields.
// https://endorser.ch/doc/html/transactions.html#id7
export interface PlanVerifiableCredential extends GenericVerifiableCredential {
  "@context": "https://schema.org";
  "@type": "PlanAction";
  name: string;
  agent?: { identifier: string };
  description?: string;
  identifier?: string;
  lastClaimId?: string;
  location?: {
    geo: { "@type": "GeoCoordinates"; latitude: number; longitude: number };
  };
}

// AKA Registration & RegisterAction
export interface RegisterVerifiableCredential {
  "@context": string;
  "@type": "RegisterAction";
  agent: { identifier: string };
  identifier?: string;
  object: string;
  participant?: { identifier: string };
}
