Skip to content

Commit 6079b68

Browse files
authored
fix swagger (#698)
* Fixing tests * fixing tests * tweak * Static errors * Fixing swagger docs * EOF newline * EOF newline2 * trailing comma * unused interface * protected class var
1 parent 7f08bdf commit 6079b68

7 files changed

+132
-19
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright (c) Meta Platforms, Inc. and affiliates.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
namespace Meta\Sales\Api;
22+
23+
/**
24+
* AddCartItemsApi response
25+
*/
26+
interface AddCartItemsApiExceptionResponseInterface
27+
{
28+
/**
29+
* Get sku which failed
30+
*
31+
* @return string
32+
*/
33+
public function getSku(): string;
34+
35+
/**
36+
* Get message for this exception
37+
*
38+
* @return string
39+
*/
40+
public function getExceptionMessage(): string;
41+
}

app/code/Meta/Sales/Api/AddCartItemsApiResponseInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getItemsAdded(): array;
3535
/**
3636
* Get array of SKU/exception message for items that failed to be added
3737
*
38-
* @return array
38+
* @return \Meta\Sales\Model\Api\AddCartItemsApiExceptionResponse[]
3939
*/
4040
public function getExceptions(): array;
4141
}

app/code/Meta/Sales/Api/CreateOrderApiInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface CreateOrderApiInterface
4848
* @param string|null $channel
4949
* @param bool $buyerRemarketingOptIn
5050
* @param bool $createInvoice
51-
* @return OrderInterface
51+
* @return \Magento\Sales\Api\Data\OrderInterface
5252
*/
5353
public function createOrder(
5454
string $cartId,

app/code/Meta/Sales/Api/NewsletterSubscriptionDiscountApiInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface NewsletterSubscriptionDiscountApiInterface
3131
* @param string $externalBusinessId
3232
* @param string $email
3333
* @param int $ruleId
34-
* @return CouponInterface
34+
* @return \Magento\SalesRule\Api\Data\CouponInterface
3535
*/
3636
public function subscribeForCoupon(string $externalBusinessId, string $email, int $ruleId): CouponInterface;
3737
}

app/code/Meta/Sales/Model/Api/AddCartItemsApi.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ public function addCartItems(string $externalBusinessId, array $items): AddCartI
8686
try {
8787
$itemsAdded[] = $this->guestCartItemRepository->save($item);
8888
} catch (\Exception $e) {
89-
$exceptions[] = [
90-
'sku' => $item->getSku(),
91-
'exception_message' => $e->getMessage()
92-
];
89+
$exceptions[] = new AddCartItemsApiExceptionResponse($item->getSku(), $e->getMessage());
9390
$this->fbeHelper->logExceptionImmediatelyToMeta(
9491
$e,
9592
[
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright (c) Meta Platforms, Inc. and affiliates.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
namespace Meta\Sales\Model\Api;
22+
23+
use Meta\Sales\Api\AddCartItemsApiExceptionResponseInterface;
24+
25+
/**
26+
* Class AddCartItemsApiExceptionResponse
27+
*
28+
* Implements the AddCartItemsApiExceptionResponseInterface to provide detailed information about exceptions
29+
* that occur when adding items to the cart.
30+
*/
31+
class AddCartItemsApiExceptionResponse implements AddCartItemsApiExceptionResponseInterface
32+
{
33+
/**
34+
* @var string The SKU of the item that failed to be added to the cart.
35+
*/
36+
public string $sku;
37+
38+
/**
39+
* @var string The message associated with the exception.
40+
*/
41+
public string $exceptionMessage;
42+
43+
/**
44+
* Constructor for AddCartItemsApiExceptionResponse.
45+
*
46+
* @param string $sku The SKU of the item that failed to be added.
47+
* @param string $exceptionMessage The exception message.
48+
*/
49+
public function __construct(string $sku, string $exceptionMessage)
50+
{
51+
$this->sku = $sku;
52+
$this->exceptionMessage = $exceptionMessage;
53+
}
54+
55+
/**
56+
* Get the SKU of the item that failed to be added to the cart.
57+
*
58+
* @return string The SKU of the failed item.
59+
*/
60+
public function getSku(): string
61+
{
62+
return $this->sku;
63+
}
64+
65+
/**
66+
* Get the message associated with the exception.
67+
*
68+
* @return string The exception message.
69+
*/
70+
public function getExceptionMessage(): string
71+
{
72+
return $this->exceptionMessage;
73+
}
74+
}

app/code/Meta/Sales/Model/Api/AddCartItemsApiResponse.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,35 @@
1818
* limitations under the License.
1919
*/
2020

21-
namespace Meta\Sales\Model\Api;
21+
namespace Meta\Sales\Model\Api;
2222

23-
use Meta\Sales\Api\AddCartItemsApiResponseInterface;
23+
use Meta\Sales\Api\AddCartItemsApiResponseInterface;
24+
use Meta\Sales\Api\AddCartItemsApiExceptionResponseInterface;
2425

25-
class AddCartItemsApiResponse implements AddCartitemsApiResponseInterface
26+
class AddCartItemsApiResponse implements AddCartItemsApiResponseInterface
2627
{
2728
/**
28-
* @var \Magento\Quote\Api\Data\CartItemInterfaceCartItemInterface[]
29+
* @var \Magento\Quote\Api\Data\CartItemInterface[]
2930
*/
3031
private $itemsAdded = [];
3132

3233
/**
33-
* @var array
34+
* @var AddCartItemsApiExceptionResponseInterface[]
3435
*/
3536
private $exceptions = [];
3637

3738
/**
38-
* Getter
39+
* Getter for items added
3940
*
40-
* @return \Magento\Quote\Api\Data\CartItemInterfaceCartItemInterface[]
41+
* @return \Magento\Quote\Api\Data\CartItemInterface[]
4142
*/
4243
public function getItemsAdded(): array
4344
{
4445
return $this->itemsAdded;
4546
}
4647

4748
/**
48-
* Setter
49+
* Setter for items added
4950
*
5051
* @param \Magento\Quote\Api\Data\CartItemInterface[] $items
5152
* @return void
@@ -56,19 +57,19 @@ public function setItemsAdded(array $items): void
5657
}
5758

5859
/**
59-
* Getter
60+
* Getter for exceptions
6061
*
61-
* @return array
62+
* @return AddCartItemsApiExceptionResponseInterface[]
6263
*/
6364
public function getExceptions(): array
6465
{
6566
return $this->exceptions;
6667
}
6768

6869
/**
69-
* Setter
70+
* Setter for exceptions
7071
*
71-
* @param array $exceptions
72+
* @param AddCartItemsApiExceptionResponseInterface[] $exceptions
7273
* @return void
7374
*/
7475
public function setExceptions(array $exceptions): void

0 commit comments

Comments
 (0)