-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
111 changed files
with
1,372 additions
and
6,627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
.idea | ||
/bin/ | ||
/build/ | ||
/vendor/ | ||
/composer.lock | ||
/.php-cs-fixer.cache | ||
/.phpunit.result.cache | ||
/.phpunit.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
Scraper Prestashop | ||
================== | ||
|
||
![Packagist version](https://flat.badgen.net/packagist/v/rem42/scraper-prestashop) | ||
![Packagist download](https://flat.badgen.net/packagist/dt/rem42/scraper-prestashop) | ||
![Packagist name](https://flat.badgen.net/packagist/name/rem42/scraper-prestashop) | ||
![Packagist php version](https://flat.badgen.net/packagist/php/rem42/scraper-prestashop) | ||
![Github licence](https://flat.badgen.net/github/license/rem42/scraper-prestashop) | ||
![Depenabot](https://flat.badgen.net/github/dependabot/rem42/scraper-prestashop) | ||
![Codeclimate lines of code](https://flat.badgen.net/codeclimate/loc/rem42/scraper-prestashop) | ||
![Codeclimate maintainability](https://flat.badgen.net/codeclimate/maintainability/rem42/scraper-prestashop) | ||
|
||
Scraper can handle multiple request type and transform them into object in order to create some API. | ||
|
||
Installation | ||
------------ | ||
|
||
````bash | ||
composer require rem42/scraper-prestashop | ||
```` | ||
|
||
Requirement | ||
----------- | ||
|
||
- PHP >= 8.1 | ||
|
||
Usage | ||
----- | ||
|
||
Initiate the client with the http client of your choice that implement the `Symfony\Contracts\HttpClient\HttpClientInterface` interface. | ||
|
||
|
||
`````php | ||
<?php | ||
|
||
use Scraper\Scraper\Client; | ||
use Symfony\Component\HttpClient\CurlHttpClient; | ||
use Symfony\Component\HttpClient\NativeHttpClient; | ||
|
||
$client = new Client( | ||
new CurlHttpClient() | ||
// OR | ||
new NativeHttpClient() | ||
); | ||
````` | ||
|
||
Then you can use the client to make request to the API. | ||
|
||
Product list | ||
------------ | ||
|
||
`````php | ||
<?php | ||
|
||
use Scraper\ScraperPrestashop\Request\PrestashopGetRequest; | ||
use Scraper\ScraperPrestashop\Entity\PrestashopProducts; | ||
|
||
$request = new PrestashopGetRequest( | ||
'host.com', // Your prestashop host | ||
'key', // Your prestashop webservice key | ||
'products', // The resource you want to get, like 'products' | ||
); | ||
|
||
// optional for list request | ||
$request | ||
->addFilter('limit', 1) | ||
->addFilter('offset', 1) | ||
; | ||
|
||
/** @var PrestashopProducts $products */ | ||
$products = $client->execute($request); | ||
|
||
$products->getProducts(); // Return an array of PrestashopProduct | ||
````` | ||
|
||
Product detail | ||
-------------- | ||
|
||
`````php | ||
<?php | ||
|
||
use Scraper\ScraperPrestashop\Request\PrestashopGetRequest; | ||
use Scraper\ScraperPrestashop\Entity\PrestashopProduct; | ||
|
||
$request = new PrestashopGetRequest( | ||
'host.com', // Your prestashop host | ||
'key', // Your prestashop webservice key | ||
'products', // The resource you want to get, like 'products' | ||
); | ||
|
||
$request->setId(42); | ||
|
||
/** @var PrestashopProduct $product */ | ||
$product = $client->execute($request); | ||
|
||
$product->name; // Return the product name | ||
$product->dateAdd; // Return the product creation date | ||
````` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
cacheResultFile=".phpunit.cache/test-results" | ||
executionOrder="depends,defects" | ||
forceCoversAnnotation="false" | ||
beStrictAboutCoversAnnotation="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
convertDeprecationsToExceptions="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
verbose="true"> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<coverage cacheDirectory=".phpunit.cache/code-coverage" | ||
processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</coverage> | ||
</phpunit> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
<?php | ||
<?php declare(strict_types=1); | ||
|
||
namespace Scraper\ScraperPrestashop\Api; | ||
|
||
use Scraper\Scraper\Api\AbstractApi; | ||
use Scraper\Scraper\Attribute\Scraper; | ||
use Scraper\Scraper\Request\ScraperRequest; | ||
use Scraper\ScraperPrestashop\Factory\SerializerFactory; | ||
use Symfony\Contracts\HttpClient\ResponseInterface; | ||
|
||
abstract class PrestashopApi extends AbstractApi | ||
{ | ||
public function __construct(ScraperRequest $request, Scraper $scraper, ResponseInterface $response) | ||
{ | ||
parent::__construct($request, $scraper, $response); | ||
$this->serializer = SerializerFactory::create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.