import {
  afterEach,
  describe,
  globalExpect,
  init_dist,
  it
} from "../../chunk-GCCHFONX.mjs";
import {
  Blindpay,
  init_client
} from "../../chunk-ES7RXEM7.mjs";
import "../../chunk-GEDDLCJY.mjs";
import "../../chunk-LK3JPQ6I.mjs";
import "../../chunk-CNNEROQ7.mjs";
import "../../chunk-GNDAATIJ.mjs";
import "../../chunk-VKN2AMCW.mjs";
import "../../chunk-LUDGZPXY.mjs";
import "../../chunk-3CZJEDS5.mjs";
import "../../chunk-UCAW3RTZ.mjs";
import "../../chunk-M6IYYMRW.mjs";
import "../../chunk-HKFAJXJG.mjs";
import "../../chunk-QVOSGLUO.mjs";
import "../../chunk-2DAKB5XK.mjs";
import "../../chunk-QHMIK7U3.mjs";
import "../../chunk-LLWEHHKB.mjs";
import {
  __async,
  __commonJS
} from "../../chunk-OBKEW4AQ.mjs";

// src/resources/webhooks/webhooks.test.ts
var require_webhooks_test = __commonJS({
  "src/resources/webhooks/webhooks.test.ts"(exports) {
    init_dist();
    init_client();
    describe("Webhooks", () => {
      afterEach(() => fetchMock.resetMocks());
      const blindpay = new Blindpay("test-key");
      describe("Create webhook endpoint", () => {
        it("should create a webhook endpoint", () => __async(null, null, function* () {
          const mockedWebhookEndpoint = {
            id: "we_000000000000"
          };
          fetchMock.mockResponseOnce(JSON.stringify(mockedWebhookEndpoint), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.create({
            instanceId: "in_000000000000",
            url: "https://example.com/webhook",
            events: ["receiver.new"]
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedWebhookEndpoint);
        }));
      });
      describe("List webhook endpoints", () => {
        it("should list webhook endpoints", () => __async(null, null, function* () {
          const mockedWebhookEndpoints = [
            {
              id: "we_000000000000",
              url: "https://example.com/webhook",
              events: ["receiver.new"],
              last_event_at: "2024-01-01T00:00:00.000Z",
              instance_id: "in_000000000000",
              created_at: "2021-01-01T00:00:00Z",
              updated_at: "2021-01-01T00:00:00Z"
            }
          ];
          fetchMock.mockResponseOnce(JSON.stringify(mockedWebhookEndpoints), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.list({
            instanceId: "in_000000000000"
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedWebhookEndpoints);
        }));
      });
      describe("Delete webhook endpoint", () => {
        it("should delete a webhook endpoint", () => __async(null, null, function* () {
          const mockedResponse = { data: null };
          fetchMock.mockResponseOnce(JSON.stringify(mockedResponse), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.delete({
            instanceId: "in_000000000000",
            id: "we_000000000000"
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedResponse);
        }));
      });
      describe("Get webhook endpoint secret", () => {
        it("should get webhook endpoint secret", () => __async(null, null, function* () {
          const mockedWebhookSecret = { key: "whsec_000000000000" };
          fetchMock.mockResponseOnce(JSON.stringify(mockedWebhookSecret), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.getSecret({
            instanceId: "in_000000000000",
            id: "we_000000000000"
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedWebhookSecret);
        }));
      });
      describe("Get webhook portal access url", () => {
        it("should get webhook portal access url", () => __async(null, null, function* () {
          const mockedWebhookUrl = { url: "https://example.com/webhook" };
          fetchMock.mockResponseOnce(JSON.stringify(mockedWebhookUrl), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.getPortalAccessUrl({
            instanceId: "in_000000000000"
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedWebhookUrl);
        }));
      });
    });
  }
});
export default require_webhooks_test();
