Skip to content

Commit

Permalink
Update to latest version API definition
Browse files Browse the repository at this point in the history
  • Loading branch information
casperbakker committed Mar 28, 2024
1 parent 04c7ad5 commit cec9569
Show file tree
Hide file tree
Showing 23 changed files with 1,000 additions and 127 deletions.
59 changes: 59 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@ public function getCommission(string $ean, float $unitPrice, ?Enum\GetCommission
return $this->request('GET', $url, $options, $responseTypes);
}

/**
* Gets a list of all commissions using EAN.
* @param Model\Ean[] $products
* @return Model\BulkCommissionRatesMultiStatusResponse
* @throws Exception\ConnectException when an error occurred in the HTTP connection.
* @throws Exception\ResponseException when an unexpected response was received.
* @throws Exception\UnauthorizedException when the request was unauthorized.
* @throws Exception\RateLimitException when the throttling limit has been reached for the API user.
* @throws Exception\Exception when something unexpected went wrong.
*/
public function getCommissionRates(array $products): Model\BulkCommissionRatesMultiStatusResponse
{
$url = "retailer/commissions";
$options = [
'body' => Model\CommissionProducts::constructFromArray(['products' => $products]),
'produces' => 'application/vnd.retailer.v10+json',
'consumes' => 'application/vnd.retailer.v10+json',
];
$responseTypes = [
];

return $this->request('POST', $url, $options, $responseTypes);
}

/**
* Gets the details of a catalog product by means of its EAN.
* @param string $ean The EAN number associated with this product.
Expand Down Expand Up @@ -229,6 +253,41 @@ public function getPerformanceIndicators(Enum\GetPerformanceIndicatorsName $name
return $this->request('GET', $url, $options, $responseTypes)->performanceIndicators;
}

/**
* Gets a list of product ranks.
* @param string $ean The EAN number associated with this product.
* @param string $date Filters search results to a specific date. The date must be in the past, no more than three
* months back, and up to yesterday.
* @param Enum\GetProductRanksType|null $type Determines the search type, either 'SEARCH' for specific queries or
* 'BROWSE' for broader category searches. In order to retrieve all results, it can be sent as "null".
* @param int|null $page The requested page number with a page size of 50 items.
* @param string|null $AcceptLanguage The language to search for.
* @return Model\ProductRanks
* @throws Exception\ConnectException when an error occurred in the HTTP connection.
* @throws Exception\ResponseException when an unexpected response was received.
* @throws Exception\UnauthorizedException when the request was unauthorized.
* @throws Exception\RateLimitException when the throttling limit has been reached for the API user.
* @throws Exception\Exception when something unexpected went wrong.
*/
public function getProductRanks(string $ean, string $date, ?Enum\GetProductRanksType $type = null, ?int $page = 1, ?string $AcceptLanguage = null): Model\ProductRanks
{
$url = "retailer/insights/product-ranks";
$options = [
'query' => [
'ean' => $ean,
'date' => $date,
'type' => $type?->value,
'page' => $page,
],
'produces' => 'application/vnd.retailer.v10+json',
];
$responseTypes = [
'200' => Model\ProductRanks::class,
];

return $this->request('GET', $url, $options, $responseTypes);
}

