prizerail 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -105,6 +105,15 @@ for await (const drawing of campaign.drawings.all({ status: "paid" })) {
105
105
  const guarantees = await campaign.guarantees.list()
106
106
  ```
107
107
 
108
+ To answer a user who asks whether their entries counted, look them up in one drawing by the id you sent:
109
+
110
+ ```ts
111
+ const found = await campaign.drawings.entrant(drawingId, entrantId)
112
+ // { entered, entries, position, receivedAt, drawn, winner }
113
+ ```
114
+
115
+ `entered` is false, not an error, for someone who isn't in the drawing. `winner` stays null for everyone until `drawn` is true. See [Look up an entrant](https://docs.prizerail.com/api/drawings#look-up-an-entrant).
116
+
108
117
  ## Draw now, in the sandbox
109
118
 
110
119
  In the sandbox, `campaign.drawings.run(id)` closes a drawing's entries now and draws it, so you can see a whole draw without waiting for its cutoff. It resolves with the drawing, usually settled within seconds. Anywhere else it throws a `PrizerailError` with code `sandbox_only`. See [Draw now](https://docs.prizerail.com/api/drawings#draw-now-sandbox-only).
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Http } from "./http.js";
2
- import type { Campaign, Drawing, DrawingRef, DrawingStatus, DrawingsPage, Entrant, EntrantEvent, EntriesPage, Guarantee, SendEntriesResponse, SentEntrant } from "./types.js";
2
+ import type { Campaign, Drawing, DrawingRef, DrawingStatus, DrawingsPage, Entrant, EntrantEvent, EntrantLookup, EntriesPage, Guarantee, SendEntriesResponse, SentEntrant } from "./types.js";
3
3
  import { type DrawProof, type VerifyResult } from "./verify.js";
4
- export declare const VERSION = "1.1.1";
4
+ export declare const VERSION = "1.2.0";
5
5
  /** The API takes up to this many entries per request. */
6
6
  export declare const ENTRIES_PER_REQUEST = 1000;
7
7
  export type PrizerailOptions = {
@@ -146,6 +146,13 @@ export declare class DrawingsClient {
146
146
  pageSize?: number;
147
147
  }): AsyncGenerator<Drawing>;
148
148
  get(id: string): Promise<Drawing>;
149
+ /**
150
+ * Whether one entrant's entries reached a drawing, how many it holds, and
151
+ * what they won once it's drawn, from what Prizerail received. Pass the
152
+ * `entrantId` as you sent it. Someone not in the drawing resolves with
153
+ * `entered: false`, not an error.
154
+ */
155
+ entrant(id: string, entrantId: string): Promise<EntrantLookup>;
149
156
  /**
150
157
  * Sandbox only: closes the drawing's entries now and draws it,
151
158
  * instead of waiting for its cutoff. Resolves with the drawing, settled or
package/dist/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PrizerailCutoffError, PrizerailDrawingChangedError, PrizerailError, } from "./errors.js";
2
2
  import { Http } from "./http.js";
3
3
  import { verifyDraw } from "./verify.js";
4
- export const VERSION = "1.1.1";
4
+ export const VERSION = "1.2.0";
5
5
  const badPage = (detail) => new PrizerailError(0, "invalid_response", `Paging stopped: ${detail}.`);
6
6
  /** The API takes up to this many entries per request. */
7
7
  export const ENTRIES_PER_REQUEST = 1000;
@@ -389,6 +389,15 @@ export class DrawingsClient {
389
389
  async get(id) {
390
390
  return (await this.campaign.http.request("GET", this.campaign.path(`/drawings/${encodeURIComponent(id)}`))).drawing;
391
391
  }
392
+ /**
393
+ * Whether one entrant's entries reached a drawing, how many it holds, and
394
+ * what they won once it's drawn, from what Prizerail received. Pass the
395
+ * `entrantId` as you sent it. Someone not in the drawing resolves with
396
+ * `entered: false`, not an error.
397
+ */
398
+ async entrant(id, entrantId) {
399
+ return this.campaign.http.request("GET", this.campaign.path(`/drawings/${encodeURIComponent(id)}/entrant`), { query: { entrantId } });
400
+ }
392
401
  /**
393
402
  * Sandbox only: closes the drawing's entries now and draws it,
394
403
  * instead of waiting for its cutoff. Resolves with the drawing, settled or
package/dist/types.d.ts CHANGED
@@ -110,6 +110,46 @@ export type Drawing = {
110
110
  prizeTableId: string | null;
111
111
  };
112
112
  };
113
+ /** One entrant in one drawing, from `drawings.entrant()`. */
114
+ export type EntrantLookup = {
115
+ drawing: {
116
+ id: string;
117
+ kind: DrawingKind;
118
+ number: number | null;
119
+ drawAt: string;
120
+ cutoffAt: string;
121
+ status: DrawingStatus;
122
+ };
123
+ entrantId: string;
124
+ /** Whether the drawing holds entries for this id. */
125
+ entered: boolean;
126
+ /**
127
+ * Their number of entries, or null if they didn't enter. 1 in a guarantee
128
+ * draw, which gives everyone who entered the period one entry.
129
+ */
130
+ entries: number | null;
131
+ /**
132
+ * Their place in the locked entrant list. Null until the drawing locks,
133
+ * shortly after the cutoff. Set from the start in a guarantee draw.
134
+ */
135
+ position: number | null;
136
+ /**
137
+ * When their first entry for this drawing arrived. In a guarantee draw,
138
+ * when the draw was made.
139
+ */
140
+ receivedAt: string | null;
141
+ /**
142
+ * Whether the winners are known: true once settled or paid. Until then
143
+ * `winner` is null for everyone, so null alone doesn't mean they lost.
144
+ */
145
+ drawn: boolean;
146
+ /** Their win, or null. `position` is their slot in the drawing's winners. */
147
+ winner: {
148
+ position: number;
149
+ amountCents: number;
150
+ heldForManualPayout: boolean;
151
+ } | null;
152
+ };
113
153
  export type DrawingsPage = {
114
154
  drawings: Drawing[];
115
155
  nextBefore: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prizerail",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "The Prizerail SDK: send entries, read draws and verify them.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.prizerail.com",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prizerail",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Integrate Prizerail prize draws into an app, check an integration end to end, and look up or verify draws.",
5
5
  "author": {
6
6
  "name": "Prizerail",