stephenmittag / php-afterbuyapi
This fork of WkAfterbuyApi provides a some endpoints of Afterbuy XML API
Requires
- php: ~5.4
- guzzlehttp/guzzle: >=5.0,<7.0
- jms/serializer: ^1.1
- symfony/framework-bundle: ~2.6
- symfony/yaml: ~2.6
Requires (Dev)
README
This fork of the WkAfterbuyApiBundle provides implementations for some endpoints of Afterbuy XML API using Guzzle.
Installation
Require the bundle and its dependencies with composer:
$ composer require stephenmittag/php-afterbuyapi
Usage
Retrieving a list of sold items from Afterbuy:
$client = new Client( $config['afterbuy']['userId'], $config['afterbuy']['userPw'], $config['afterbuy']['partnerId'], $config['afterbuy']['partnerPw'], 'EN' ); $soldItems = $client->getSoldItems($filters, $orderDirection, $maxSoldItems, $detailLevel);
The response will be an instance of Wk\AfterbuyApiBundle\Model\XmlApi\GetSoldItems\GetSoldItemsResponse
and provides methods to traverse the XML sent back from Afterbuy such as fetching the orders:
$orders = $soldItems->getResult()->getOrders();
Provide an array of filters defined in Afterbuy, for example a DateFilter or a DefaultFilter. The models for these filters can be found in Wk\AfterbuyApiBundle\Model\XmlApi\GetSoldItems\Filter
.
$dateFilter = (new DateFilter(DateFilter::FILTER_AUCTION_END_DATE)) ->setDateFrom(new DateTime('2000-01-01 00:00:00')) ->setDateTo(new DateTime('2000-01-10 00:00:00')); $defaultFilter = new DefaultFilter(DefaultFilter::FILTER_COMPLETED_AUCTIONS);
Updating sold items on Afterbuy:
$order = new \Wk\AfterbuyApiBundle\Model\XmlApi\UpdateSoldItems\Order(); $order->setOrderId(1234567890) ->setUserDefinedFlag(12345) ->setInvoiceMemo("You didn't read the memo? You are fired!"); $client->updateSoldItems(array($orders));
The response will be an instance of Wk\AfterbuyApiBundle\Model\XmlApi\UpdateSoldItems\UpdateSoldItemsResponse
.
Dependencies
jms/serializer
- Allows you to easily serialize, and deserialize data of any complexityguzzlehttp/guzzle
- Guzzle is a PHP HTTP client library
PHPUnit Tests
You can run the tests using the following command:
$ vendor/bin/phpunit
Resources
Afterbuy XML Interface Documentation: