| 166 | }); |
| 167 | |
| 168 | const customerIds = () => |
| 169 | Effect.gen(function* () { |
| 170 | const response = yield* Effect.promise(() => |
| 171 | fetch(`${autumnUrl}/v1/customers.list`, { |
| 172 | method: "POST", |
| 173 | headers: { "content-type": "application/json" }, |
| 174 | body: "{}", |
| 175 | }), |
| 176 | ); |
| 177 | if (!response.ok) { |
| 178 | return yield* Effect.fail( |
| 179 | `autumn customers.list responded ${response.status}: ${yield* Effect.promise(() => response.text())}`, |
| 180 | ); |
| 181 | } |
| 182 | const body = (yield* Effect.promise(() => response.json())) as { |
| 183 | readonly list?: ReadonlyArray<{ readonly id?: string }>; |
| 184 | }; |
| 185 | return (body.list ?? []).map((customer) => customer.id ?? ""); |
| 186 | }); |
| 187 | |
| 188 | const settleCheckout = (sessionId: string) => |
| 189 | Effect.gen(function* () { |