41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
declare( strict_types=1 );
|
|
|
|
namespace StreamGoals\Overlay;
|
|
|
|
/**
|
|
* Read-only data the overlay widgets need. Rows are raw associative arrays shaped like the
|
|
* sg_* tables; the payload builders do all privacy filtering, so implementations need not.
|
|
*/
|
|
interface OverlayDataSource {
|
|
|
|
/** The goal currently shown on stream (status active, newest first), or null. */
|
|
public function activeGoal(): ?array;
|
|
|
|
/** Sum of completed donations for the goal, in minor units (base or total per counts_fees). */
|
|
public function raisedMinor( array $goal ): int;
|
|
|
|
/** Raw sg_state value for a goal key, or null. */
|
|
public function stateValue( int $goalId, string $key ): ?string;
|
|
|
|
/** @return array{label:string,value:int} */
|
|
public function counter( int $goalId ): array;
|
|
|
|
/**
|
|
* Donations newer than $sinceId (ascending id, at most $limit rows). With null, return the single
|
|
* newest row so the caller can establish a baseline.
|
|
*
|
|
* @return array<int,array<string,mixed>>
|
|
*/
|
|
public function donations( ?int $sinceId, int $limit ): array;
|
|
|
|
/**
|
|
* Bonus event names that fired (and were not reversed) per donation, in firing order. One lookup
|
|
* for the whole page. Raw stored strings; Payloads sanitizes them. Donations without bonuses may be omitted.
|
|
*
|
|
* @param int[] $donationIds
|
|
* @return array<int,string[]> donation id => event names
|
|
*/
|
|
public function bonusesFor( array $donationIds ): array;
|
|
}
|