From a3a6db3fbc0b83befcb707a77fbca1fe9f4b21e7 Mon Sep 17 00:00:00 2001 From: Siavash Malekpour Date: Mon, 5 Mar 2018 13:03:45 -0500 Subject: [PATCH] Move out private resources into a separate private repo (#14) * Move private gapi resources to a private repo https://trello.com/c/6KWY9NZj --- .npmignore | 3 - build/gapi-js.js | 2 +- build/gapi-js.js.map | 2 +- package.json | 2 +- src/gapi-js.js | 218 ++++++++++++++++++++++-------------------- src/gapi-resources.js | 24 ----- 6 files changed, 117 insertions(+), 134 deletions(-) delete mode 100644 .npmignore diff --git a/.npmignore b/.npmignore deleted file mode 100644 index d33e8d7..0000000 --- a/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.idea -node_modules -src diff --git a/build/gapi-js.js b/build/gapi-js.js index 2585d69..b6621f3 100644 --- a/build/gapi-js.js +++ b/build/gapi-js.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("superagent")):"function"==typeof define&&define.amd?define(["superagent"],t):"object"==typeof exports?exports["gapi-js"]=t(require("superagent")):e["gapi-js"]=t(e._)}(this,function(e){return function(e){function t(s){if(r[s])return r[s].exports;var n=r[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,s){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:s})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,r){"use strict";function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=this._getUrl();return this.request=a.default.get(r),this.page(e,t),this}},{key:"query",value:function(e){return this.queryParams=Object.assign({},this.queryParams,e),this}},{key:"page",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;return this.query({page:e,max_per_page:t}),this}},{key:"order",value:function(){for(var e=this,t=arguments.length,r=Array(t),s=0;s0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=this._getUrl();return this.request=c.default.get(r),this.page(e,t),this}},{key:"query",value:function(e){return this.queryParams=Object.assign({},this.queryParams,e),this}},{key:"page",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;return this.query({page:e,max_per_page:t}),this}},{key:"order",value:function(){for(var e=this,t=arguments.length,r=Array(t),n=0;n 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;\n\n /**\n * By default will look for the first 20 items\n **/\n var url = this._getUrl();\n this.request = _superagent2.default.get(url);\n this.page(number, size);\n return this;\n }\n }, {\n key: 'query',\n value: function query(queryObj) {\n this.queryParams = Object.assign({}, this.queryParams, queryObj);\n return this;\n }\n }, {\n key: 'page',\n value: function page() {\n var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;\n\n this.query({ page: number, max_per_page: size });\n return this;\n }\n }, {\n key: 'order',\n value: function order() {\n var _this3 = this;\n\n for (var _len2 = arguments.length, fields = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n fields[_key2] = arguments[_key2];\n }\n\n fields.forEach(function (orderProp) {\n var thisOrderProp = orderProp;\n var isDesc = orderProp.indexOf('-') === 0;\n if (isDesc) {\n thisOrderProp = orderProp.slice(1);\n }\n if (thisOrderProp.length === 0) {\n throw new Error('Order parameter property is an empty string');\n }\n var queryParam = 'order_by__' + (isDesc ? 'desc' : 'asc');\n _this3.dupableParams.push([queryParam, thisOrderProp]);\n });\n return this;\n }\n }, {\n key: 'post',\n value: function post() {\n var url = this._getUrl();\n this.request = _superagent2.default.post(url);\n return this;\n }\n }, {\n key: 'patch',\n value: function patch(ids) {\n var url = this._getUrl(ids);\n this.request = _superagent2.default.patch(url);\n return this;\n }\n }, {\n key: 'del',\n value: function del(ids) {\n var url = this._getUrl(ids);\n this.request = _superagent2.default.del(url);\n return this;\n }\n }, {\n key: 'graphQL',\n value: function graphQL(query, variables) {\n var url = [this.baseUrl, 'graphql'].join('/') + '/';\n this.request = _superagent2.default.post(url).send({ query: query, variables: variables });\n return this;\n }\n }, {\n key: 'send',\n value: function send(args) {\n this.request.send(args);\n return this;\n }\n }, {\n key: 'end',\n value: function end(callback) {\n this.request.query({ 'cache_bust': Date.now() });\n this._setHeadersParams().request.end(callback);\n return this;\n }\n }, {\n key: 'then',\n value: function then(resolve, reject) {\n this.request.query({ 'cache_bust': Date.now() });\n return this._setHeadersParams().request.then(resolve, reject);\n }\n }]);\n\n return Gapi;\n}(_gapiResources2.default);\n\nexports.default = Gapi;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// gapi-js.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap b6620d3db84ab5253ac5","export default class GapiResources {\n\n constructor() {\n this.resource = null;\n }\n\n get countries() { this.resource = 'countries'; return this; }\n set countries(value) { return this; }\n\n get places() { this.resource = 'places'; return this;}\n set places(value) { return this; }\n\n get suppliers() { this.resource = 'suppliers'; return this; }\n set suppliers(value) { return this; }\n\n get accommodation_costs() { this.resource = 'accommodation_costs'; return this; }\n set accommodation_costs(value) { return this; } \n\n get band_costs() { this.resource = 'band_costs'; return this; }\n set band_costs(value) { return this; } \n\n get fixed_costs() { this.resource = 'fixed_costs'; return this; }\n set fixed_costs(value) { return this; } \n\n get multishare_costs() { this.resource = 'multishare_costs'; return this; }\n set multishare_costs(value) { return this; } \n\n get per_person_costs() { this.resource = 'per_person_costs'; return this; }\n set per_person_costs(value) { return this; }\n\n get per_person_variable_costs() { this.resource = 'per_person_variable_costs'; return this; }\n set per_person_variable_costs(value) { return this; } \n\n get dossiers() { this.resource = 'dossiers'; return this; }\n set dossiers(value) { return this; }\n\n get country_dossiers() { this.resource = 'country_dossiers'; return this; }\n set country_dossiers(value) { return this; }\n\n get place_dossiers() { this.resource = 'place_dossiers'; return this;}\n set place_dossiers(value) { return this; }\n\n get transport_dossiers() { this.resource = 'transport_dossiers'; return this; }\n set transport_dossiers(value) { return this; }\n\n get transport_leg_dossiers() { this.resource = 'transport_leg_dossiers'; return this; }\n set transport_leg_dossiers(value) { return this; }\n\n get activity_dossiers() { this.resource = 'activity_dossiers'; return this; }\n set activity_dossiers(value) { return this; }\n\n get accommodation_dossiers() { this.resource = 'accommodation_dossiers'; return this; }\n set accommodation_dossiers(value) { return this; }\n\n get features() { this.resource = 'features'; return this; }\n set features(value) { return this; }\n\n get dossier_features() { this.resource = 'dossier_features'; return this; }\n set dossier_features(value) { return this; }\n\n get dossier_segments() { this.resource = 'dossier_segments'; return this; }\n set dossier_segments(value) { return this; }\n\n get tour_categories() { this.resource = 'tour_categories'; return this; }\n set tour_categories(value) { return this; }\n\n get reporting_offices() { this.resource = 'reporting_offices'; return this; }\n set reporting_offices(value) { return this; }\n\n get itineraries() { this.resource = 'itineraries'; return this; }\n set itineraries(value) { return this; }\n\n get images() { this.resource = 'images'; return this; }\n set images(value) { return this; }\n\n get videos() { this.resource = 'videos'; return this; }\n set videos(value) { return this; }\n\n \n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/gapi-resources.js","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"commonjs\":\"superagent\",\"commonjs2\":\"superagent\",\"amd\":\"superagent\",\"root\":\"_\"}\n// module id = 1\n// module chunks = 0","import request from 'superagent';\nimport GapiResources from './gapi-resources';\n\n\nexport default class Gapi extends GapiResources {\n\n constructor ({url='https://rest.gadventures.com', key, proxy}){\n super();\n\n if( !key ) {\n throw 'A gapi key is required when instantiating Gapi'\n }\n\n this.baseUrl = url;\n this.key = key;\n this.proxy = proxy;\n this.queryParams = {};\n this.dupableParams = [];\n }\n\n _setHeadersParams() {\n this.request.accept(this.proxy ? `application/json;${this.proxy}` : `application/json`);\n this.request.type('application/json');\n this.request.set('X-Application-Key', this.key);\n\n this.request.query(this.queryParams);\n this.dupableParams.forEach((paramPair) => {\n this.request.query(`${paramPair[0]}=${paramPair[1]}`);\n });\n return this;\n // this.request.set('X-Fastly-Bypass', 'pass'); // Temporary\n }\n\n _getUrl(...ids) {\n /**\n * Builds the full gapi request URL based on the resource provided\n * `this.resource` is set by `GapiResource` getter methods.\n **/\n if( ! this.resource ) {\n throw 'No resource has been provided.'; // TODO: Something more declarative.\n }\n const args = [this.baseUrl, this.resource, ...ids];\n return args.join('/') + '/';\n }\n\n get( ...ids ) {\n /**\n * Support for multiple resource Ids\n * For resources that accept more than one id. e.g. `itineraries/123/456/`\n **/\n const url = this._getUrl(...ids);\n this.request = request.get(url);\n return this;\n }\n\n list(number=1, size=20) {\n /**\n * By default will look for the first 20 items\n **/\n const url = this._getUrl();\n this.request = request.get(url);\n this.page(number, size);\n return this;\n }\n\n query(queryObj) {\n this.queryParams = Object.assign({}, this.queryParams, queryObj);\n return this;\n }\n\n page(number=1, size=20) {\n this.query({page: number, max_per_page: size});\n return this;\n }\n\n order(...fields) {\n fields.forEach((orderProp) => {\n let thisOrderProp = orderProp;\n const isDesc = orderProp.indexOf('-') === 0;\n if (isDesc){ thisOrderProp = orderProp.slice(1); }\n if (thisOrderProp.length === 0) { throw new Error('Order parameter property is an empty string'); }\n const queryParam = `order_by__${isDesc ? 'desc' : 'asc'}`;\n this.dupableParams.push([queryParam, thisOrderProp]);\n \n });\n return this;\n }\n\n post () {\n const url = this._getUrl();\n this.request = request.post(url);\n return this;\n }\n\n patch (ids) {\n const url = this._getUrl(ids);\n this.request = request.patch(url);\n return this;\n }\n\n del (ids) {\n const url = this._getUrl(ids);\n this.request = request.del(url);\n return this;\n }\n\n graphQL(query, variables){\n const url = [this.baseUrl, 'graphql'].join('/') + '/';\n this.request = request.post(url).send({query, variables});\n return this;\n }\n\n send ( args ) {\n this.request.send( args );\n return this;\n }\n\n end (callback) {\n this.request.query({'cache_bust': Date.now()});\n this._setHeadersParams().request.end(callback);\n return this;\n }\n\n then (resolve, reject) {\n this.request.query({'cache_bust': Date.now()});\n return this._setHeadersParams().request.then(resolve, reject);\n }\n\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/gapi-js.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///gapi-js.js","webpack:///webpack/bootstrap f5fb972248c3a1406665","webpack:///./src/gapi-resources.js","webpack:///external {\"commonjs\":\"superagent\",\"commonjs2\":\"superagent\",\"amd\":\"superagent\",\"root\":\"_\"}","webpack:///./src/gapi-js.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","length","descriptor","writable","key","protoProps","staticProps","GapiResources","resource","set","default","_interopRequireDefault","obj","_possibleConstructorReturn","self","ReferenceError","_inherits","subClass","superClass","create","constructor","setPrototypeOf","__proto__","GapiGenerator","undefined","_superagent","_superagent2","_gapiResources","_gapiResources2","ResourceClass","Gapi","_ResourceClass","_ref","_ref$url","url","proxy","_this","getPrototypeOf","baseUrl","queryParams","dupableParams","_this2","request","accept","type","query","forEach","paramPair","_len","arguments","ids","Array","_key","args","concat","join","_getUrl","apply","number","size","page","queryObj","assign","max_per_page","_this3","_len2","fields","_key2","orderProp","thisOrderProp","isDesc","indexOf","slice","Error","queryParam","push","post","patch","del","variables","send","callback","cache_bust","Date","now","_setHeadersParams","end","resolve","reject","then"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,eACA,kBAAAC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AAMtE,KAAK4F,QAAQN,EAEzB,OADAtF,MAAK8E,QAAUhB,EAAAhB,QAAQoE,IAAI5C,GACpBtE,QAzGmCwC,IAAA,UAAA7B,MAAA,SA4GnCsE,EAAOkC,GACd,GAAM7C,IAAOtE,KAAK0E,QAAS,WAAWiB,KAAK,KAAO,GAElD,OADA3F,MAAK8E,QAAUhB,EAAAhB,QAAQkE,KAAK1C,GAAK8C,MAAMnC,QAAOkC,cACvCnH,QA/GmCwC,IAAA,OAAA7B,MAAA,SAkHtC8E,GAEJ,MADAzF,MAAK8E,QAAQsC,KAAK3B,GACXzF,QApHmCwC,IAAA,MAAA7B,MAAA,SAuHvC0G,GAGH,MAFArH,MAAK8E,QAAQG,OAAOqC,WAAcC,KAAKC,QACvCxH,KAAKyH,oBAAoB3C,QAAQ4C,IAAIL,GAC9BrH,QA1HmCwC,IAAA,OAAA7B,MAAA,SA6HtCgH,EAASC,GAEb,MADA5H,MAAK8E,QAAQG,OAAOqC,WAAcC,KAAKC,QAChCxH,KAAKyH,oBAAoB3C,QAAQ+C,KAAKF,EAASC,OA/HZ1D,GAE3BD,EAiInB,OAAOC,GJ0TTvE,GAAQmD,QIvTOa","file":"gapi-js.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"superagent\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"superagent\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"gapi-js\"] = factory(require(\"superagent\"));\n\telse\n\t\troot[\"gapi-js\"] = factory(root[\"_\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"superagent\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"superagent\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"gapi-js\"] = factory(require(\"superagent\"));\n\telse\n\t\troot[\"gapi-js\"] = factory(root[\"_\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _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; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar GapiResources = function () {\n function GapiResources() {\n _classCallCheck(this, GapiResources);\n\n this.resource = null;\n }\n\n _createClass(GapiResources, [{\n key: 'countries',\n get: function get() {\n this.resource = 'countries';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'places',\n get: function get() {\n this.resource = 'places';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'dossiers',\n get: function get() {\n this.resource = 'dossiers';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'country_dossiers',\n get: function get() {\n this.resource = 'country_dossiers';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'place_dossiers',\n get: function get() {\n this.resource = 'place_dossiers';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'transport_dossiers',\n get: function get() {\n this.resource = 'transport_dossiers';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'transport_leg_dossiers',\n get: function get() {\n this.resource = 'transport_leg_dossiers';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'activity_dossiers',\n get: function get() {\n this.resource = 'activity_dossiers';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'accommodation_dossiers',\n get: function get() {\n this.resource = 'accommodation_dossiers';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'features',\n get: function get() {\n this.resource = 'features';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'dossier_features',\n get: function get() {\n this.resource = 'dossier_features';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'dossier_segments',\n get: function get() {\n this.resource = 'dossier_segments';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'tour_categories',\n get: function get() {\n this.resource = 'tour_categories';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'itineraries',\n get: function get() {\n this.resource = 'itineraries';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'images',\n get: function get() {\n this.resource = 'images';return this;\n },\n set: function set(value) {\n return this;\n }\n }, {\n key: 'videos',\n get: function get() {\n this.resource = 'videos';return this;\n },\n set: function set(value) {\n return this;\n }\n }]);\n\n return GapiResources;\n}();\n\nexports.default = GapiResources;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.GapiGenerator = undefined;\n\nvar _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; }; }();\n\nvar _superagent = __webpack_require__(1);\n\nvar _superagent2 = _interopRequireDefault(_superagent);\n\nvar _gapiResources = __webpack_require__(0);\n\nvar _gapiResources2 = _interopRequireDefault(_gapiResources);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar GapiGenerator = exports.GapiGenerator = function GapiGenerator(ResourceClass) {\n var Gapi = function (_ResourceClass) {\n _inherits(Gapi, _ResourceClass);\n\n function Gapi(_ref) {\n var _ref$url = _ref.url,\n url = _ref$url === undefined ? 'https://rest.gadventures.com' : _ref$url,\n key = _ref.key,\n proxy = _ref.proxy;\n\n _classCallCheck(this, Gapi);\n\n var _this = _possibleConstructorReturn(this, (Gapi.__proto__ || Object.getPrototypeOf(Gapi)).call(this));\n\n if (!key) {\n throw 'A gapi key is required when instantiating Gapi';\n }\n\n _this.baseUrl = url;\n _this.key = key;\n _this.proxy = proxy;\n _this.queryParams = {};\n _this.dupableParams = [];\n return _this;\n }\n\n _createClass(Gapi, [{\n key: '_setHeadersParams',\n value: function _setHeadersParams() {\n var _this2 = this;\n\n this.request.accept(this.proxy ? 'application/json;' + this.proxy : 'application/json');\n this.request.type('application/json');\n this.request.set('X-Application-Key', this.key);\n\n this.request.query(this.queryParams);\n this.dupableParams.forEach(function (paramPair) {\n _this2.request.query(paramPair[0] + '=' + paramPair[1]);\n });\n return this;\n // this.request.set('X-Fastly-Bypass', 'pass'); // Temporary\n }\n }, {\n key: '_getUrl',\n value: function _getUrl() {\n /**\n * Builds the full gapi request URL based on the resource provided\n * `this.resource` is set by `GapiResource` getter methods.\n **/\n if (!this.resource) {\n throw 'No resource has been provided.'; // TODO: Something more declarative.\n }\n\n for (var _len = arguments.length, ids = Array(_len), _key = 0; _key < _len; _key++) {\n ids[_key] = arguments[_key];\n }\n\n var args = [this.baseUrl, this.resource].concat(ids);\n return args.join('/') + '/';\n }\n }, {\n key: 'get',\n value: function get() {\n /**\n * Support for multiple resource Ids\n * For resources that accept more than one id. e.g. `itineraries/123/456/`\n **/\n var url = this._getUrl.apply(this, arguments);\n this.request = _superagent2.default.get(url);\n return this;\n }\n }, {\n key: 'list',\n value: function list() {\n var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;\n\n /**\n * By default will look for the first 20 items\n **/\n var url = this._getUrl();\n this.request = _superagent2.default.get(url);\n this.page(number, size);\n return this;\n }\n }, {\n key: 'query',\n value: function query(queryObj) {\n this.queryParams = Object.assign({}, this.queryParams, queryObj);\n return this;\n }\n }, {\n key: 'page',\n value: function page() {\n var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;\n\n this.query({ page: number, max_per_page: size });\n return this;\n }\n }, {\n key: 'order',\n value: function order() {\n var _this3 = this;\n\n for (var _len2 = arguments.length, fields = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n fields[_key2] = arguments[_key2];\n }\n\n fields.forEach(function (orderProp) {\n var thisOrderProp = orderProp;\n var isDesc = orderProp.indexOf('-') === 0;\n if (isDesc) {\n thisOrderProp = orderProp.slice(1);\n }\n if (thisOrderProp.length === 0) {\n throw new Error('Order parameter property is an empty string');\n }\n var queryParam = 'order_by__' + (isDesc ? 'desc' : 'asc');\n _this3.dupableParams.push([queryParam, thisOrderProp]);\n });\n return this;\n }\n }, {\n key: 'post',\n value: function post() {\n var url = this._getUrl();\n this.request = _superagent2.default.post(url);\n return this;\n }\n }, {\n key: 'patch',\n value: function patch(ids) {\n var url = this._getUrl(ids);\n this.request = _superagent2.default.patch(url);\n return this;\n }\n }, {\n key: 'del',\n value: function del(ids) {\n var url = this._getUrl(ids);\n this.request = _superagent2.default.del(url);\n return this;\n }\n }, {\n key: 'graphQL',\n value: function graphQL(query, variables) {\n var url = [this.baseUrl, 'graphql'].join('/') + '/';\n this.request = _superagent2.default.post(url).send({ query: query, variables: variables });\n return this;\n }\n }, {\n key: 'send',\n value: function send(args) {\n this.request.send(args);\n return this;\n }\n }, {\n key: 'end',\n value: function end(callback) {\n this.request.query({ 'cache_bust': Date.now() });\n this._setHeadersParams().request.end(callback);\n return this;\n }\n }, {\n key: 'then',\n value: function then(resolve, reject) {\n this.request.query({ 'cache_bust': Date.now() });\n return this._setHeadersParams().request.then(resolve, reject);\n }\n }]);\n\n return Gapi;\n }(ResourceClass);\n\n return Gapi;\n};\n\nexports.default = GapiGenerator(_gapiResources2.default);\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// gapi-js.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap f5fb972248c3a1406665","export default class GapiResources {\n\n constructor() {\n this.resource = null;\n }\n\n get countries() { this.resource = 'countries'; return this; }\n set countries(value) { return this; }\n\n get places() { this.resource = 'places'; return this;}\n set places(value) { return this; }\n\n get dossiers() { this.resource = 'dossiers'; return this; }\n set dossiers(value) { return this; }\n\n get country_dossiers() { this.resource = 'country_dossiers'; return this; }\n set country_dossiers(value) { return this; }\n\n get place_dossiers() { this.resource = 'place_dossiers'; return this;}\n set place_dossiers(value) { return this; }\n\n get transport_dossiers() { this.resource = 'transport_dossiers'; return this; }\n set transport_dossiers(value) { return this; }\n\n get transport_leg_dossiers() { this.resource = 'transport_leg_dossiers'; return this; }\n set transport_leg_dossiers(value) { return this; }\n\n get activity_dossiers() { this.resource = 'activity_dossiers'; return this; }\n set activity_dossiers(value) { return this; }\n\n get accommodation_dossiers() { this.resource = 'accommodation_dossiers'; return this; }\n set accommodation_dossiers(value) { return this; }\n\n get features() { this.resource = 'features'; return this; }\n set features(value) { return this; }\n\n get dossier_features() { this.resource = 'dossier_features'; return this; }\n set dossier_features(value) { return this; }\n\n get dossier_segments() { this.resource = 'dossier_segments'; return this; }\n set dossier_segments(value) { return this; }\n\n get tour_categories() { this.resource = 'tour_categories'; return this; }\n set tour_categories(value) { return this; }\n\n get itineraries() { this.resource = 'itineraries'; return this; }\n set itineraries(value) { return this; }\n\n get images() { this.resource = 'images'; return this; }\n set images(value) { return this; }\n\n get videos() { this.resource = 'videos'; return this; }\n set videos(value) { return this; }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/gapi-resources.js","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"commonjs\":\"superagent\",\"commonjs2\":\"superagent\",\"amd\":\"superagent\",\"root\":\"_\"}\n// module id = 1\n// module chunks = 0","import request from 'superagent';\nimport GapiResources from './gapi-resources';\n\n\nexport const GapiGenerator = (ResourceClass) => {\n\n class Gapi extends ResourceClass {\n\n constructor ({url = 'https://rest.gadventures.com', key, proxy}) {\n super();\n\n if (!key) {\n throw 'A gapi key is required when instantiating Gapi'\n }\n\n this.baseUrl = url;\n this.key = key;\n this.proxy = proxy;\n this.queryParams = {};\n this.dupableParams = [];\n }\n\n _setHeadersParams () {\n this.request.accept(this.proxy ? `application/json;${this.proxy}` : `application/json`);\n this.request.type('application/json');\n this.request.set('X-Application-Key', this.key);\n\n this.request.query(this.queryParams);\n this.dupableParams.forEach((paramPair) => {\n this.request.query(`${paramPair[0]}=${paramPair[1]}`);\n });\n return this;\n // this.request.set('X-Fastly-Bypass', 'pass'); // Temporary\n }\n\n _getUrl (...ids) {\n /**\n * Builds the full gapi request URL based on the resource provided\n * `this.resource` is set by `GapiResource` getter methods.\n **/\n if (!this.resource) {\n throw 'No resource has been provided.'; // TODO: Something more declarative.\n }\n const args = [this.baseUrl, this.resource, ...ids];\n return args.join('/') + '/';\n }\n\n get (...ids) {\n /**\n * Support for multiple resource Ids\n * For resources that accept more than one id. e.g. `itineraries/123/456/`\n **/\n const url = this._getUrl(...ids);\n this.request = request.get(url);\n return this;\n }\n\n list (number = 1, size = 20) {\n /**\n * By default will look for the first 20 items\n **/\n const url = this._getUrl();\n this.request = request.get(url);\n this.page(number, size);\n return this;\n }\n\n query (queryObj) {\n this.queryParams = Object.assign({}, this.queryParams, queryObj);\n return this;\n }\n\n page (number = 1, size = 20) {\n this.query({page: number, max_per_page: size});\n return this;\n }\n\n order (...fields) {\n fields.forEach((orderProp) => {\n let thisOrderProp = orderProp;\n const isDesc = orderProp.indexOf('-') === 0;\n if (isDesc) {\n thisOrderProp = orderProp.slice(1);\n }\n if (thisOrderProp.length === 0) {\n throw new Error('Order parameter property is an empty string');\n }\n const queryParam = `order_by__${isDesc ? 'desc' : 'asc'}`;\n this.dupableParams.push([queryParam, thisOrderProp]);\n\n });\n return this;\n }\n\n post () {\n const url = this._getUrl();\n this.request = request.post(url);\n return this;\n }\n\n patch (ids) {\n const url = this._getUrl(ids);\n this.request = request.patch(url);\n return this;\n }\n\n del (ids) {\n const url = this._getUrl(ids);\n this.request = request.del(url);\n return this;\n }\n\n graphQL (query, variables) {\n const url = [this.baseUrl, 'graphql'].join('/') + '/';\n this.request = request.post(url).send({query, variables});\n return this;\n }\n\n send (args) {\n this.request.send(args);\n return this;\n }\n\n end (callback) {\n this.request.query({'cache_bust': Date.now()});\n this._setHeadersParams().request.end(callback);\n return this;\n }\n\n then (resolve, reject) {\n this.request.query({'cache_bust': Date.now()});\n return this._setHeadersParams().request.then(resolve, reject);\n }\n }\n\n return Gapi;\n};\n\nexport default GapiGenerator(GapiResources);\n\n\n\n// WEBPACK FOOTER //\n// ./src/gapi-js.js"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index b63d452..b171d3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gapi-js", - "version": "3.4.0", + "version": "4.0.0", "description": "A js client for GAPI", "main": "build/gapi-js.js", "module": "src/gapi-js.js", diff --git a/src/gapi-js.js b/src/gapi-js.js index c27a01a..d15819d 100644 --- a/src/gapi-js.js +++ b/src/gapi-js.js @@ -2,128 +2,138 @@ import request from 'superagent'; import GapiResources from './gapi-resources'; -export default class Gapi extends GapiResources { +export const GapiGenerator = (ResourceClass) => { - constructor ({url='https://rest.gadventures.com', key, proxy}){ - super(); + class Gapi extends ResourceClass { - if( !key ) { - throw 'A gapi key is required when instantiating Gapi' + constructor ({url = 'https://rest.gadventures.com', key, proxy}) { + super(); + + if (!key) { + throw 'A gapi key is required when instantiating Gapi' + } + + this.baseUrl = url; + this.key = key; + this.proxy = proxy; + this.queryParams = {}; + this.dupableParams = []; } - this.baseUrl = url; - this.key = key; - this.proxy = proxy; - this.queryParams = {}; - this.dupableParams = []; - } + _setHeadersParams () { + this.request.accept(this.proxy ? `application/json;${this.proxy}` : `application/json`); + this.request.type('application/json'); + this.request.set('X-Application-Key', this.key); + + this.request.query(this.queryParams); + this.dupableParams.forEach((paramPair) => { + this.request.query(`${paramPair[0]}=${paramPair[1]}`); + }); + return this; + // this.request.set('X-Fastly-Bypass', 'pass'); // Temporary + } - _setHeadersParams() { - this.request.accept(this.proxy ? `application/json;${this.proxy}` : `application/json`); - this.request.type('application/json'); - this.request.set('X-Application-Key', this.key); - - this.request.query(this.queryParams); - this.dupableParams.forEach((paramPair) => { - this.request.query(`${paramPair[0]}=${paramPair[1]}`); - }); - return this; - // this.request.set('X-Fastly-Bypass', 'pass'); // Temporary - } + _getUrl (...ids) { + /** + * Builds the full gapi request URL based on the resource provided + * `this.resource` is set by `GapiResource` getter methods. + **/ + if (!this.resource) { + throw 'No resource has been provided.'; // TODO: Something more declarative. + } + const args = [this.baseUrl, this.resource, ...ids]; + return args.join('/') + '/'; + } - _getUrl(...ids) { - /** - * Builds the full gapi request URL based on the resource provided - * `this.resource` is set by `GapiResource` getter methods. - **/ - if( ! this.resource ) { - throw 'No resource has been provided.'; // TODO: Something more declarative. + get (...ids) { + /** + * Support for multiple resource Ids + * For resources that accept more than one id. e.g. `itineraries/123/456/` + **/ + const url = this._getUrl(...ids); + this.request = request.get(url); + return this; } - const args = [this.baseUrl, this.resource, ...ids]; - return args.join('/') + '/'; - } - get( ...ids ) { - /** - * Support for multiple resource Ids - * For resources that accept more than one id. e.g. `itineraries/123/456/` - **/ - const url = this._getUrl(...ids); - this.request = request.get(url); - return this; - } + list (number = 1, size = 20) { + /** + * By default will look for the first 20 items + **/ + const url = this._getUrl(); + this.request = request.get(url); + this.page(number, size); + return this; + } - list(number=1, size=20) { - /** - * By default will look for the first 20 items - **/ - const url = this._getUrl(); - this.request = request.get(url); - this.page(number, size); - return this; - } + query (queryObj) { + this.queryParams = Object.assign({}, this.queryParams, queryObj); + return this; + } - query(queryObj) { - this.queryParams = Object.assign({}, this.queryParams, queryObj); - return this; - } + page (number = 1, size = 20) { + this.query({page: number, max_per_page: size}); + return this; + } - page(number=1, size=20) { - this.query({page: number, max_per_page: size}); - return this; - } + order (...fields) { + fields.forEach((orderProp) => { + let thisOrderProp = orderProp; + const isDesc = orderProp.indexOf('-') === 0; + if (isDesc) { + thisOrderProp = orderProp.slice(1); + } + if (thisOrderProp.length === 0) { + throw new Error('Order parameter property is an empty string'); + } + const queryParam = `order_by__${isDesc ? 'desc' : 'asc'}`; + this.dupableParams.push([queryParam, thisOrderProp]); + + }); + return this; + } - order(...fields) { - fields.forEach((orderProp) => { - let thisOrderProp = orderProp; - const isDesc = orderProp.indexOf('-') === 0; - if (isDesc){ thisOrderProp = orderProp.slice(1); } - if (thisOrderProp.length === 0) { throw new Error('Order parameter property is an empty string'); } - const queryParam = `order_by__${isDesc ? 'desc' : 'asc'}`; - this.dupableParams.push([queryParam, thisOrderProp]); - - }); - return this; - } + post () { + const url = this._getUrl(); + this.request = request.post(url); + return this; + } - post () { - const url = this._getUrl(); - this.request = request.post(url); - return this; - } + patch (ids) { + const url = this._getUrl(ids); + this.request = request.patch(url); + return this; + } - patch (ids) { - const url = this._getUrl(ids); - this.request = request.patch(url); - return this; - } + del (ids) { + const url = this._getUrl(ids); + this.request = request.del(url); + return this; + } - del (ids) { - const url = this._getUrl(ids); - this.request = request.del(url); - return this; - } + graphQL (query, variables) { + const url = [this.baseUrl, 'graphql'].join('/') + '/'; + this.request = request.post(url).send({query, variables}); + return this; + } - graphQL(query, variables){ - const url = [this.baseUrl, 'graphql'].join('/') + '/'; - this.request = request.post(url).send({query, variables}); - return this; - } + send (args) { + this.request.send(args); + return this; + } - send ( args ) { - this.request.send( args ); - return this; - } + end (callback) { + this.request.query({'cache_bust': Date.now()}); + this._setHeadersParams().request.end(callback); + return this; + } - end (callback) { - this.request.query({'cache_bust': Date.now()}); - this._setHeadersParams().request.end(callback); - return this; + then (resolve, reject) { + this.request.query({'cache_bust': Date.now()}); + return this._setHeadersParams().request.then(resolve, reject); + } } - then (resolve, reject) { - this.request.query({'cache_bust': Date.now()}); - return this._setHeadersParams().request.then(resolve, reject); - } + return Gapi; +}; -} +export default GapiGenerator(GapiResources); diff --git a/src/gapi-resources.js b/src/gapi-resources.js index 543b3cb..fcf7033 100644 --- a/src/gapi-resources.js +++ b/src/gapi-resources.js @@ -10,27 +10,6 @@ export default class GapiResources { get places() { this.resource = 'places'; return this;} set places(value) { return this; } - get suppliers() { this.resource = 'suppliers'; return this; } - set suppliers(value) { return this; } - - get accommodation_costs() { this.resource = 'accommodation_costs'; return this; } - set accommodation_costs(value) { return this; } - - get band_costs() { this.resource = 'band_costs'; return this; } - set band_costs(value) { return this; } - - get fixed_costs() { this.resource = 'fixed_costs'; return this; } - set fixed_costs(value) { return this; } - - get multishare_costs() { this.resource = 'multishare_costs'; return this; } - set multishare_costs(value) { return this; } - - get per_person_costs() { this.resource = 'per_person_costs'; return this; } - set per_person_costs(value) { return this; } - - get per_person_variable_costs() { this.resource = 'per_person_variable_costs'; return this; } - set per_person_variable_costs(value) { return this; } - get dossiers() { this.resource = 'dossiers'; return this; } set dossiers(value) { return this; } @@ -64,9 +43,6 @@ export default class GapiResources { get tour_categories() { this.resource = 'tour_categories'; return this; } set tour_categories(value) { return this; } - get reporting_offices() { this.resource = 'reporting_offices'; return this; } - set reporting_offices(value) { return this; } - get itineraries() { this.resource = 'itineraries'; return this; } set itineraries(value) { return this; }