/**
* Get sales forecast to estimate the sales expectations on the total bol.com platform for the requested number of
* weeks ahead.
Expand Down
13 changes: 13 additions & 0 deletions src/Enum/GetProductRanksAcceptLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Picqer\BolRetailerV10\Enum;

// This class is auto generated by OpenApi\ModelGenerator
enum GetProductRanksAcceptLanguage: string
{
case NL_NL = 'nl-NL';
case NL = 'nl';
case NL_BE = 'nl-BE';
case FR = 'fr';
case FR_BE = 'fr-BE';
}
10 changes: 10 additions & 0 deletions src/Enum/GetProductRanksType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Picqer\BolRetailerV10\Enum;

// This class is auto generated by OpenApi\ModelGenerator
enum GetProductRanksType: string
{
case SEARCH = 'SEARCH';
case BROWSE = 'BROWSE';
}
34 changes: 34 additions & 0 deletions src/Model/BulkCommissionRatesMultiStatusResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Picqer\BolRetailerV10\Model;

use Picqer\BolRetailerV10\Enum;

// This class is auto generated by OpenApi\ModelGenerator
class BulkCommissionRatesMultiStatusResponse extends AbstractModel
{
/**
* Returns the definition of the model: an associative array with field names as key and
* field definition as value. The field definition contains of
* model: Model class or null if it is a scalar type
* array: Boolean whether it is an array
* @return array The model definition
*/
public function getModelDefinition(): array
{
return [
'successfulQueries' => [ 'model' => CommissionSuccessfulQuery::class, 'enum' => null, 'array' => true ],
'failedQueries' => [ 'model' => CommissionFailedQuery::class, 'enum' => null, 'array' => true ],
];
}

/**
* @var CommissionSuccessfulQuery[]
*/
public $successfulQueries = [];

/**
* @var CommissionFailedQuery[]
*/
public $failedQueries = [];
}
4 changes: 2 additions & 2 deletions src/Model/ChangeTransportRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class ChangeTransportRequest extends AbstractModel
public function getModelDefinition(): array
{
return [
'transporterCode' => [ 'model' => null, 'enum' => Enum\ChangeTransportRequestTransporterCode::class, 'array' => false ],
'transporterCode' => [ 'model' => null, 'enum' => null, 'array' => false ],
'trackAndTrace' => [ 'model' => null, 'enum' => null, 'array' => false ],
];
}

/**
* @var Enum\ChangeTransportRequestTransporterCode
* @var string Specify the transporter that carries out the shipment.
*/
public $transporterCode;

Expand Down
40 changes: 40 additions & 0 deletions src/Model/CommissionDateRange.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Picqer\BolRetailerV10\Model;

use Picqer\BolRetailerV10\Enum;

// This class is auto generated by OpenApi\ModelGenerator
class CommissionDateRange extends AbstractModel
{
/**
* Returns the definition of the model: an associative array with field names as key and
* field definition as value. The field definition contains of
* model: Model class or null if it is a scalar type
* array: Boolean whether it is an array
* @return array The model definition
*/
public function getModelDefinition(): array
{
return [
'startDate' => [ 'model' => null, 'enum' => null, 'array' => false ],
'endDate' => [ 'model' => null, 'enum' => null, 'array' => false ],
'rates' => [ 'model' => CommissionDateRate::class, 'enum' => null, 'array' => true ],
];
}

/**
* @var string The inclusive start date (in ISO 8601 format) from which the commission applies
*/
public $startDate;

/**
* @var string The exclusive end date (in ISO 8601 format) after which the commission no longer applies.
*/
public $endDate;

/**
* @var CommissionDateRate[] An array of objects, each describing commission rates for a specific condition.
*/
public $rates = [];
}
34 changes: 34 additions & 0 deletions src/Model/CommissionDateRate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Picqer\BolRetailerV10\Model;

use Picqer\BolRetailerV10\Enum;

// This class is auto generated by OpenApi\ModelGenerator
class CommissionDateRate extends AbstractModel
{
/**
* Returns the definition of the model: an associative array with field names as key and
* field definition as value. The field definition contains of
* model: Model class or null if it is a scalar type
* array: Boolean whether it is an array
* @return array The model definition
*/
public function getModelDefinition(): array
{
return [
'condition' => [ 'model' => null, 'enum' => null, 'array' => false ],
'priceRanges' => [ 'model' => CommissionPriceRange::class, 'enum' => null, 'array' => true ],
];
}

/**
* @var string Condition of the product.
*/
public $condition;

/**
* @var CommissionPriceRange[]
*/
public $priceRanges = [];
}
41 changes: 41 additions & 0 deletions src/Model/CommissionFailedQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Picqer\BolRetailerV10\Model;

