HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/node_modules/@mollie/api-client/dist/mollie.js
'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var fs = _interopDefault(require('fs'));
var https = _interopDefault(require('https'));
var path = _interopDefault(require('path'));
var axios = _interopDefault(require('axios'));
var qs = _interopDefault(require('qs'));
var _toPlainObject = _interopDefault(require('lodash/toPlainObject'));
var omit = _interopDefault(require('lodash/omit'));

var cert = "56d9b651c121c60f.pem";

var version = "2.3.2";

/**
 * Create pre-configured httpClient instance
 * @private
 */

function createHttpClient() {
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  options.baseURL = 'https://api.mollie.com:443/v2/';
  options.headers = Object.assign({}, options.headers, {
    Authorization: "Bearer ".concat(options.apiKey),
    'Accept-Encoding': 'gzip',
    'Content-Type': 'application/json',
    'User-Agent': "node.js/".concat(process.version),
    'X-Mollie-User-Agent': "mollie/".concat(version)
  });
  options.httpsAgent = new https.Agent({
    cert: fs.readFileSync(path.resolve(__dirname, cert))
  });
  options.paramsSerializer = options.paramsSerializer || qs.stringify;
  return axios.create(options);
}

function _typeof(obj) {
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    _typeof = function (obj) {
      return typeof obj;
    };
  } else {
    _typeof = function (obj) {
      return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    };
  }

  return _typeof(obj);
}

function _classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
}

function _defineProperties(target, props) {
  for (var i = 0; i < props.length; i++) {
    var descriptor = props[i];
    descriptor.enumerable = descriptor.enumerable || false;
    descriptor.configurable = true;
    if ("value" in descriptor) descriptor.writable = true;
    Object.defineProperty(target, descriptor.key, descriptor);
  }
}

function _createClass(Constructor, protoProps, staticProps) {
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  if (staticProps) _defineProperties(Constructor, staticProps);
  return Constructor;
}

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

function _objectSpread(target) {
  for (var i = 1; i < arguments.length; i++) {
    var source = arguments[i] != null ? arguments[i] : {};
    var ownKeys = Object.keys(source);

    if (typeof Object.getOwnPropertySymbols === 'function') {
      ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
        return Object.getOwnPropertyDescriptor(source, sym).enumerable;
      }));
    }

    ownKeys.forEach(function (key) {
      _defineProperty(target, key, source[key]);
    });
  }

  return target;
}

function _inherits(subClass, superClass) {
  if (typeof superClass !== "function" && superClass !== null) {
    throw new TypeError("Super expression must either be null or a function");
  }

  subClass.prototype = Object.create(superClass && superClass.prototype, {
    constructor: {
      value: subClass,
      writable: true,
      configurable: true
    }
  });
  if (superClass) _setPrototypeOf(subClass, superClass);
}

function _getPrototypeOf(o) {
  _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
    return o.__proto__ || Object.getPrototypeOf(o);
  };
  return _getPrototypeOf(o);
}

function _setPrototypeOf(o, p) {
  _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
    o.__proto__ = p;
    return o;
  };

  return _setPrototypeOf(o, p);
}

function isNativeReflectConstruct() {
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  if (Reflect.construct.sham) return false;
  if (typeof Proxy === "function") return true;

  try {
    Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
    return true;
  } catch (e) {
    return false;
  }
}

function _construct(Parent, args, Class) {
  if (isNativeReflectConstruct()) {
    _construct = Reflect.construct;
  } else {
    _construct = function _construct(Parent, args, Class) {
      var a = [null];
      a.push.apply(a, args);
      var Constructor = Function.bind.apply(Parent, a);
      var instance = new Constructor();
      if (Class) _setPrototypeOf(instance, Class.prototype);
      return instance;
    };
  }

  return _construct.apply(null, arguments);
}

function _isNativeFunction(fn) {
  return Function.toString.call(fn).indexOf("[native code]") !== -1;
}

function _wrapNativeSuper(Class) {
  var _cache = typeof Map === "function" ? new Map() : undefined;

  _wrapNativeSuper = function _wrapNativeSuper(Class) {
    if (Class === null || !_isNativeFunction(Class)) return Class;

    if (typeof Class !== "function") {
      throw new TypeError("Super expression must either be null or a function");
    }

    if (typeof _cache !== "undefined") {
      if (_cache.has(Class)) return _cache.get(Class);

      _cache.set(Class, Wrapper);
    }

    function Wrapper() {
      return _construct(Class, arguments, _getPrototypeOf(this).constructor);
    }

    Wrapper.prototype = Object.create(Class.prototype, {
      constructor: {
        value: Wrapper,
        enumerable: false,
        writable: true,
        configurable: true
      }
    });
    return _setPrototypeOf(Wrapper, Class);
  };

  return _wrapNativeSuper(Class);
}

function _assertThisInitialized(self) {
  if (self === void 0) {
    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  }

  return self;
}

function _possibleConstructorReturn(self, call) {
  if (call && (typeof call === "object" || typeof call === "function")) {
    return call;
  }

  return _assertThisInitialized(self);
}

