export default {
  name: "Verify Email with Verifly",
  description: "Verify one email address using the Verifly Email Verification API.",
  key: "verifly-verify-email",
  version: "0.0.1",
  type: "action",
  props: {
    apiKey: {
      type: "string",
      label: "Verifly API Key",
      secret: true
    },
    email: {
      type: "string",
      label: "Email"
    }
  },
  async run({ $ }) {
    const response = await fetch(`https://verifly.email/api/v1/verify?email=${encodeURIComponent(this.email)}`, {
      headers: {
        Authorization: `Bearer ${this.apiKey}`
      }
    });
    const data = await response.json();
    if (!response.ok) {
      throw new Error(data.error || data.message || `Verifly API ${response.status}`);
    }
    $.export("$summary", `Verified ${this.email}`);
    return data;
  }
};
