Exemplo n.º 1
0
 /**
  * The constructor for the shop class.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.0.0
  * @since 0.1.1 Save the own login credentials.
  * @api
  * @param String $host The ePages host to connect.
  * @param String $shop The refered ePages shop.
  * @param String $authToken The authentificaton token to connect via REST.
  * @param boolean $isssl True, if you use SSL, false if not. Default value is true.
  * @source 2 1 Calls the REST client and connect.
  */
 function __construct($host, $shop, $authToken, $isssl = true)
 {
     if (!InputValidator::isHost($host) || !InputValidator::isShop($shop)) {
         return;
     }
     $this->host = $host;
     $this->shop = $shop;
     $this->authToken = $authToken;
     $this->isssl = $isssl;
     RESTClient::connect($this->host, $this->shop, $this->authToken, $this->isssl);
 }
Exemplo n.º 2
0
 /**
  * @group utility
  */
 function testSend()
 {
     @RESTClient::setRequestMethod();
     @RESTClient::connect("www.google.de", "Shopname", "AuthToken");
     $this->assertNull(@RESTClient::send("locale"));
     @RESTClient::setRequestMethod("NOTVALID");
     $this->assertNull(@RESTClient::send("locale"));
     @RESTClient::disconnect();
     @RESTClient::setRequestMethod("GET");
     $this->assertNull(@RESTClient::send("locale"));
     @RESTClient::setRequestMethod("NOTVALID");
     $this->assertNull(@RESTClient::send("locale"));
 }
Exemplo n.º 3
0
 /**
  * @group utility
  */
 function testSendWithLocalization()
 {
     RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true);
     RESTClient::setRequestMethod("GET");
     $this->assertNull(RESTClient::sendWithLocalization("locale", "NoLocale"));
     $this->assertTrue(RESTClient::error());
     $this->assertEquals("RESTC-3", RESTClient::errorNumber());
     $this->assertNull(RESTClient::sendWithLocalization("locales", "NoLocale", "NoArray"));
     $this->assertTrue(RESTClient::error());
     $this->assertEquals("RESTC-3", RESTClient::errorNumber());
     $this->assertNull(RESTClient::sendWithLocalization("locales", "en_GB", "NoArray"));
     $this->assertTrue(RESTClient::error());
     $this->assertEquals("RESTC-5", RESTClient::errorNumber());
     RESTClient::disconnect();
     $this->assertNull(RESTClient::sendWithLocalization("locales", "NoLocale"));
     $this->assertTrue(RESTClient::error());
     $this->assertEquals("RESTC-3", RESTClient::errorNumber());
     RESTClient::disconnect();
     $this->assertNull(RESTClient::sendWithLocalization("locales", "en_GB"));
     $this->assertTrue(RESTClient::error());
     $this->assertEquals("RESTC-6", RESTClient::errorNumber());
     RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true);
     RESTClient::setRequestMethod("GET");
     $this->assertNull(RESTClient::sendWithLocalization("NoValidRessource", "en_GB"));
     $this->assertTrue(RESTClient::error());
     $this->assertEquals("RESTC-7", RESTClient::errorNumber());
     $this->assertNull(RESTClient::sendWithLocalization("NoValidRessource", "NoLocale"));
     $this->assertTrue(RESTClient::error());
     $this->assertEquals("RESTC-3", RESTClient::errorNumber());
     $this->assertNull(RESTClient::sendWithLocalization("locales", "de_DE", "noArray"));
     $this->assertTrue(RESTClient::error());
     $this->assertEquals("RESTC-5", RESTClient::errorNumber());
     $this->assertNotNull(RESTClient::sendWithLocalization("locales", "de_DE"));
     $this->assertFalse(RESTClient::error());
     $this->assertNull(RESTClient::errorNumber());
 }
Exemplo n.º 4
0
 /**
  * Use this shop from now.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.1
  * @since 0.1.2 Add error reporting.
  */
 public function useShop()
 {
     self::errorReset();
     if (InputValidator::isEmpty($this->host) || InputValidator::isEmpty($this->shop)) {
         RESTClient::disconnect($this->host, $this->shop, $this->authToken, $this->isssl);
         Logger::warning("ep6\\Shop\nCan't use shop, because there no shop host and name configured.");
         $error = InputValidator::isEmpty($this->host) ? "S-3" : "S-4";
         self::setError($error);
     } else {
         RESTClient::connect($this->host, $this->shop, $this->authToken, $this->isssl);
     }
 }
Exemplo n.º 5
0
 /**
  * The constructor for the main class.
  *
  * @param String	$host		The ePages host to connect.
  * @param String	$shop		The refered ePages shop.
  * @param String	$authToken	The authentificaton token to connect via REST.
  * @param boolean	$isssl		True, if you use SSL, false if not. Default value is true.
  */
 function __construct($host, $shop, $authToken, $isssl = true)
 {
     RESTClient::connect($host, $shop, $authToken, $isssl);
 }