function _superPropBase(object, property) {
  while (!Object.prototype.hasOwnProperty.call(object, property)) {
    object = _getPrototypeOf(object);
    if (object === null) break;
  }

  return object;
}

function _get(target, property, receiver) {
  if (typeof Reflect !== "undefined" && Reflect.get) {
    _get = Reflect.get;
  } else {
    _get = function _get(target, property, receiver) {
      var base = _superPropBase(target, property);

      if (!base) return;
      var desc = Object.getOwnPropertyDescriptor(base, property);

      if (desc.get) {
        return desc.get.call(receiver);
      }

      return desc.value;
    };
  }

  return _get(target, property, receiver || target);
}

function _toConsumableArray(arr) {
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}

function _arrayWithoutHoles(arr) {
  if (Array.isArray(arr)) {
    for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];

    return arr2;
  }
}

function _iterableToArray(iter) {
  if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}

function _nonIterableSpread() {
  throw new TypeError("Invalid attempt to spread non-iterable instance");
}

var url = require('url'); // eslint-disable-next-line import/prefer-default-export


var parseCursorUrl = function parseCursorUrl(cursorUrl) {
  return url.parse(cursorUrl, true);
};

/**
 * A list helper class
 */

var List =
/*#__PURE__*/
function (_Array) {
  _inherits(List, _Array);

  function List() {
    var _this;

    _classCallCheck(this, List);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(List).call(this));
    _this.links = null;
    _this.count = null;
    _this.nextPage = null;
    _this.previousPage = null;
    _this.nextPageCursor = null;
    _this.previousPageCursor = null;
    return _this;
  }

  _createClass(List, null, [{
    key: "getNextPageParams",
    value: function getNextPageParams(links) {
      if (links.next && links.next.href) {
        return parseCursorUrl(links.next.href).query;
      }

      return {};
    }
  }, {
    key: "getPreviousPageParams",
    value: function getPreviousPageParams(links) {
      if (links.previous && links.previous.href) {
        return parseCursorUrl(links.previous.href).query;
      }

      return {};
    }
  }, {
    key: "buildResourceList",
    value: function buildResourceList(_ref) {
      var response = _ref.response,
          resourceName = _ref.resourceName,
          params = _ref.params,
          callback = _ref.callback,
          getResources = _ref.getResources,
          Model = _ref.Model;

      var _embedded = response._embedded,
          _response$count = response.count,
          count = _response$count === void 0 ? 0 : _response$count,
          _response$_links = response._links,
          _links = _response$_links === void 0 ? [] : _response$_links;

      var resources = _embedded[resourceName];
      var list = new List();
      list.links = _links;
      list.count = count;

      list.nextPage = function () {
        return getResources(_objectSpread({}, params, List.getNextPageParams(_links)), callback);
      };

      list.previousPage = function () {
        return getResources(_objectSpread({}, params, List.getPreviousPageParams(_links)), callback);
      };

      list.nextPageCursor = List.getNextPageParams(_links).from;
      list.previousPageCursor = List.getPreviousPageParams(_links).from;
      list.push.apply(list, _toConsumableArray(resources.map(function (resource) {
        return new Model(resource);
      })));
      return list;
    }
  }]);

  return List;
}(_wrapNativeSuper(Array));

/**
 * The base resource
 * @param {Object} httpClient
 * @private
 */

