Skip to content

Commit

Permalink
Merge pull request #45 from WoutervanderLoopNL/fix-enum-serialize
Browse files Browse the repository at this point in the history
Fix Enum not correctly serialized with \http_build_query in guzzle
  • Loading branch information
casperbakker authored Jan 23, 2024
2 parents 2305bf1 + 71a63c9 commit 04c7ad5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 20 additions & 20 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getCommission(string $ean, float $unitPrice, ?Enum\GetCommission
$options = [
'query' => [
'unit-price' => $unitPrice,
'condition' => $condition,
'condition' => $condition?->value,
],
'produces' => 'application/vnd.retailer.v10+json',
];
Expand Down Expand Up @@ -184,9 +184,9 @@ public function getOfferInsights(string $offerId, Enum\GetOfferInsightsPeriod $p
$options = [
'query' => [
'offer-id' => $offerId,
'period' => $period,
'period' => $period->value,
'number-of-periods' => $numberOfPeriods,
'name' => $name,
'name' => $name->value,
],
'produces' => 'application/vnd.retailer.v10+json',
];
Expand Down Expand Up @@ -216,7 +216,7 @@ public function getPerformanceIndicators(Enum\GetPerformanceIndicatorsName $name
$url = "retailer/insights/performance/indicator";
$options = [
'query' => [
'name' => $name,
'name' => $name->value,
'year' => $year,
'week' => $week,
],
Expand Down Expand Up @@ -279,7 +279,7 @@ public function getSearchTerms(string $searchTerm, Enum\GetSearchTermsPeriod $pe
$options = [
'query' => [
'search-term' => $searchTerm,
'period' => $period,
'period' => $period->value,
'number-of-periods' => $numberOfPeriods,
'related-search-terms' => $relatedSearchTerms,
],
Expand Down Expand Up @@ -315,8 +315,8 @@ public function getInventory(?int $page = 1, array $quantity = [], ?Enum\GetInve
'query' => [
'page' => $page,
'quantity' => $quantity,
'stock' => $stock,
'state' => $state,
'stock' => $stock?->value,
'state' => $state?->value,
'query' => $query,
],
'produces' => 'application/vnd.retailer.v10+json',
Expand Down Expand Up @@ -689,8 +689,8 @@ public function getOrders(?int $page = 1, ?Enum\GetOrdersFulfilmentMethod $fulfi
$options = [
'query' => [
'page' => $page,
'fulfilment-method' => $fulfilmentMethod,
'status' => $status,
'fulfilment-method' => $fulfilmentMethod?->value,
'status' => $status?->value,
'change-interval-minute' => $changeIntervalMinute,
'latest-change-date' => $latestChangeDate,
],
Expand Down Expand Up @@ -800,7 +800,7 @@ public function getProductListFilters(?Enum\GetProductListFiltersCountryCode $co
$url = "retailer/products/list-filters";
$options = [
'query' => [
'country-code' => $countryCode,
'country-code' => $countryCode?->value,
'search-term' => $searchTerm,
'category-id' => $categoryId,
],
Expand Down Expand Up @@ -830,7 +830,7 @@ public function getProductAssets(string $ean, ?Enum\GetProductAssetsUsage $usage
$url = "retailer/products/{$ean}/assets";
$options = [
'query' => [
'usage' => $usage,
'usage' => $usage?->value,
],
'produces' => 'application/vnd.retailer.v10+json',
];
Expand Down Expand Up @@ -864,9 +864,9 @@ public function getCompetingOffers(string $ean, ?int $page = 1, ?Enum\GetCompeti
$options = [
'query' => [
'page' => $page,
'country-code' => $countryCode,
'country-code' => $countryCode?->value,
'best-offer-only' => $bestOfferOnly,
'condition' => $condition,
'condition' => $condition?->value,
],
'produces' => 'application/vnd.retailer.v10+json',
];
Expand Down Expand Up @@ -896,7 +896,7 @@ public function getProductPlacement(string $ean, ?Enum\GetProductPlacementCountr
$url = "retailer/products/{$ean}/placement";
$options = [
'query' => [
'country-code' => $countryCode,
'country-code' => $countryCode?->value,
],
'produces' => 'application/vnd.retailer.v10+json',
];
Expand Down Expand Up @@ -997,7 +997,7 @@ public function getPromotions(Enum\GetPromotionsPromotionType $promotionType, ?i
$url = "retailer/promotions";
$options = [
'query' => [
'promotion-type' => $promotionType,
'promotion-type' => $promotionType->value,
'page' => $page,
],
'produces' => 'application/vnd.retailer.v10+json',
Expand Down Expand Up @@ -1310,7 +1310,7 @@ public function getLoadCarrierLabels(string $replenishmentId, ?Enum\GetLoadCarri
$url = "retailer/replenishments/{$replenishmentId}/load-carrier-labels";
$options = [
'query' => [
'label-type' => $labelType,
'label-type' => $labelType?->value,
],
'produces' => 'application/vnd.retailer.v10+pdf',
];
Expand Down Expand Up @@ -1391,7 +1391,7 @@ public function getReturns(?int $page = 1, ?bool $handled = null, ?Enum\GetRetur
'query' => [
'page' => $page,
'handled' => $handled,
'fulfilment-method' => $fulfilmentMethod,
'fulfilment-method' => $fulfilmentMethod?->value,
],
'produces' => 'application/vnd.retailer.v10+json',
];
Expand Down Expand Up @@ -1500,7 +1500,7 @@ public function getShipments(?int $page = 1, ?Enum\GetShipmentsFulfilmentMethod
$options = [
'query' => [
'page' => $page,
'fulfilment-method' => $fulfilmentMethod,
'fulfilment-method' => $fulfilmentMethod?->value,
'order-id' => $orderId,
],
'produces' => 'application/vnd.retailer.v10+json',
Expand Down Expand Up @@ -1561,7 +1561,7 @@ public function getInvoiceRequests(?string $shipmentId = null, ?int $page = 1, ?
'query' => [
'shipment-id' => $shipmentId,
'page' => $page,
'state' => $state,
'state' => $state?->value,
],
'produces' => 'application/vnd.retailer.v10+json',
];
Expand Down Expand Up @@ -1934,7 +1934,7 @@ public function getProcessStatusEntityId(string $entityId, Enum\GetProcessStatus
$options = [
'query' => [
'entity-id' => $entityId,
'event-type' => $eventType,
'event-type' => $eventType->value,
'page' => $page,
],
'produces' => 'application/vnd.retailer.v10+json',
Expand Down
2 changes: 1 addition & 1 deletion src/OpenApi/ClientGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ protected function addQueryParams(array $arguments, array &$code): void
if ($argument['in'] != 'query') {
continue;
}
$code[] = sprintf(' \'%s\' => $%s,', $argument['paramName'], $argument['name']);
$code[] = sprintf(' \'%s\' => $%s%s,', $argument['paramName'], $argument['name'], str_starts_with($argument['php'], 'Enum') ? '->value' : (str_starts_with($argument['php'], '?Enum') ? '?->value' : ''));
}
$code[] = ' ],';
}
Expand Down

0 comments on commit 04c7ad5

Please sign in to comment.