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

Added forceToken support for pricing endpoints #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MiChAeLoKGB
Copy link

@MiChAeLoKGB MiChAeLoKGB commented Feb 10, 2022

Fixes #28

For PriceProtectionException to work, API must return PRICE_PROTECTION_ERROR instead of generic VALIDATION_ERROR when price protection mechanism is tripped.

@DRN88
Copy link

DRN88 commented Sep 7, 2023

Why is this still not merged? This exception happens all the time.

vendor/mallgroup/mpapi-client/src/Article/ArticleClient.php

    public function updateProduct(ProductRequest $product): void
    {
        $this->sendJson('PUT', sprintf(self::PRODUCT_DETAIL, $product->getId()), $product->getArrayForApi());
    }

    public function updateProductWithForceToken(ProductRequest $product, string $forceToken): void
    {
        $appendUrlWithForceToken = '?force_token=' . $forceToken;
        $this->sendJson('PUT', sprintf(self::PRODUCT_DETAIL, $product->getId()) . $appendUrlWithForceToken, $product->getArrayForApi());
    }

    public function deleteProduct(string $productId): void
    {
        $this->sendJson('DELETE', sprintf(self::PRODUCT_DETAIL, $productId));
    }

In a try-catch, get the force token, and use updateProductWithForceToken to update the product.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Product price protection
3 participants