use Picqer\BolRetailerV10\Enum;

// This class is auto generated by OpenApi\ModelGenerator
class CommissionFailedQuery extends AbstractModel
{
/**
* Returns the definition of the model: an associative array with field names as key and
* field definition as value. The field definition contains of
* model: Model class or null if it is a scalar type
* array: Boolean whether it is an array
* @return array The model definition
*/
public function getModelDefinition(): array
{
return [
'index' => [ 'model' => null, 'enum' => null, 'array' => false ],
'status' => [ 'model' => null, 'enum' => null, 'array' => false ],
'violations' => [ 'model' => Violation::class, 'enum' => null, 'array' => true ],
];
}

/**
* @var float This provides the location of the entity where it was provided in the original response body.
*/
public $index;

/**
* @var int HTTP status code for individual entity operation.
*/
public $status;

/**
* @var Violation[] Outlines the list of violations encountered in the API for the specific index detailing the
* nature and reason for the issue.
*/
public $violations = [];
}
46 changes: 46 additions & 0 deletions src/Model/CommissionPriceRange.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Picqer\BolRetailerV10\Model;

use Picqer\BolRetailerV10\Enum;

// This class is auto generated by OpenApi\ModelGenerator
class CommissionPriceRange extends AbstractModel
{
/**
* Returns the definition of the model: an associative array with field names as key and
* field definition as value. The field definition contains of
* model: Model class or null if it is a scalar type
* array: Boolean whether it is an array
* @return array The model definition
*/
public function getModelDefinition(): array
{
return [
'range' => [ 'model' => CommissionRange::class, 'enum' => null, 'array' => false ],
'fixedAmount' => [ 'model' => null, 'enum' => null, 'array' => false ],
'percentage' => [ 'model' => null, 'enum' => null, 'array' => false ],
'reductionApplied' => [ 'model' => null, 'enum' => null, 'array' => false ],
];
}

/**
* @var CommissionRange Defines a specific price range for which the commission rates apply including VAT.
*/
public $range;

/**
* @var float The fixed commission amount excluding VAT.
*/
public $fixedAmount;

/**
* @var float A percentage of commission, based on the intended selling price per unit, excluding VAT.
*/
public $percentage;

/**
* @var bool A boolean flag indicating whether a reduction is applied to the commission or not.
*/
public $reductionApplied;
}
59 changes: 59 additions & 0 deletions src/Model/CommissionProducts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Picqer\BolRetailerV10\Model;

use Picqer\BolRetailerV10\Enum;

// This class is auto generated by OpenApi\ModelGenerator
class CommissionProducts extends AbstractModel
{
/**
* Returns the definition of the model: an associative array with field names as key and
* field definition as value. The field definition contains of
* model: Model class or null if it is a scalar type
* array: Boolean whether it is an array
* @return array The model definition
*/
public function getModelDefinition(): array
{
return [
'products' => [ 'model' => Ean::class, 'enum' => null, 'array' => true ],
];
}

/**
* @var Ean[]
*/
public $products = [];

/**
* Returns an array with the eans from products.
* @return string[] Eans from products.
*/
public function getProductsEans(): array
{
return array_map(function ($model) {
return $model->ean;
}, $this->products);
}

/**
* Sets products by an array of eans.
* @param string[] $eans Eans for products.
*/
public function setProductsEans(array $eans): void
{
$this->products = array_map(function ($ean) {
return Ean::constructFromArray(['ean' => $ean]);
}, $eans);
}

/**
* Adds a new Ean to products by ean.
* @param string $ean Ean for the Ean to add.
*/
public function addProductsEan(string $ean): void
{
$this->products[] = Ean::constructFromArray(['ean' => $ean]);
}
}
Loading

0 comments on commit cec9569

Please sign in to comment.