GithubHelp home page GithubHelp logo

ep6client-php's Introduction

epages REST SDK

This is the REST SDK to connect to an epages shop. You can use it as a developer for develop epages apps. Register at the epages developer page for a free development account.

Requirements

To use this package it needs at least PHP 5.4. Download or update the latest REST SDK it via command line.

wget https://raw.githubusercontent.com/ePages-de/epages-rest-php/master/build/epages-rest-php.phar -O epages-rest-php.phar

Its also possible to download the PHP file archive manually. Took the latest .phar release in the releases area.

Installation

To use the SDK only include it. For developing reasons its useful to print all notifications and informations on the screen. Warning: Its not recommended to do this in live system!

require_once("libraries/epages-rest-php.phar");
ep6\Logger::setLogLevel(ep6\LogLevel::NOTIFICATION);

Version information

This are the information which are provided with the epages REST SDK since now.

Feature GET PUT POST DELETE PATCH information
carts ?
categories - - ?
currencies - - - ?
legal - - - ? won't do, it's not needed
legal/contact-information - - ?
legal/privacy-policy - - ?
legal/rights-of-withdrawal - - ?
legal/shipping-information - - ?
legal/terms-and-condition - - ?
locales - - - ?
products - - ?
products//custom-attributes - - . ?
products//stock-level - - ?
products/export - - - ?
sales ?
search/product-suggest - - - ?
shpping-methods - - - ?

Code examples

For more small examples see the examples folder.

Example 1

This example get 100 products with a german localization and sort it with name attribute:

require_once("libraries/epages-rest-client.phar");
ep6\Logger::setLogLevel(ep6\LogLevel::NOTIFICATION);

// set connection constants
$HOST		= "www.meinshop.de";
$SHOP		= "DemoShop";
$AUTHTOKEN	= "xyzxyzxyzxyzxyzxyzxyzxyz";
$ISSSL		= true;

// connect to shop
$shop = new ep6\Shop($HOST, $SHOP, $AUTHTOKEN, $ISSSL);

// use a product filter to search for products
$productFilter = new ep6\ProductFilter();
$productFilter->setLocale("de_DE");
$productFilter->setCurrency("EUR");
$productFilter->setSort("name");
$productFilter->setResultsPerPage(100);
$products = $productFilter->getProducts();

// print the products
foreach ($products as $product) {

	echo "<h2>" . htmlentities($product->getName()) . "</h2>";
	echo "<p>";
	echo "<img style=\"float:left\" src=\"" . $product->getSmallImage()->getOriginURL() . "\"/>";
	echo "<strong>ProductID:</strong> " . $product->getID() . "<br/>";
	echo "<strong>Description:</strong> " . htmlentities($product->getDescription()) . "<br/><br/>";
	echo "<strong>This product is ";
	if (!$product->isForSale()) {
		echo "NOT ";
	}
	echo "for sale and is ";
	if ($product->isSpecialOffer()) {
		echo "<u>a</u> ";
	}
	else {
		echo "not a ";
	}
	echo "special offer.</strong>";
	echo "</p><hr style=\"clear:both\"/>";
}

Example 2

This example gets some shop information.

require_once("libraries/epages-rest-php.phar");
ep6\Logger::setLogLevel(ep6\LogLevel::NOTIFICATION);

// set connection constants
$HOST		= "www.meinshop.de";
$SHOP		= "DemoShop";
$AUTHTOKEN	= "xyzxyzxyzxyzxyzxyzxyzxyz";
$ISSSL		= true;

// connect to shop
$shop = new ep6\Shop($HOST, $SHOP, $AUTHTOKEN, $ISSSL);

// prints the default currency and localization
echo $shop->getDefaultLocales();
echo $shop->getDefaultCurrencies();

// prints the name of the contact information in default language and in german
$contactInformation = $shop->getContactInformation();
echo $contactInformation->getDefaultName();
echo $contactInformation->getName();

Utilities

Logger

The library comes with a huge Logger. It is called ep6\Logger. To use this (instead of the echo command) write

ep6\Logger::force("Print this!");

The force printer also can print arrays in a simple structure.

By default all notification messages are print. To change this use:

ep6\Logger::setLogLevel(ep6\LogLevel::NOTIFICATION);	// shows all messages
ep6\Logger::setLogLevel(ep6\LogLevel::WARNING);			// shows warning and error messages
ep6\Logger::setLogLevel(ep6\LogLevel::ERROR);			// shows only error messages
ep6\Logger::setLogLevel(ep6\LogLevel::NONE);			// don't log anything

InputValidator

To validate data and check the value of an object there is a InputValidator class:

ep6\InputValidator::isHost("www.test.de");
ep6\InputValidator::isJSON("{}");

All InputValidator functions are found in the doumentation

Function reference

The complete reference is located here.

Licence

The code is available under the terms of the MIT License.

ep6client-php's People

Contributors

panvid avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.