var Resource =
/*#__PURE__*/
function () {
  /**
   * Constructor
   * @param httpClient
   */
  function Resource(httpClient) {
    _classCallCheck(this, Resource);

    this.httpClient = httpClient;
  }
  /**
   * Error handler
   * @param {*} response
   * @param {function} [cb]
   * @since 2.0.0
   * @private
   */


  _createClass(Resource, [{
    key: "getClient",

    /**
     * Get the API client
     * @returns {Object} httpClient
     * @since 2.0.0
     * @private
     */
    value: function getClient() {
      return this.httpClient;
    }
    /**
     * Set the parent ID by providing the parent
     * @param parent
     * @since 1.1.1
     * @deprecated
     */

  }, {
    key: "withParent",
    value: function withParent(parent) {
      if (parent && parent.id) {
        this.setParentId(parent.id);
      }

      return this;
    }
    /**
     * Set the parent ID
     * @param {number} parentId
     * @since 2.0.0
     * @protected
     */

  }, {
    key: "setParentId",
    value: function setParentId(parentId) {
      this.parentId = parentId;
    }
    /**
     * If the parent ID is set
     * @returns {boolean}
     * @since 2.0.0
     */

  }, {
    key: "hasParentId",
    value: function hasParentId() {
      return !!this.parentId;
    }
    /**
     * Create a resource URL with the parent ID
     * @returns {string} resourceUrl
     * @since 2.0.0
     * @private
     */

  }, {
    key: "getResourceUrl",
    value: function getResourceUrl() {
      if (this.constructor.resource.indexOf('_') !== -1) {
        var parts = this.constructor.resource.split('_');
        return "".concat(parts[0], "/").concat(this.parentId, "/").concat(parts[1]);
      }

      return this.constructor.resource;
    }
    /**
     * Get the resource name from the resource identifier
     * @returns {string} resourceUrl
     * @since 2.0.0-rc.2
     * @private
     */

  }, {
    key: "getResourceName",
    value: function getResourceName() {
      if (this.constructor.resource.includes('_')) {
        return this.constructor.resource.split('_')[1];
      }

      return this.constructor.resource;
    }
    /**
     * Create a resource by ID
     * @param {Object} [data]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.0.0
     */

  }, {
    key: "create",
    value: function create(data, cb) {
      var _this = this;

      if (typeof data === 'function') {
        cb = data; // eslint-disable-line no-param-reassign
      }

      return this.getClient().post(this.getResourceUrl(), data).then(function (response) {
        var model = new _this.constructor.model(response.data);

        if (cb) {
          return cb(null, model);
        }

        return model;
      }).catch(function (error) {
        return Resource.errorHandler(error.response, cb);
      });
    }
    /**
     * Get a resource by ID
     * @param {number} id
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.0.0
     */

  }, {
    key: "get",
    value: function get(id, params, cb) {
      var _this2 = this;

      if (typeof params === 'function') {
        cb = params; // eslint-disable-line no-param-reassign
      }

      return this.getClient().get("".concat(this.getResourceUrl(), "/").concat(id), {
        params: params
      }).then(function (response) {
        var model = new _this2.constructor.model(response.data);

        if (cb) {
          return cb(null, model);
        }

        return model;
      }).catch(function (error) {
        return Resource.errorHandler(error.response, cb);
      });
    }
    /**
     * Get all resources
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.0.0
     */

  }, {
    key: "all",
    value: function all(params, cb) {
      var _this3 = this;

      if (typeof params === 'function') {
        cb = params; // eslint-disable-line no-param-reassign
      }

      return this.getClient().get(this.getResourceUrl(), {
        params: params
      }).then(function (response) {
        var resourceName = _this3.getResourceName();

        var list = List.buildResourceList({
          response: response.data,
          resourceName: resourceName,
          params: params,
          callback: cb,
          getResources: _this3.all.bind(_this3),
          Model: _this3.constructor.model
        });

        if (cb) {
          return cb(null, list);
        }

        return list;
      }).catch(function (error) {
        return Resource.errorHandler(error.response, cb);
      });
    }
    /**
     * Update a resource by ID
     * @param {number} id
     * @param {Object} [data]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.0.0
     */

  }, {
    key: "update",
    value: function update(id, data, cb) {
      var _this4 = this;

      if (typeof data === 'function') {
        cb = data; // eslint-disable-line no-param-reassign
      }

      return this.getClient().post("".concat(this.getResourceUrl(), "/").concat(id), data).then(function (response) {
        var model = new _this4.constructor.model(response.data);

        if (cb) {
          return cb(null, model);
        }

        return model;
      }).catch(function (error) {
        return Resource.errorHandler(error.response, cb);
      });
    }
    /**
     * Delete a resource by ID
     * @param {number} id
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.0.0
     */

  }, {
    key: "delete",
    value: function _delete(id, cb) {
      var _this5 = this;

      return this.getClient().delete("".concat(this.getResourceUrl(), "/").concat(id)).then(function (response) {
        var model = new _this5.constructor.model(response.data);

        if (cb) {
          return cb(null, model);
        }

        return model;
      }).catch(function (error) {
        return Resource.errorHandler(error.response, cb);
      });
    }
  }], [{
    key: "errorHandler",
    value: function errorHandler(response, cb) {
      var error = response && response.data || response;

      if (cb) {
        return cb(error);
      }

      throw error;
    }
  }]);

  return Resource;
}();

/**
 * Base model
 */

var Model =
/*#__PURE__*/
function () {
  function Model() {
    _classCallCheck(this, Model);
  }

  _createClass(Model, [{
    key: "toPlainObject",

    /**
     * Converts a model into a plain object
     * @returns {Object}
     */
    value: function toPlainObject() {
      return _toPlainObject(this);
    }
  }]);

  return Model;
}();

/**
 * The `Payment` model
 */

