# frozen_string_literal: true

module SynorHosting
  # Domain status
  module DomainStatus
    PENDING = "pending"
    ACTIVE = "active"
    SUSPENDED = "suspended"
    EXPIRED = "expired"
  end

  # DNS record types
  module DnsRecordType
    A = "A"
    AAAA = "AAAA"
    CNAME = "CNAME"
    TXT = "TXT"
    MX = "MX"
    NS = "NS"
    SRV = "SRV"
  end

  # Deployment status
  module DeploymentStatus
    PENDING = "pending"
    BUILDING = "building"
    DEPLOYING = "deploying"
    ACTIVE = "active"
    FAILED = "failed"
    ROLLED_BACK = "rolled_back"
  end

  # Certificate status
  module CertificateStatus
    PENDING = "pending"
    ISSUED = "issued"
    EXPIRED = "expired"
    REVOKED = "revoked"
    FAILED = "failed"
  end

  # Domain record
  DomainRecord = Struct.new(
    :cid,
    :ttl,
    :updated_at,
    keyword_init: true
  )

  # Domain
  Domain = Struct.new(
    :name,
    :owner,
    :status,
    :record,
    :expires_at,
    :created_at,
    :auto_renew,
    keyword_init: true
  )

  # DNS record
  DnsRecord = Struct.new(
    :type,
    :name,
    :value,
    :ttl,
    :priority,
    keyword_init: true
  )

  # Deployment
  Deployment = Struct.new(
    :id,
    :domain,
    :cid,
    :status,
    :url,
    :created_at,
    :deployed_at,
    :build_logs,
    :error_message,
    keyword_init: true
  )

  # Certificate
  Certificate = Struct.new(
    :domain,
    :status,
    :issuer,
    :issued_at,
    :expires_at,
    :auto_renew,
    :fingerprint,
    keyword_init: true
  )

  # Analytics time range
  AnalyticsTimeRange = Struct.new(
    :start_time,
    :end_time,
    keyword_init: true
  )

  # Bandwidth stats
  BandwidthStats = Struct.new(
    :total_bytes,
    :cached_bytes,
    :uncached_bytes,
    keyword_init: true
  )

  # Request stats
  RequestStats = Struct.new(
    :total,
    :success,
    :error,
    :cached,
    keyword_init: true
  )

  # Geographic stats
  GeoStats = Struct.new(
    :country,
    :requests,
    :bandwidth,
    keyword_init: true
  )

  # Analytics
  Analytics = Struct.new(
    :domain,
    :time_range,
    :requests,
    :bandwidth,
    :visitors,
    :page_views,
    :top_paths,
    :geo_distribution,
    keyword_init: true
  )

  # Path stats
  PathStats = Struct.new(
    :path,
    :requests,
    :bandwidth,
    keyword_init: true
  )

  # Hosting config
  HostingConfig = Struct.new(
    :api_key,
    :endpoint,
    :timeout,
    :retries,
    :debug,
    keyword_init: true
  ) do
    def initialize(api_key:, endpoint: "https://hosting.synor.io/v1", timeout: 30, retries: 3, debug: false)
      super(api_key: api_key, endpoint: endpoint, timeout: timeout, retries: retries, debug: debug)
    end
  end

  # Health response
  HealthResponse = Struct.new(
    :status,
    keyword_init: true
  )
end
