/** * 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); }
/** * @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")); }
/** * @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()); }
/** * 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); } }
/** * 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); }