Record Class Quote

java.lang.Object
java.lang.Record
com.tnsai.payment.Quote
Record Components:
quoteId - broker-issued identifier; opaque to the caller, presented on PaymentBroker.settle(com.tnsai.payment.Quote)
payer - who's paying
payee - who's getting paid
service - what's being paid for
priceUSD - broker-computed total in USD
idempotencyKey - unique per logical payment intent; caller supplies it so retries land on the same payment
issuedAt - wall-clock instant the broker minted the quote
expiresAt - wall-clock instant past which the quote is no longer settle-able

public record Quote(String quoteId, AgentPrincipal payer, AgentPrincipal payee, Service service, BigDecimal priceUSD, String idempotencyKey, Instant issuedAt, Instant expiresAt) extends Record
Priced commitment for a Service between two AgentPrincipal agents (TNS-298). Returned by PaymentBroker.quote(com.tnsai.identity.AgentPrincipal, com.tnsai.identity.AgentPrincipal, com.tnsai.payment.Service) and consumed by PaymentBroker.settle(com.tnsai.payment.Quote).

Quotes are valid until expiresAt; the broker rejects settlement attempts past expiry. Idempotency keys let callers retry a settlement (network-flaky path) without re-charging.

Since:
0.10.0 (TNS-298)
  • Constructor Details

    • Quote

      public Quote(String quoteId, AgentPrincipal payer, AgentPrincipal payee, Service service, BigDecimal priceUSD, String idempotencyKey, Instant issuedAt, Instant expiresAt)
      Creates an instance of a Quote record class.
      Parameters:
      quoteId - the value for the quoteId record component
      payer - the value for the payer record component
      payee - the value for the payee record component
      service - the value for the service record component
      priceUSD - the value for the priceUSD record component
      idempotencyKey - the value for the idempotencyKey record component
      issuedAt - the value for the issuedAt record component
      expiresAt - the value for the expiresAt record component
  • Method Details

    • isExpired

      public boolean isExpired(Instant now)
      true when now falls strictly past expiresAt.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • quoteId

      public String quoteId()
      Returns the value of the quoteId record component.
      Returns:
      the value of the quoteId record component
    • payer

      public AgentPrincipal payer()
      Returns the value of the payer record component.
      Returns:
      the value of the payer record component
    • payee

      public AgentPrincipal payee()
      Returns the value of the payee record component.
      Returns:
      the value of the payee record component
    • service

      public Service service()
      Returns the value of the service record component.
      Returns:
      the value of the service record component
    • priceUSD

      public BigDecimal priceUSD()
      Returns the value of the priceUSD record component.
      Returns:
      the value of the priceUSD record component
    • idempotencyKey

      public String idempotencyKey()
      Returns the value of the idempotencyKey record component.
      Returns:
      the value of the idempotencyKey record component
    • issuedAt

      public Instant issuedAt()
      Returns the value of the issuedAt record component.
      Returns:
      the value of the issuedAt record component
    • expiresAt

      public Instant expiresAt()
      Returns the value of the expiresAt record component.
      Returns:
      the value of the expiresAt record component