UNPKG

lin3s-sylius-shop-api-client

Version:

JavaScript client on top of SyliusShopApiPlugin to build integrations with ease.

43 lines (33 loc) 1.63 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios); var _requestConfig = require('../requestConfig'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } exports.default = function (config) { return function (_ref) { var email = _ref.email, firstName = _ref.firstName, lastName = _ref.lastName, plainPassword = _ref.plainPassword, rest = _objectWithoutProperties(_ref, ['email', 'firstName', 'lastName', 'plainPassword']); return new Promise(function (resolve, reject) { var headers = _extends({}, (0, _requestConfig.contentTypeJson)()); _axios2.default.post(config.baseUrl + '/shop-api/register', _extends({ email: email, firstName: firstName, lastName: lastName, plainPassword: plainPassword, channel: config.channel }, rest), headers).then(function (response) { return resolve(response.data); }).catch(function (error) { return reject(error); }); }); }; };