class EmailAlertSignupContentItemPresenter

  def initialize(policy, update_type="major")
    @policy = policy
    @update_type = update_type
  end

  def exportable_attributes
    {
      format: "email_alert_signup",
      content_id: policy.email_alert_signup_content_id,
      title: policy.name,
      description: "",
      public_updated_at: public_updated_at,
      locale: "en",
      update_type: update_type,
      publishing_app: "policy-publisher",
      rendering_app: "email-alert-frontend",
      routes: routes,
      details: details,
      links: { parent: [policy.content_id] },
    }
  end

  def base_path
    "#{policy.base_path}/email-signup"
  end

private
  attr_reader :policy, :update_type

  def public_updated_at
    policy.updated_at
  end

  def routes
    [
      {
        path: base_path,
        type: "exact",
      },
    ]
  end

  def details
    {
      breadcrumbs: breadcrumbs,
      summary: summary,
      tags: {
        policy: [policy.slug],
      },
      govdelivery_title: "#{policy.name} policy",
    }
  end

  def summary
    %q[
      You'll get an email each time a document about
      this policy is published or updated.
    ]
  end

  def breadcrumbs
    [
      {
        title: policy.name,
        link: policy.base_path,
      }
    ]
  end

end

class EmailAlertSignupContentItemPresenter

  def initialize(policy, update_type="major")
    @policy = policy
    @update_type = update_type
  end

  def exportable_attributes
    {
      format: "email_alert_signup",
      content_id: policy.email_alert_signup_content_id,
      title: policy.name,
      description: "",
      public_updated_at: public_updated_at,
      locale: "en",
      update_type: update_type,
      publishing_app: "policy-publisher",
      rendering_app: "email-alert-frontend",
      routes: routes,
      details: details,
      links: { parent: [policy.content_id] },
    }
  end

  def base_path
    "#{policy.base_path}/email-signup"
  end

private
  attr_reader :policy, :update_type

  def public_updated_at
    policy.updated_at
  end

  def routes
    [
      {
        path: base_path,
        type: "exact",
      },
    ]
  end

  def details
    {
      email_alert_type: "policies",
      breadcrumbs: breadcrumbs,
      summary: summary,
      tags: {
        policy: [policy.slug],
      },
      govdelivery_title: "#{policy.name} policy",
    }
  end

  def summary
    %q[
      You'll get an email each time a document about
      this policy is published or updated.
    ]
  end

  def breadcrumbs
    [
      {
        title: policy.name,
        link: policy.base_path,
      }
    ]
  end

end

Include email_alert_type value in details hash for email alert signup
Include email_alert_type value in details hash for email alert signup

Including this will help email-alert-frontend construct the correct payload
to send to the email-alert-api for subscriptions.
