Overview

Namespaces

  • Apptus
    • ESales
      • Connector
        • Report
        • Time
    • Util
      • Cache
  • PHP
  • Overview
  • Namespace
  • Class
  • Tree
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 
<?php
namespace Apptus\ESales\Connector;

/**
 * A panel in the eSales panel hierarchy.
 *
 * Use {@see retrieveContent()} to get the content of this panel and all its subpanels, recursively.
 *
 * When executing panels, see the <i>Panel library</i> section in <a href="http://zone.apptus.com">Apptus Zone</a> (http://zone.apptus.com) for the arguments to each panel.
 * When working with filters see <i>Working with filters</i> and the {@see FilterBuilder} class.
 * Also read the other articles in the <i>Key concepts</i> section for information about the other panel arguments.
 */
class Panel {
    private $cluster;
    private $session;
    private $path;

    /**
     * @internal
     * @param Cluster
     * @param Session
     * @param string
     */
    public function __construct(Cluster $cluster, Session $session, $path) {
        $this->path = (string) $path;
        $this->session = $session;
        $this->cluster = $cluster;
    }

    /**
     * Retrieves the content of this panel from the eSales service.
     *
     * The panel is evaluated with the arguments supplied to this method.
     * You may use an {@see ArgMap} or a standard array with string keys and string values to pass the arguments.
     *
     * @param ArgMap|array|null
     *            A map of arguments, where key is the parameter name, and value is the argument value.
     *            Arguments having null values are ignored.
     * @return PanelContent
     *            A PanelContent object holding the content of the panel.
     * @throws RequestFailedException
     *             If there is an error communicating with the eSales service.
     * @throws ParseException
     *             If the response cannot be parsed.
     * @throws \InvalidArgumentException
     *             if arguments contains empty or reserved keys
     */
    public function retrieveContent($arguments = null) {
        $xml = $this->retrieveContentAsXml($arguments);
        $parser = new PanelParser($this->path);
        $content = $parser->parse($xml);
        return $content;
    }

    /**
     * Retrieves the content of this panel from the eSales service as a string.
     *
     * The panel is evaluated with the arguments supplied to this method.
     * You may use an {@see ArgMap} or a standard array with string keys and string values to pass the arguments.
     *
     * @param ArgMap|array|null
     *            A map of arguments, where key is the parameter name, and value is the argument value.
     *            Arguments having null values are ignored.
     * @return string
     *            A string containing the xml content of the panel.
     * @throws \InvalidArgumentException
     *            If arguments contains empty or reserved keys.
     * @throws RequestFailedException
     *            If there is an error communicating with the eSales service.
     */
    public function retrieveContentAsXml($arguments = null) {
        if ($arguments !== null && isset($arguments['session_key'])) {
            throw new \InvalidArgumentException('Argument session_key is reserved and must not be specified.');
        }
        $args = new ArgMap();
        $args->put('session_key', $this->session->key());
        $args->putAll($arguments);
        $headers = new ArgMap();
        if ($this->session->market() !== null) {
            $headers->put(session::MARKET_HEADER_NAME, $this->session->market());
        }
        if ($this->session->customerKey() !== null) {
            $headers->put(session::CUSTOMER_KEY_HEADER_NAME, $this->session->customerKey());
        }
        $result = $this->cluster->queryPanel($this->path, $args, $headers);
        return $result;
    }
}
Apptus ESales Connector PHP API documentation generated by ApiGen