Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
require_once 'EbatNs_Logger.php';
4
require_once 'EbatNs_Session.php';
5
require_once 'EbatNs_ServiceProxy.php';
6
require_once 'AbstractResponseType.php';
7
require_once 'AckCodeType.php';
8
 
9
/**
10
 * Prepares an environment for testing ebatNs calls
11
 *
12
 */
13
class EbatNs_Environment
14
{
15
    /**
16
     * @var EbatNs_Session
17
     */
18
    protected $session;
19
 
20
    /**
21
     * @var EbatNs_Logger
22
     */
23
    protected $logger = null;
24
 
25
    /**
26
     * @var EbatNs_ServiceProxy
27
     */
28
    protected $proxy = null;
29
 
30
    /**
31
     * Fullpath to config-file
32
     *
33
     * @var string
34
     */
35
    protected $configFile = null;
36
 
37
    public function __construct($logLevel = 0, $configFile = 'config/ebay.config.php')
38
    {
39
        $this->init($logLevel, $configFile);
40
    }
41
 
42
    public function init($logLevel = 0, $configFile)
43
    {
44
        if ($logLevel >= 1)
45
            $this->logger = new EbatNs_Logger();
46
        $this->configFile = $configFile;
47
        $this->session = new EbatNs_Session($this->configFile);
48
        $this->proxy = new EbatNs_ServiceProxy($this->session);
49
 
50
        if ($this->logger)
51
	        $this->proxy->attachLogger($this->logger);
52
    }
53
 
54
    public function dispatchCall()
55
    {
56
    }
57
 
58
    /**
59
     * Tests if a response is valid and prints out
60
     * a error trace if not
61
     *
62
     * @param AbstractResponseType $res
63
     * @return boolean
64
     */
65
    protected function testValid($res)
66
    {
67
        if ($res->getAck() == AckCodeType::CodeType_Success)
68
        {
69
            return true;
70
        }
71
        else
72
        {
73
            echo $this->proxy->getErrorsToString($res, true);
74
            return false;
75
        }
76
    }
77
 
78
    protected function dumpObject($data)
79
    {
80
        echo  "<br>---------------------<br>"
81
            . "Object Dump:<br><pre>" . print_r($data, true) . "</pre>";
82
    }
83
}
84
?>