-
Notifications
You must be signed in to change notification settings - Fork 12
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
Makes the order operation 'deliver' available. #114
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ class OrderOperation extends Operation\AbstractBulkOperation | |
public const TYPE_ACKNOWLEDGE = 'acknowledge'; | ||
public const TYPE_UNACKNOWLEDGE = 'unacknowledge'; | ||
public const TYPE_UPLOAD_DOCUMENTS = 'upload-documents'; | ||
public const TYPE_DELIVER = 'deliver'; | ||
|
||
/** | ||
* @var array | ||
|
@@ -34,6 +35,7 @@ class OrderOperation extends Operation\AbstractBulkOperation | |
self::TYPE_ACKNOWLEDGE, | ||
self::TYPE_UNACKNOWLEDGE, | ||
self::TYPE_UPLOAD_DOCUMENTS, | ||
self::TYPE_DELIVER, | ||
]; | ||
|
||
/** | ||
|
@@ -361,4 +363,29 @@ public function refund($reference, $channelName, $shipping = true, $products = [ | |
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Notify marketplace of order delivery | ||
* | ||
* @param string $id Order id | ||
* @param string $reference Order reference | ||
* @param string $channelName Channel to notify | ||
* | ||
* @return OrderOperation | ||
* | ||
* @throws Exception\InvalidArgumentException | ||
*/ | ||
public function deliver($id, $reference = '', $channelName = ''): self | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, I am not favorable to proposed implementation because it breaks the object consistency & it only manage IDs for deliver operation. We are a bit annoyed here, because the number of parameter has to change from My recommandation would probably to create a new OrderOperation object with fixed signatures and deprecate the actual one. SDK user would be able to use the new object if he want. I can understand that is much more work than your need here. For now, I suggest you to keep the object consitency with channel name & reference, and if you need to use IDs, to manage it on your own. I will check on my side if we can schedule to update SDK soon to manage order's ID. However, I can't give you any date yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mdumoulin, the following implementation of the method deliver is ok for you?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, because it should be either $reference and $channelName; or $id. The only suitable solution to implement it in actual object is : public function deliver($reference, $channelName): self
{
$this->addOperation(
$reference,
$channelName,
self::TYPE_DELIVER
);
return $this;
} A possible solution to manage ID would be to create another OrderOperation object. In short it could be something like that : <?php
namespace ShoppingFeed\Sdk\Api\Order;
use ShoppingFeed\Sdk\Operation\AbstractBulkOperation;
class Operation extends AbstractBulkOperation
{
public function deliver(OrderIdentifier $id): self
{
$this->addOperation(
$id,
self::TYPE_DELIVER
);
return $this;
}
}
interface OrderIdentifier
{
public function toArray(): array;
}
class Id implements OrderIdentifier
{
private $id;
public function __construct(int $id)
{
$this->id = $id;
}
public function toArray(): array
{
return [
'id' => $this->id,
];
}
}
class Reference implements OrderIdentifier
{
private $channelName;
private $reference;
public function __construct(string $channelName, string $reference)
{
$this->channelName = $channelName;
$this->reference = $reference;
}
public function toArray(): array
{
return [
'channelName' => $this->channelName,
'reference' => $this->reference,
];
}
} |
||
{ | ||
$this->addOperation( | ||
$reference, | ||
$channelName, | ||
self::TYPE_DELIVER, | ||
[ | ||
'id' => $id, | ||
] | ||
); | ||
|
||
return $this; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, you need to add also a new method in this class :
And make some tests in the OrderOperationTest class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but I would like to point out that the parameters 'reference' and 'channelName' aren't required by API anymore. Instead, the parameter 'id' should be sent. I think all methods in this class should be adapted to the new API.
Do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bogdan202, thanks for the PR. In addition to Kevin's feedback, can you add a section in documentation here please : https://github.com/shoppingflux/php-sdk/blob/master/docs/manual/resources/order.md#refund
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. This version was meant to be compatible to be integrated by old modules. It would be a good step towards the migration if the SDK could manage order's ID in addition to channel's name & order's reference.