Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Enum not correctly serialized with \http_build_query in guzzle #45

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading