Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 2.53 KB

README.md

File metadata and controls

55 lines (39 loc) · 2.53 KB

@particular./zendesk-magento-m1-request

npm version semantic-release code style: prettier CircleCI dependency status: david

🎮 Minimal Magento m1 API request library for Node (design for use w/ Zendesk Extension)

Installation

yarn add @particular./zendesk-magento-m1-request # npm install @particular./zendesk-magento-m1-request

Quickstart (OAuth)

const { createClient } = require('@particular./zendesk-magento-m1-request');
// import { createClient } from '@particular./zendesk-magento-m1-request'

const magentoM1 = new createClient({
  store_url: 'https://.../...', //Magento m1 Store URL
  access_token: '...' //Access token generated after installing/configuring Zendesk extension
});

magentoM1
  .get(`zendesk/api/customers/${email}`)
  .then(console.log)
  .catch(console.error);

Custom headers per request

The API provides you the ability to send various request headers that change the way data is stored or retrieved.

By default this library will encode all data as JSON, however you can customise this by setting your own Content-Type header as an additional argument to get, patch, post, put and delete.

Note: If you add the Content-Type custom header to patch, post, put or delete you will need to encode data yourself.

const magentoM1 = new createClient({
  store_url: 'https://.../...', //Magento m1 Store URL
  access_token: '...' //Access token generated after installing/configuring Zendesk extension
});

const headers = {
  'X-My-Header': 'custom'
};

magentoM1
  .get(`zendesk/api/customers/${email}`, headers)
  .then(console.log)
  .catch(console.error);

Contact Adam Grohs @ Particular. for any questions.