<?php
if (!defined('ABSPATH')) {
    exit;
}

class BMTQB_Integration_Context {
    public $industry;
    public $industry_key;
    public $industry_label;
    public $data;
    public $results;
    public $post_id;
    public $quote_reference;
    public $pdf_path;
    public $pdf_url;
    public $photos;
    public $photos_sent;
    public $customer;
    public $service_address;
    public $submitted_at;

    public function __construct(BMTQB_Industry_Interface $industry, $data, $results, $post_id, $pdf_path = '', $photos = [], $quote_reference = '') {
        $this->industry = $industry;
        $this->industry_key = $industry->key();
        $this->industry_label = $industry->label();
        $this->data = is_array($data) ? $data : [];
        $this->results = is_array($results) ? $results : [];
        $this->post_id = (int) $post_id;
        $this->quote_reference = (string) $quote_reference;
        $this->pdf_path = (string) $pdf_path;
        $this->pdf_url = BMTQB_Formatter::pdf_url_from_path($this->pdf_path);
        $this->photos = is_array($photos) ? $photos : [];
        $this->photos_sent = !empty($this->photos);
        $this->customer = [
            'first_name' => $this->data['first_name'] ?? '',
            'last_name' => $this->data['last_name'] ?? '',
            'email' => $this->data['email'] ?? '',
            'phone' => $this->data['phone'] ?? '',
        ];
        $this->service_address = $this->data['service_address'] ?? '';
        $this->submitted_at = current_time('mysql');
    }
}