var Payment =
/*#__PURE__*/
function (_Model) {
  _inherits(Payment, _Model);

  function Payment(props) {
    var _this;

    _classCallCheck(this, Payment);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Payment).call(this, props));
    var defaults = {
      resource: 'payment',
      id: null,
      mode: null,
      createdAt: null,
      status: null,
      isCancelable: null,
      paidAt: null,
      canceledAt: null,
      expiresAt: null,
      expiredAt: null,
      failedAt: null,
      amount: {
        value: null,
        currency: null
      },
      amountRefunded: null,
      amountRemaining: null,
      description: null,
      redirectUrl: null,
      webhookUrl: null,
      method: null,
      metadata: null,
      locale: null,
      countryCode: null,
      profileId: null,
      settlementAmount: null,
      settlementId: null,
      customerId: null,
      sequenceType: null,
      mandateId: null,
      subscriptionId: null,
      applicationFee: {
        amount: {
          value: null,
          currency: null
        },
        description: null
      },
      details: null,
      _links: {
        checkout: null,
        refunds: null,
        chargebacks: null,
        settlement: null,
        mandate: null,
        subscription: null,
        customer: null
      }
    };
    Object.assign(_assertThisInitialized(_this), defaults, props);
    return _this;
  }
  /**
   * If the payment is open
   * @returns {boolean}
   */


  _createClass(Payment, [{
    key: "isOpen",
    value: function isOpen() {
      return this.status === Payment.STATUS_OPEN;
    }
    /**
     * If the payment is authorized
     * @returns {boolean}
     */

  }, {
    key: "isAuthorized",
    value: function isAuthorized() {
      return this.status === Payment.STATUS_AUTHORIZED;
    }
    /**
     * If the payment is paid
     * @returns {boolean}
     */

  }, {
    key: "isPaid",
    value: function isPaid() {
      return !!this.paidAt;
    }
    /**
     * If the payment is canceled
     * @returns {boolean}
     */

  }, {
    key: "isCanceled",
    value: function isCanceled() {
      return !!this.canceledAt;
    }
    /**
     * If the payment is expired
     * @returns {boolean}
     */

  }, {
    key: "isExpired",
    value: function isExpired() {
      return !!this.expiredAt;
    }
    /**
     * If the payment is refundable
     * @returns {boolean}
     * @since 2.0.0-rc.2
     */

  }, {
    key: "isRefundable",
    value: function isRefundable() {
      return this.amountRemaining !== null;
    }
    /**
     * Get the payment URL
     * @returns {string|null}
     */

  }, {
    key: "getPaymentUrl",
    value: function getPaymentUrl() {
      return this._links && this._links.checkout && this._links.checkout.href;
    }
  }]);

  return Payment;
}(Model);

_defineProperty(Payment, "STATUS_OPEN", 'open');

_defineProperty(Payment, "STATUS_PENDING", 'pending');

_defineProperty(Payment, "STATUS_CANCELED", 'canceled');

_defineProperty(Payment, "STATUS_EXPIRED", 'expired');

_defineProperty(Payment, "STATUS_PAID", 'paid');

_defineProperty(Payment, "STATUS_FAILED", 'failed');

_defineProperty(Payment, "STATUS_AUTHORIZED", 'authorized');

_defineProperty(Payment, "SEQUENCETYPE_ONEOFF", 'oneoff');

_defineProperty(Payment, "SEQUENCETYPE_FIRST", 'first');

_defineProperty(Payment, "SEQUENCETYPE_RECURRING", 'recurring');

/**
 * The `payments` resource
 * @static {string} resource
 * @static {Object} model
 * @since 1.0.0
 */

var Payments =
/*#__PURE__*/
function (_Resource) {
  _inherits(Payments, _Resource);

  function Payments() {
    _classCallCheck(this, Payments);

    return _possibleConstructorReturn(this, _getPrototypeOf(Payments).apply(this, arguments));
  }

  return Payments;
}(Resource);

_defineProperty(Payments, "resource", 'payments');

_defineProperty(Payments, "model", Payment);

/**
 * Payments base resource
 * @private
 */

var PaymentsResource =
/*#__PURE__*/
function (_Resource) {
  _inherits(PaymentsResource, _Resource);

  function PaymentsResource() {
    _classCallCheck(this, PaymentsResource);

    return _possibleConstructorReturn(this, _getPrototypeOf(PaymentsResource).apply(this, arguments));
  }

  _createClass(PaymentsResource, [{
    key: "setParent",

    /**
     * Set the parent
     * @param {Object} params
     * @since 2.0.0
     */
    value: function setParent() {
      var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      if (!params.paymentId && !this.hasParentId()) {
        throw TypeError('Missing parameter "paymentId".');
      } else if (params.paymentId) {
        this.setParentId(params.paymentId);
      }
    }
  }]);

  return PaymentsResource;
}(Resource);

/**
 * The `Refund` model
 */

var Refund =
/*#__PURE__*/
function (_Model) {
  _inherits(Refund, _Model);

  function Refund(props) {
    var _this;

    _classCallCheck(this, Refund);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Refund).call(this, props));
    var defaults = {
      resource: 'refund',
      id: null,
      amount: {
        currency: null,
        value: null
      },
      settlementAmount: null,
      description: null,
      status: null,
      createdAt: null,
      paymentId: null,
      _links: {
        payment: null,
        settlement: null
      }
    };
    Object.assign(_assertThisInitialized(_this), defaults, props);
    return _this;
  }
  /**
   * The refund is queued until there is enough balance to process te refund. You can still cancel
   * the refund.
   * @returns {boolean}
   */


  _createClass(Refund, [{
    key: "isQueued",
    value: function isQueued() {
      return this.status === Refund.STATUS_QUEUED;
    }
    /**
     * The refund will be sent to the bank on the next business day. You can still cancel the refund.
     * @returns {boolean}
     */

  }, {
    key: "isPending",
    value: function isPending() {
      return this.status === Refund.STATUS_PENDING;
    }
    /**
     * The refund has been sent to the bank. The refund amount will be transferred to the consumer
     * account as soon as possible.
     * @returns {boolean}
     */

  }, {
    key: "isProcessing",
    value: function isProcessing() {
      return this.status === Refund.STATUS_PROCESSING;
    }
    /**
     * The refund amount has been transferred to the consumer.
     * @returns {boolean}
     */

  }, {
    key: "isRefunded",
    value: function isRefunded() {
      return this.status === Refund.STATUS_REFUNDED;
    }
    /**
     * The refund has failed during processing.
     * @returns {boolean}
     */

  }, {
    key: "isFailed",
    value: function isFailed() {
      return this.status === Refund.STATUS_FAILED;
    }
  }]);

  return Refund;
}(Model);

_defineProperty(Refund, "STATUS_QUEUED", 'queued');

_defineProperty(Refund, "STATUS_PENDING", 'pending');

_defineProperty(Refund, "STATUS_PROCESSING", 'processing');

_defineProperty(Refund, "STATUS_REFUNDED", 'refunded');

_defineProperty(Refund, "STATUS_FAILED", 'failed');

/**
 * The `payments_refunds` resource
 * @static {string} resource
 * @static {Object} model
 * @since 1.1.1
 */

var PaymentsRefunds =
/*#__PURE__*/
function (_PaymentsResource) {
  _inherits(PaymentsRefunds, _PaymentsResource);

  function PaymentsRefunds() {
    _classCallCheck(this, PaymentsRefunds);

    return _possibleConstructorReturn(this, _getPrototypeOf(PaymentsRefunds).apply(this, arguments));
  }

  _createClass(PaymentsRefunds, [{
    key: "create",

    /**
     * Create a payment refund
     * @param {Object} [data]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.1.1
     */
    value: function create(data, cb) {
      this.setParent(data);

      if (_typeof(data) === 'object') {
        data = omit(data, 'paymentId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(PaymentsRefunds.prototype), "create", this).call(this, data, cb);
    }
    /**
     * Get a payment refund by ID
     * @param {number} id
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.1.1
     */

  }, {
    key: "get",
    value: function get(id, params, cb) {
      this.setParent(params);

      if (_typeof(params) === 'object') {
        params = omit(params, 'paymentId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(PaymentsRefunds.prototype), "get", this).call(this, id, params, cb);
    }
    /**
     * Get all payment refunds
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.1.1
     */

  }, {
    key: "all",
    value: function all(params, cb) {
      this.setParent(params);

      if (_typeof(params) === 'object') {
        params = omit(params, 'paymentId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(PaymentsRefunds.prototype), "all", this).call(this, params, cb);
    }
    /**
     * Delete a payment_refund by ID
     * @param {number} id
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.1.1
     */

  }, {
    key: "delete",
    value: function _delete(id, params, cb) {
      if (typeof params === 'function') {
        cb = params; // eslint-disable-line no-param-reassign
      }

      this.setParent(params);
      return _get(_getPrototypeOf(PaymentsRefunds.prototype), "delete", this).call(this, id, cb);
    }
    /**
     * Alias for delete
     * @since 1.3.2
     */

  }, {
    key: "cancel",
    value: function cancel() {
      return this.delete.apply(this, arguments);
    }
  }]);

  return PaymentsRefunds;
}(PaymentsResource);

_defineProperty(PaymentsRefunds, "resource", 'payments_refunds');

_defineProperty(PaymentsRefunds, "model", Refund);

/**
 * The `Method` model
 */

var Method =
/*#__PURE__*/
function (_Model) {
  _inherits(Method, _Model);

  function Method(props) {
    var _this;

    _classCallCheck(this, Method);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Method).call(this, props));
    var defaults = {
      resource: 'method',
      id: null,
      description: null,
      image: {
        size1x: null,
        size2x: null
      }
    };
    Object.assign(_assertThisInitialized(_this), defaults, props);
    return _this;
  }
  /**
   * @param size
   * @returns {string|null}
   */


  _createClass(Method, [{
    key: "getImage",
    value: function getImage() {
      var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '2x';
      return this.image && (size === '1x' ? this.image.size1x : this.image.size2x);
    }
  }]);

  return Method;
}(Model);

/**
 * The `methods` resource
 * @static {string} resource
 * @static {Object} model
 * @since 1.0.0
 */

var Methods =
/*#__PURE__*/
function (_Resource) {
  _inherits(Methods, _Resource);

  function Methods() {
    _classCallCheck(this, Methods);

    return _possibleConstructorReturn(this, _getPrototypeOf(Methods).apply(this, arguments));
  }

  return Methods;
}(Resource);

_defineProperty(Methods, "resource", 'methods');

_defineProperty(Methods, "model", Method);

/**
 * The `refunds` resource
 * @static {string} resource
 * @static {Object} model
 * @since 2.0.0
 */

var Refunds =
/*#__PURE__*/
function (_Resource) {
  _inherits(Refunds, _Resource);

  function Refunds() {
    _classCallCheck(this, Refunds);

    return _possibleConstructorReturn(this, _getPrototypeOf(Refunds).apply(this, arguments));
  }

  return Refunds;
}(Resource);

_defineProperty(Refunds, "resource", 'refunds');

_defineProperty(Refunds, "model", Refund);

/**
 * The `Customer` model
 */

var Customer =
/*#__PURE__*/
function (_Model) {
  _inherits(Customer, _Model);

  function Customer(props) {
    var _this;

    _classCallCheck(this, Customer);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Customer).call(this, props));
    var defaults = {
      resource: 'customer',
      id: null,
      mode: null,
      name: null,
      email: null,
      locale: null,
      metadata: null,
      recentlyUsedMethods: null,
      createdAt: null,
      _links: {
        mandates: null,
        subscriptions: null,
        payments: null
      }
    };
    Object.assign(_assertThisInitialized(_this), defaults, props);
    return _this;
  }

  return Customer;
}(Model);

/**
 * The `customers` resource
 * @static {string} resource
 * @static {Object} model
 * @since 1.1.1
 */

var Customers =
/*#__PURE__*/
function (_Resource) {
  _inherits(Customers, _Resource);

  function Customers() {
    _classCallCheck(this, Customers);

    return _possibleConstructorReturn(this, _getPrototypeOf(Customers).apply(this, arguments));
  }

  return Customers;
}(Resource);

_defineProperty(Customers, "resource", 'customers');

_defineProperty(Customers, "model", Customer);

/**
 * Customers base resource
 * @private
 */

var CustomersResource =
/*#__PURE__*/
function (_Resource) {
  _inherits(CustomersResource, _Resource);

  function CustomersResource() {
    _classCallCheck(this, CustomersResource);

    return _possibleConstructorReturn(this, _getPrototypeOf(CustomersResource).apply(this, arguments));
  }

  _createClass(CustomersResource, [{
    key: "setParent",

    /**
     * Set the parent
     * @param {Object} params
     * @since 2.0.0
     */
    value: function setParent() {
      var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      if (!params.customerId && !this.hasParentId()) {
        throw TypeError('Missing parameter "customerId".');
      } else if (params.customerId) {
        this.setParentId(params.customerId);
      }
    }
  }]);

  return CustomersResource;
}(Resource);

/**
 * The `customers_payments` resource
 * @static {string} resource
 * @static {Object} model
 * @since 1.1.1
 */

var CustomersPayments =
/*#__PURE__*/
function (_CustomersResource) {
  _inherits(CustomersPayments, _CustomersResource);

  function CustomersPayments() {
    _classCallCheck(this, CustomersPayments);

    return _possibleConstructorReturn(this, _getPrototypeOf(CustomersPayments).apply(this, arguments));
  }

  _createClass(CustomersPayments, [{
    key: "create",

    /**
     * Create a customer payment
     * @param {Object} [data]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.1.1
     */
    value: function create(data, cb) {
      this.setParent(data);

      if (_typeof(data) === 'object') {
        data = omit(data, 'customerId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(CustomersPayments.prototype), "create", this).call(this, data, cb);
    }
    /**
     * Get a customer payment
     * @param {number} id
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.1.1
     */

  }, {
    key: "get",
    value: function get(id, params, cb) {
      this.setParent(params);

      if (_typeof(params) === 'object') {
        params = omit(params, 'customerId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(CustomersPayments.prototype), "get", this).call(this, id, params, cb);
    }
    /**
     * Get all of a customer's payments
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.1.1
     */

  }, {
    key: "all",
    value: function all(params, cb) {
      this.setParent(params);

      if (_typeof(params) === 'object') {
        params = omit(params, 'customerId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(CustomersPayments.prototype), "all", this).call(this, params, cb);
    }
  }]);

  return CustomersPayments;
}(CustomersResource);

_defineProperty(CustomersPayments, "resource", 'customers_payments');

_defineProperty(CustomersPayments, "model", Payment);

/**
 * The `Mandate` model
 */

var Mandate =
/*#__PURE__*/
function (_Model) {
  _inherits(Mandate, _Model);

  function Mandate(props) {
    var _this;

    _classCallCheck(this, Mandate);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Mandate).call(this, props));
    var defaults = {
      resource: 'mandate',
      id: null,
      status: null,
      method: null,
      details: null,
      mandateReference: null,
      signatureDate: null,
      createdAt: null,
      _links: {
        customer: null
      }
    };
    Object.assign(_assertThisInitialized(_this), defaults, props);
    return _this;
  }
  /**
   * If the mandate is valid
   * @returns {boolean}
   */


  _createClass(Mandate, [{
    key: "isValid",
    value: function isValid() {
      return this.status === Mandate.STATUS_VALID;
    }
  }]);

  return Mandate;
}(Model);

_defineProperty(Mandate, "STATUS_VALID", 'valid');

_defineProperty(Mandate, "STATUS_INVALID", 'invalid');

/**
 * The `customers_mandates` resource
 * @static {string} resource
 * @static {Object} model
 * @since 1.2.0
 */

var CustomersMandates =
/*#__PURE__*/
function (_CustomersResource) {
  _inherits(CustomersMandates, _CustomersResource);

  function CustomersMandates() {
    _classCallCheck(this, CustomersMandates);

    return _possibleConstructorReturn(this, _getPrototypeOf(CustomersMandates).apply(this, arguments));
  }

  _createClass(CustomersMandates, [{
    key: "create",

    /**
     * Create a customer mandate
     * @param {Object} [data]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.2.0
     */
    value: function create(data, cb) {
      this.setParent(data);

      if (_typeof(data) === 'object') {
        data = omit(data, 'customerId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(CustomersMandates.prototype), "create", this).call(this, data, cb);
    }
    /**
     * Get a customer mandate by ID
     * @param id
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.2.0
     */

  }, {
    key: "get",
    value: function get(id, params, cb) {
      this.setParent(params);

      if (_typeof(params) === 'object') {
        params = omit(params, 'customerId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(CustomersMandates.prototype), "get", this).call(this, id, params, cb);
    }
    /**
     * Get all of a customer's mandates
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.2.0
     */

  }, {
    key: "all",
    value: function all(params, cb) {
      this.setParent(params);

      if (_typeof(params) === 'object') {
        params = omit(params, 'customerId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(CustomersMandates.prototype), "all", this).call(this, params, cb);
    }
    /**
     * Delete a customer subscription
     * @param id
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 2.0.0
     */

  }, {
    key: "delete",
    value: function _delete(id, params, cb) {
      if (typeof params === 'function') {
        cb = params; // eslint-disable-line no-param-reassign
      }

      this.setParent(params);
      return _get(_getPrototypeOf(CustomersMandates.prototype), "delete", this).call(this, id, cb);
    }
    /**
     * Alias for delete
     * @since 1.3.2
     */

  }, {
    key: "cancel",
    value: function cancel() {
      return this.delete.apply(this, arguments);
    }
    /**
     * Alias of delete
     * @since 2.0.0
     */

  }, {
    key: "revoke",
    value: function revoke() {
      return this.delete.apply(this, arguments);
    }
  }]);

  return CustomersMandates;
}(CustomersResource);

_defineProperty(CustomersMandates, "resource", 'customers_mandates');

_defineProperty(CustomersMandates, "model", Mandate);

/**
 * The `Subscription` model
 */

var Subscription =
/*#__PURE__*/
function (_Model) {
  _inherits(Subscription, _Model);

  // Waiting for a valid mandate.
  // Active, but mandate became invalid.
  function Subscription(props) {
    var _this;

    _classCallCheck(this, Subscription);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Subscription).call(this, props));
    var defaults = {
      resource: 'subscription',
      id: null,
      mode: null,
      createdAt: null,
      status: null,
      amount: {
        currency: null,
        value: null
      },
      times: null,
      interval: null,
      startDate: null,
      description: null,
      method: null,
      canceledAt: null,
      webhookUrl: null,
      _links: {
        customer: null
      }
    };
    Object.assign(_assertThisInitialized(_this), defaults, props);
    return _this;
  }
  /**
   * Get the webhook url
   * @returns {boolean|string}
   */


  _createClass(Subscription, [{
    key: "getWebhookUrl",
    value: function getWebhookUrl() {
      return this.webhookUrl;
    }
    /**
     * If the subscription is active
     * @returns {boolean}
     */

  }, {
    key: "isActive",
    value: function isActive() {
      return this.status === Subscription.STATUS_ACTIVE;
    }
    /**
     * If the subscription is pending
     * @returns {boolean}
     */

  }, {
    key: "isPending",
    value: function isPending() {
      return this.status === Subscription.STATUS_PENDING;
    }
    /**
     * If the subscription is completed
     * @returns {boolean}
     */

  }, {
    key: "isCompleted",
    value: function isCompleted() {
      return this.status === Subscription.STATUS_COMPLETED;
    }
    /**
     * If the subscription is suspended
     * @returns {boolean}
     */

  }, {
    key: "isSuspended",
    value: function isSuspended() {
      return this.status === Subscription.STATUS_SUSPENDED;
    }
    /**
     * If the subscription is canceled
     * @returns {boolean}
     */

  }, {
    key: "isCanceled",
    value: function isCanceled() {
      return !!this.canceledAt;
    }
  }]);

  return Subscription;
}(Model);

_defineProperty(Subscription, "STATUS_ACTIVE", 'active');

_defineProperty(Subscription, "STATUS_PENDING", 'pending');

_defineProperty(Subscription, "STATUS_CANCELED", 'canceled');

_defineProperty(Subscription, "STATUS_SUSPENDED", 'suspended');

_defineProperty(Subscription, "STATUS_COMPLETED", 'completed');

/**
 * The `customers_subscriptions` resource
 * @static {string} resource
 * @static {Object} model
 * @since 1.3.2
 */

var CustomersSubscriptions =
/*#__PURE__*/
function (_CustomersResource) {
  _inherits(CustomersSubscriptions, _CustomersResource);

  function CustomersSubscriptions() {
    _classCallCheck(this, CustomersSubscriptions);

    return _possibleConstructorReturn(this, _getPrototypeOf(CustomersSubscriptions).apply(this, arguments));
  }

  _createClass(CustomersSubscriptions, [{
    key: "create",

    /**
     * Create a customer subscription
     * @param {Object} [data]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.3.2
     */
    value: function create(data, cb) {
      this.setParent(data);

      if (_typeof(data) === 'object') {
        data = omit(data, 'customerId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(CustomersSubscriptions.prototype), "create", this).call(this, data, cb);
    }
    /**
     * Get a customer subscription
     * @param id
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.3.2
     */

  }, {
    key: "get",
    value: function get(id, params, cb) {
      this.setParent(params);

      if (_typeof(params) === 'object') {
        params = omit(params, 'customerId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(CustomersSubscriptions.prototype), "get", this).call(this, id, params, cb);
    }
    /**
     * Get all customer's subscriptions
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.3.2
     */

  }, {
    key: "all",
    value: function all(params, cb) {
      this.setParent(params);

      if (_typeof(params) === 'object') {
        params = omit(params, 'customerId'); // eslint-disable-line no-param-reassign
      }

      return _get(_getPrototypeOf(CustomersSubscriptions.prototype), "all", this).call(this, params, cb);
    }
    /**
     * Delete a customer subscription
     * @param id
     * @param {Object} [params]
     * @param {function} [cb]
     * @returns {Promise.<T>}
     * @since 1.3.2
     */

  }, {
    key: "delete",
    value: function _delete(id, params, cb) {
      if (typeof params === 'function') {
        cb = params; // eslint-disable-line no-param-reassign
      }

      this.setParent(params);
      return _get(_getPrototypeOf(CustomersSubscriptions.prototype), "delete", this).call(this, id, cb);
    }
    /**
     * Alias for delete
     * @since 1.3.2
     */

  }, {
    key: "cancel",
    value: function cancel(id, params, cb) {
      return this.delete(id, params, cb);
    }
  }]);

  return CustomersSubscriptions;
}(CustomersResource);

_defineProperty(CustomersSubscriptions, "resource", 'customers_subscriptions');

_defineProperty(CustomersSubscriptions, "model", Subscription);

/**
 * The `Chargeback` model
 */

var Chargeback =
/*#__PURE__*/
function (_Model) {
  _inherits(Chargeback, _Model);

  function Chargeback(props) {
    var _this;

    _classCallCheck(this, Chargeback);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Chargeback).call(this, props));
    var defaults = {
      resource: 'chargeback',
      id: null,
      amount: null,
      settlementAmount: null,
      createdAt: null,
      reversedAt: null,
      paymentId: null,
      _links: {
        payment: null,
        settlement: null
      }
    };
    Object.assign(_assertThisInitialized(_this), defaults, props);
    return _this;
  }

  return Chargeback;
}(Model);

/**
 * The `chargebacks` resource
 * @static {string} resource
 * @static {Object} model
 * @since 2.0.0-rc.1
 */

var Chargebacks =
/*#__PURE__*/
function (_Resource) {
  _inherits(Chargebacks, _Resource);

  function Chargebacks() {
    _classCallCheck(this, Chargebacks);

    return _possibleConstructorReturn(this, _getPrototypeOf(Chargebacks).apply(this, arguments));
  }

  return Chargebacks;
}(Resource);

_defineProperty(Chargebacks, "resource", 'chargebacks');

_defineProperty(Chargebacks, "model", Chargeback);

/**
 * Create Mollie API
 * @param {Object} httpClient
 * @returns {Object} available resources
 * @since 2.0.0
 */

function createMollieApi(_ref) {
  var httpClient = _ref.httpClient;
  return {
    payments: new Payments(httpClient),
    payments_refunds: new PaymentsRefunds(httpClient),
    methods: new Methods(httpClient),
    refunds: new Refunds(httpClient),
    customers: new Customers(httpClient),
    customers_payments: new CustomersPayments(httpClient),
    customers_mandates: new CustomersMandates(httpClient),
    customers_subscriptions: new CustomersSubscriptions(httpClient),
    chargebacks: new Chargebacks(httpClient)
  };
}

/**
 * Create Mollie client.
 * @param options
 * @returns {Object} available resources
 * @since 2.0.0
 */

function mollie() {
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

  if (!options.apiKey) {
    throw new TypeError('Missing parameter "apiKey".');
  }

  var httpClient = createHttpClient(options);
  return createMollieApi({
    httpClient: httpClient
  });
}

module.exports = mollie;