sailfork / t3code-github / .repos/ alchemy-effect/ packages/ stripe/ src/ RetrieveWebhookEndpoint.ts

import type {
  GetWebhookEndpointError,
  GetWebhookEndpointRequest,
  WebhookEndpoint as StripeWebhookEndpoint,
} from "@distilled.cloud/stripe/stripe";
import * as Binding from "alchemy/Binding";
import type { RuntimeContext } from "alchemy/RuntimeContext";
import type * as Effect from "effect/Effect";
import type { WebhookEndpoint } from "./WebhookEndpoint.ts";

export interface RetrieveWebhookEndpointRequest extends Omit<
  GetWebhookEndpointRequest,
  "webhook_endpoint"
> {}

/**
 * Retrieve a bound Stripe Webhook Endpoint over HTTP.
 *
 * ### Reading a Webhook Endpoint
 * **Example:** Bind and retrieve
 * ```typescript
 * const retrieve = yield* Stripe.RetrieveWebhookEndpoint(hook);
 * const live = yield* retrieve();
 * ```
 *
 * @binding
 * @product Webhook
 */
export interface RetrieveWebhookEndpoint extends Binding.Service<
  RetrieveWebhookEndpoint,
  "Stripe.RetrieveWebhookEndpoint",
  (
    webhookEndpoint: WebhookEndpoint,
  ) => Effect.Effect<
    (
      request?: RetrieveWebhookEndpointRequest,
    ) => Effect.Effect<StripeWebhookEndpoint, GetWebhookEndpointError, RuntimeContext>
  >
> {}

export const RetrieveWebhookEndpoint = Binding.Service<RetrieveWebhookEndpoint>(
  "Stripe.RetrieveWebhookEndpoint",
);