@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 52 lines 1.58 KB
Raw
1 import { GetAccountPerson } from "@distilled.cloud/stripe/stripe";
2 import * as Binding from "alchemy/Binding";
3 import type { ResourceLike } from "alchemy/Resource";
4 import * as Effect from "effect/Effect";
5 import * as Layer from "effect/Layer";
6 import type { AccountPerson } from "./AccountPerson.ts";
7 import { RetrieveAccountPerson } from "./RetrieveAccountPerson.ts";
8 import {
9 asStringEffect,
10 attachStripeToken,
11 authorizeWith,
12 resolveStripeAuth,
13 } from "./StripeHttp.ts";
14
15 /**
16 * HTTP implementation of {@link RetrieveAccountPerson}. Retrieve takes
17 * both `account` and `person`.
18 *
19 * @layer
20 * @product Account
21 * @provides Stripe.RetrieveAccountPerson
22 */
23 export const RetrieveAccountPersonHttp = Layer.effect(
24 RetrieveAccountPerson,
25 Effect.gen(function* () {
26 const ambient = yield* resolveStripeAuth;
27
28 return Effect.fn(function* (person: AccountPerson) {
29 const host = yield* Binding.Host;
30 const bound = yield* attachStripeToken(
31 person as unknown as ResourceLike,
32 ["accounts_read"],
33 "Stripe.RetrieveAccountPerson",
34 );
35 const id = yield* asStringEffect(person.id);
36 const account = yield* asStringEffect(person.account);
37 const auth = host !== undefined ? authorizeWith(bound) : ambient.authorize;
38
39 return Effect.fn(`Stripe.RetrieveAccountPerson(${person.LogicalId})`)(function* (request?: {
40 expand?: string[];
41 }) {
42 return yield* auth(
43 GetAccountPerson({
44 ...request,
45 person: yield* id,
46 account: yield* account,
47 }),
48 );
49 });
50 });
51 }),
52 );