API Requests for Mageworx Reward Points Extension

API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog
Reading Time: 3 minutes

Within one of the recent Reward Points extension updates, support of REST API requests has been added. REST API requests allow dealing with internal customer credits in 3rd-party systems on the fly. Additionally, with their help, you get to easily integrate Magento 2 with other systems and 3rd-party front-ends, such as mobile apps, for example.

In this article, we will guide you through the available REST API requests and explain how they can come in handy. All requests can be divided into two groups. The first group helps interact with the Reward Points extension in the shopping cart. The second group of requests w ill help us either find out or edit customer reward points balances.

Available REST API Requests

Shopping Cart-Related Requests

Let me repeat myself, the first group of requests includes those that allow adding reward points to the shopping cart. PUT request will be of help here. It allows adding reward points to cart by specifying cart_id (quote_id) in the endpoint, as well as the quantity of used reward points.

You can also include ‘all’ (instead of a fixed number of applied reward points) in the endpoint. Thus, all available points will get applied to the shopping cart. Here’s how such requests will look like:

  • PUT V1/mw-rewardpoints/carts/74/points/3 -> Add Reward Points to the Shopping Cart (Add the certain number of the Reward Points to the shopping cart. Use admin Token. Specify cart_id and amount of Reward Points in the endpoint.)
API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog
  • PUT /V1/mw-rewardpoints/carts/74/points/all -> Add all Reward Points to the Shopping Cart (Add all Reward Points to the shopping cart. Use admin Token and specify cart_id in the endpoint).
API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog
  • PUT /V1/mw-rewardpoints/mine/points/3 -> Add Reward Points to the Customer Shopping Cart (Add the certain number of the Reward Points to the shopping cart. Use Customer Token. Specify amount of Reward Points in the endpoint.)
  • PUT /V1/mw-rewardpoints/mine/points/all -> Add all Reward Points to the Customer Shopping Cart (Add all Reward Points to the shopping cart. Use Customer Token.)

You might have noticed that the last two requests differ from the preceding ones. In them, a bind to ‘Customer Shopping Cart’ instead of cart_id is used. Also, the ‘mine’ value is used in the endpoint.

Additionally, DELETE requests naturally help delete the applied reward points from the shopping cart. That said, you can include either cart_id or ‘mine’ in the endpoint. Such requests look as follows:

  • DELETE /V1/mw-rewardpoints/carts/74/points -> Delete Reward Points from the shopping cart (Remove the Reward Points from the shopping cart. Use admin Token and specify cart_id in the endpoint.)
API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog
  • DELETE /V1/mw-rewardpoints/mine/points -> Delete Reward Points from the customer shopping cart (Remove the Reward Points from the shopping cart. Use Customer Token.)
API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog

GET requests will be the last ones in this group. They can help you find out the number of reward points that have been applied in the shopping cart.

  • GET /V1/mw-rewardpoints/carts/74/points -> Receive applied Reward Points to the cart (Receive the Reward Points which were applied in the shopping cart. Use admin Token and specify cart_id in the endpoint.)
API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog
  • GET /V1/mw-rewardpoints/mine/points -> Receive applied Reward Points to the shopping cart (Receive the Reward Points which were applied in the shopping cart. Use Customer Token.)

Requests Related to Reward Points Editing

Let’s proceed to the second group of requests. It includes such requests as POST and GET. With their help, we can find out the current reward points balance of a specific customer in a particular Magento 2 store, as well as edit this balance. Let’s get into details.

With the help of the GET request ― after specifying customer_id and website_id in the endpoint ― you can find out reward points balance for a particular shopper.

  • GET /V1/mw-rewardpoints/balance/customer/1/website/1 -> Receive customer balance for Reward Points (Receive customer balance for Reward Points considering website ID and customer ID in the endpoint.)
API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog

POST request allows changing a customer reward points balance. For that, you’ll need to include ‘customer_id’, ‘website_id’ and ‘points’ quantity in the request body.

  • POST /V1/mw-rewardpoints/balance -> Change Customer Balance (Change customer balance for Reward Points considering website ID and customer ID in the BODY request.)
API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog
API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog
API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog

LEAVE A REPLY

Please enter your comment!
Please enter your name here