<?php


namespace App\Libs\Push\HuaWei\Admin\Msg\Apns;


use App\Libs\Push\HuaWei\Admin\Constants;
use App\Libs\Push\HuaWei\Admin\PushLogConfig;

class ApnsConfig
{
    private $payload;
    private $headers;
    private $hms_options;

    private $fields;

    public function __construct()
    {
        $this->fields = array();
    }

    public function payload($value)
    {
        $this->payload = $value;
    }

    public function headers($value)
    {
        $this->headers = $value;
    }

    public function hms_options($value)
    {
        $this->hms_options = $value;
    }

    public function getFields()
    {
        return $this->fields;
    }

    public function buildFields()
    {

        $keys = array(
            'headers',
            'hms_options',
            'payload'
        );
        foreach ($keys as $key) {
            PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][key:' . $key . '][value:' . json_encode($this->$key) . ']', Constants::HW_PUSH_LOG_DEBUG_LEVEL);
            if (isset($this->$key)) {
                $this->fields[$key] = $this->$key;
            }
        }
        PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][buildFields result:' . json_encode($this->fields), Constants::HW_PUSH_LOG_DEBUG_LEVEL);

    }
}