M2 Note: Classes for building rest client in your extension

This is about using Magento 2 internal classes useful for building restapi client in your magento extension.

\Magento\Framework\Oauth\Oauth

Oauth class will help you deal with REST authorization. Interesting function is `buildAuthorizationHeader` . Of course you should inject \Magento\Framework\Oauth\OauthInterface in your code instead of the class.

\Magento\Framework\Serialize\Serializer\Json

For building valid json bodies.

\Magento\Framework\Reflection\DataObjectProcessor

If you want to convert an object like order to array use.

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store