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: change order id to string #180

Open
wants to merge 1 commit into
base: gsc-master-dev
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Factory/Xml/Order/OrderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function make(SimpleXMLElement $element): Order
);

return Order::fromData(
(int) $element->OrderId,
(string) $element->OrderId,
$orderNumber,
(string) $element->CustomerFirstName,
(string) $element->CustomerLastName,
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/Xml/Order/OrderItemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function make(SimpleXMLElement $element): OrderItem
return OrderItem::fromOrderItem(
(int) $element->OrderItemId,
(int) $element->ShopId,
(int) $element->OrderId,
(string) $element->OrderId,
(string) $element->Name,
(string) $element->Sku,
(string) $element->Variation,
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/Xml/Order/OrdersItemsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function make(SimpleXMLElement $xml): Orders

$orderItems = OrderItemsFactory::make($item);

$order = Order::fromItems((int) $item->OrderId, (int) $item->OrderNumber, $orderItems);
$order = Order::fromItems((string) $item->OrderId, (int) $item->OrderNumber, $orderItems);
$orders->add($order);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Model/Order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Order implements JsonSerializable
{
/**
* @var int
* @var string
*/
protected $orderId;

Expand Down Expand Up @@ -140,7 +140,7 @@ class Order implements JsonSerializable
* @param string|int $orderNumber
*/
public static function fromData(
int $orderId,
string $orderId,
$orderNumber,
?string $customerFirstName,
?string $customerLastName,
Expand Down Expand Up @@ -198,7 +198,7 @@ public static function fromData(
/**
* @param string|int $orderNumber
*/
public static function fromItems(int $orderId, $orderNumber, OrderItems $orderItems): Order
public static function fromItems(string $orderId, $orderNumber, OrderItems $orderItems): Order
{
$order = new self();

Expand All @@ -209,7 +209,7 @@ public static function fromItems(int $orderId, $orderNumber, OrderItems $orderIt
return $order;
}

public function getOrderId(): int
public function getOrderId(): string
{
return $this->orderId;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Model/Order/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class OrderItem implements JsonSerializable
protected $shopId;

/**
* @var int|null
* @var string|null
*/
protected $orderId;

Expand Down Expand Up @@ -211,7 +211,7 @@ class OrderItem implements JsonSerializable
final public static function fromOrderItem(
int $orderItemId,
int $shopId,
int $orderId,
string $orderId,
string $name,
string $sku,
string $variation,
Expand Down Expand Up @@ -334,7 +334,7 @@ public function getShopId(): ?int
return $this->shopId;
}

public function getOrderId(): ?int
public function getOrderId(): ?string
{
return $this->orderId;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Order/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function all(): array
return $this->collection;
}

public function findByOrderId(int $orderId): ?Order
public function findByOrderId(string $orderId): ?Order
{
if (!key_exists($orderId, $this->collection)) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/Service/BaseOrderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BaseOrderManager extends BaseManager
public const DEFAULT_DATE_FORMAT = 'Y-m-d\TH:i:s';

public function getOrder(
int $orderId,
string $orderId,
bool $debug = true
): Order {
$action = 'GetOrder';
Expand All @@ -59,7 +59,7 @@ public function getOrder(
* @return OrderItem[]
*/
public function getOrderItems(
int $orderId,
string $orderId,
bool $debug = true
): array {
$action = 'GetOrderItems';
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/BaseOrderManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testItReturnsAOrder(): void
{
$sdkClient = $this->getSdkClient($this->getOrdersResponse('Order/OrderResponse.xml'));

$orderId = 4687503;
$orderId = '4687503';

$result = $sdkClient->orders()->getOrder($orderId);

Expand All @@ -65,7 +65,7 @@ public function testItReturnsACollectionOfOrderItems(): void
{
$sdkClient = $this->getSdkClient($this->getOrdersResponse('Order/OrderItemsResponse.xml'));

$orderId = 6750999;
$orderId = '6750999';

$result = $sdkClient->orders()->getOrderItems($orderId);

Expand Down Expand Up @@ -448,7 +448,7 @@ public function testItLogsDependingOnDebugParamWhenGetOrderItemsSuccessResponse(
}

$sdkClient->orders()->getOrderItems(
1,
'1',
$debug
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Order/OrderItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class OrderItemTest extends LinioTestCase
{
protected $orderItemId = 6750999;
protected $shopId = 7208215;
protected $orderId = 4758978;
protected $orderId = '4758978';
protected $name = 'MEGIR 5006 RELOJ ACERO INOXIDABLE ROSA';
protected $sku = 'DJFKLJOEDKLFJ';
protected $variation = 'Talla Única';
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Order/OrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class OrderTest extends LinioTestCase
{
protected $orderId = 4632913;
protected $orderId = '4632913';
protected $customerFirstName = 'first_name+4632913';
protected $customerLastName = 'last_name';
protected $orderNumber = 204527353;
Expand Down Expand Up @@ -191,7 +191,7 @@ public function testItReturnsAJsonRepresentation(string $property): void

public function testItReturnsAJsonRepresentationWithOrderItems(): void
{
$orderId = 1;
$orderId = '1';
$orderNumber = 1;
$randomDigit = $this->getFaker()->randomDigitNotNull;

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Order/OrdersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testItReturnsACollectionOfOrders(): void

$orderList = $orders->all();

$order = $orders->findByOrderId(4687808);
$order = $orders->findByOrderId('4687808');

$this->assertInstanceOf(Orders::class, $orders);
$this->assertInstanceOf(Order::class, $order);
Expand All @@ -44,7 +44,7 @@ public function testItReturnsACollectionOfOrderItems(): void

$orderList = $orders->all();

$order = $orders->findByOrderId(4687808);
$order = $orders->findByOrderId('4687808');

$this->assertInstanceOf(Orders::class, $orders);
$this->assertInstanceOf(Order::class, $order);
Expand All @@ -63,7 +63,7 @@ public function testItReturnNullWithAInvalidOrderId(): void

$orders = OrdersFactory::make($simpleXml);

$order = $orders->findByOrderId(12);
$order = $orders->findByOrderId('12');

$this->assertNull($order);
}
Expand Down