@move-lab/shippify-node
Version:
This library allows you to quickly use Shippify API with NodeJS
88 lines (71 loc) • 2.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _lodash = require('lodash');
var _ = _interopRequireWildcard(_lodash);
var _Quote = require('./Quote');
var _Quote2 = _interopRequireDefault(_Quote);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var raw = Symbol();
var express = Symbol();
var flex = Symbol();
var Quotes = function () {
function Quotes(payload) {
_classCallCheck(this, Quotes);
this[raw] = payload.quotes;
this[express] = payload.express;
this[flex] = payload.flex;
}
_createClass(Quotes, [{
key: 'all',
get: function get() {
return this[raw].map(function (q) {
return new _Quote2.default(q);
});
}
}, {
key: 'closest',
get: function get() {
return new _Quote2.default(_.first(_.orderBy(this[raw], ['dropoffStartTime'], ['asc'])));
}
}, {
key: 'furthest',
get: function get() {
return new _Quote2.default(_.last(_.orderBy(this[raw], ['dropoffStartTime'], ['asc'])));
}
}, {
key: 'cheapest',
get: function get() {
return new _Quote2.default(_.first(_.orderBy(this[raw], ['cost'], ['asc'])));
}
}, {
key: 'expensive',
get: function get() {
return new _Quote2.default(_.first(_.orderBy(this[raw], ['cost'], ['asc'])));
}
}, {
key: 'express',
get: function get() {
return this[express];
}
}, {
key: 'flex',
get: function get() {
return this[flex];
}
}, {
key: 'raw',
get: function get() {
return this[raw];
}
}]);
return Quotes;
}();
exports.default = Quotes;
Quotes.parse = function (data) {
return new Quotes(data.payload);
};