- /**
- * Valid response statuses.
- * Allow 401 as a workaround for one specific client which return such on
- * its client identifier endpoint when not yet authenticated.
- * @param {Number} status
- * @returns {Boolean}
- */
- static _validateStatus(status) {
- return (status >= 200 && status < 300) || status == 401;
- }
-
-
- /**
- * A request config skeleton.
- * @param {String} method
- * @param {URL} urlObj
- * @param {String=} body
- * @param {Object=} params
- * @param {Object=} headers
- * @returns {Object}
- */
- static _axiosConfig(method, urlObj, body, params = {}, headers = {}) {
- const config = {
- method,
- url: `${urlObj.origin}${urlObj.pathname}`,
- params: urlObj.searchParams,
- headers,
- ...(body && { data: body }),
- // Setting this does not appear to be enough to keep axios from parsing JSON response into object
- responseType: 'text',
- // So force the matter by eliding all response transformations
- transformResponse: [ (res) => res ],
-
- validateStatus: Communication._validateStatus,
- };
- Object.entries(params).map(([k, v]) => config.params.set(k, v));
- return config;
- }
-
-