/**
 * Japan Post Facade
 *
 * Public API for Japan Post integration.
 * Controllers should use this facade instead of internal services directly.
 */

import { Injectable } from "@nestjs/common";
import { JapanPostAddressService } from "../services/japanpost-address.service.js";
import type { AddressLookupResult } from "@customer-portal/domain/address";

@Injectable()
export class JapanPostFacade {
  constructor(private readonly addressService: JapanPostAddressService) {}

  /**
   * Lookup address by ZIP code
   *
   * @param zipCode - ZIP code (with or without hyphen, e.g., "100-0001" or "1000001")
   * @param clientIp - Client IP address for API request (defaults to 127.0.0.1)
   * @returns Domain AddressLookupResult with Japanese and romanized address data
   */
  async lookupByZipCode(
    zipCode: string,
    clientIp: string = "127.0.0.1"
  ): Promise<AddressLookupResult> {
    return this.addressService.lookupByZipCode(zipCode, clientIp);
  }

  /**
   * Check if the Japan Post service is available
   */
  isAvailable(): boolean {
    return this.addressService.isAvailable();
  }
}
