| 1 | import type { |
| 2 | GetProductError, |
| 3 | GetProductRequest, |
| 4 | Product as StripeProduct, |
| 5 | } from "@distilled.cloud/stripe/stripe"; |
| 6 | import type * as Effect from "effect/Effect"; |
| 7 | import * as Binding from "../Binding.ts"; |
| 8 | import type { RuntimeContext } from "../RuntimeContext.ts"; |
| 9 | import type { Product } from "./Product.ts"; |
| 10 | |
| 11 | export interface RetrieveProductRequest extends Omit<GetProductRequest, "id"> {} |
| 12 | |
| 13 | /** |
| 14 | * Retrieve a bound Stripe Product over HTTP. Pass the Product resource, |
| 15 | * a `prod_…` id string, or an Effect resolving to a Product. |
| 16 | * |
| 17 | * ### Reading a Product |
| 18 | * **Example:** Bind and retrieve |
| 19 | * ```typescript |
| 20 | * const retrieve = yield* Stripe.RetrieveProduct(product); |
| 21 | * const live = yield* retrieve(); |
| 22 | * ``` |
| 23 | * |
| 24 | * **Example:** By id |
| 25 | * ```typescript |
| 26 | * const retrieve = yield* Stripe.RetrieveProduct("prod_123"); |
| 27 | * const live = yield* retrieve(); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | * @product Product |
| 32 | */ |
| 33 | export interface RetrieveProduct extends Binding.Service< |
| 34 | RetrieveProduct, |
| 35 | "Stripe.RetrieveProduct", |
| 36 | ( |
| 37 | product: string | Product, |
| 38 | ) => Effect.Effect< |
| 39 | ( |
| 40 | request?: RetrieveProductRequest, |
| 41 | ) => Effect.Effect<StripeProduct, GetProductError, RuntimeContext> |
| 42 | > |
| 43 | > {} |
| 44 | |
| 45 | export const RetrieveProduct = Binding.Service<RetrieveProduct>( |
| 46 | "Stripe.RetrieveProduct", |
| 47 | ); |