# frozen_string_literal: true

module SynorEconomics
  # Service types
  module ServiceType
    COMPUTE = "compute"
    STORAGE = "storage"
    DATABASE = "database"
    HOSTING = "hosting"
    RPC = "rpc"
    BRIDGE = "bridge"
  end

  # Billing periods
  module BillingPeriod
    HOURLY = "hourly"
    DAILY = "daily"
    WEEKLY = "weekly"
    MONTHLY = "monthly"
  end

  # Stake status
  module StakeStatus
    ACTIVE = "active"
    UNSTAKING = "unstaking"
    WITHDRAWN = "withdrawn"
  end

  # Discount types
  module DiscountType
    PERCENTAGE = "percentage"
    FIXED = "fixed"
    CREDITS = "credits"
  end

  # Invoice status
  module InvoiceStatus
    PENDING = "pending"
    PAID = "paid"
    OVERDUE = "overdue"
    CANCELLED = "cancelled"
  end

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

  # Data types
  ServicePricing = Struct.new(:service, :unit, :price_per_unit, :currency, :minimum, :maximum, keyword_init: true)

  UsageMetrics = Struct.new(:service, :compute_units, :storage_bytes, :bandwidth_bytes, :duration_seconds, :requests, keyword_init: true)

  PriceResult = Struct.new(:service, :amount, :currency, :usage, keyword_init: true)

  UsagePlanItem = Struct.new(:service, :projected_usage, :period, keyword_init: true)

  CostItem = Struct.new(:service, :amount, keyword_init: true)

  CostEstimate = Struct.new(:total, :currency, :breakdown, :discount_applied, :period, keyword_init: true)

  UsageItem = Struct.new(:service, :compute_units, :storage_bytes, :bandwidth_bytes, :requests, :cost, keyword_init: true)

  Usage = Struct.new(:period, :start_date, :end_date, :items, :total_cost, :currency, keyword_init: true)

  InvoiceLine = Struct.new(:service, :description, :quantity, :unit_price, :amount, keyword_init: true)

  Invoice = Struct.new(:id, :date, :due_date, :status, :lines, :subtotal, :discount, :tax, :total, :currency, :pdf_url, keyword_init: true)

  AccountBalance = Struct.new(:available, :pending, :staked, :total, :currency, keyword_init: true)

  Stake = Struct.new(:id, :amount, :staked_at, :unlock_at, :status, :rewards_earned, :apy, keyword_init: true)

  StakeReceipt = Struct.new(:id, :amount, :tx_hash, :staked_at, :unlock_at, :apy, keyword_init: true)

  UnstakeReceipt = Struct.new(:id, :amount, :tx_hash, :unstaked_at, :available_at, keyword_init: true)

  StakingRewards = Struct.new(:pending, :claimed, :total, :current_apy, :last_claim, :next_distribution, keyword_init: true)

  Discount = Struct.new(:code, :type, :value, :description, :applicable_services, :valid_from, :valid_until, :max_uses, :current_uses, :active, keyword_init: true)

  DiscountResult = Struct.new(:discount, :savings_estimate, :applied_at, keyword_init: true)
end
