clubhouse-lib
Advanced tools
Comparing version 0.1.7 to 0.2.0
@@ -5,6 +5,14 @@ 'use strict'; | ||
var _client_error = require('./client_error'); | ||
var _TokenRequestFactory = require('./TokenRequestFactory'); | ||
var _client_error2 = _interopRequireDefault(_client_error); | ||
var _TokenRequestFactory2 = _interopRequireDefault(_TokenRequestFactory); | ||
var _FetchRequestPerformer = require('./FetchRequestPerformer'); | ||
var _FetchRequestPerformer2 = _interopRequireDefault(_FetchRequestPerformer); | ||
var _FetchRequestParser = require('./FetchRequestParser'); | ||
var _FetchRequestParser2 = _interopRequireDefault(_FetchRequestParser); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -14,47 +22,5 @@ | ||
require('es6-promise').polyfill(); | ||
require('fetch-everywhere'); | ||
var API_BASE_URL = 'https://api.clubhouse.io'; | ||
var API_VERSION = 'beta'; | ||
var parseResponse = function parseResponse(response) { | ||
return response.json().then(function (json) { | ||
if (response.ok) { | ||
return json; | ||
} | ||
return Promise.reject(new _client_error2.default(response, json)); | ||
}); | ||
}; | ||
var TokenRequestFactory = function () { | ||
function TokenRequestFactory(token) { | ||
_classCallCheck(this, TokenRequestFactory); | ||
this.token = token; | ||
} | ||
_createClass(TokenRequestFactory, [{ | ||
key: 'makeRequest', | ||
value: function makeRequest(url) { | ||
var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GET'; | ||
var body = arguments[2]; | ||
var urlWithToken = url + '?token=' + this.token; | ||
var headers = { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json; charset=utf-8' | ||
}; | ||
return fetch(urlWithToken, { | ||
body: JSON.stringify(body), | ||
headers: headers, | ||
method: method | ||
}); | ||
} | ||
}]); | ||
return TokenRequestFactory; | ||
}(); | ||
/** */ | ||
@@ -79,2 +45,4 @@ | ||
var requestFactory = arguments[1]; | ||
var requestPerformer = arguments[2]; | ||
var responseParser = arguments[3]; | ||
@@ -86,2 +54,4 @@ _classCallCheck(this, Client); | ||
this.requestFactory = requestFactory; | ||
this.requestPerformer = requestPerformer; | ||
this.responseParser = responseParser; | ||
} | ||
@@ -100,3 +70,4 @@ /** */ | ||
var URL = this.generateUrl(uri); | ||
return this.requestFactory.makeRequest(URL).then(parseResponse); | ||
var request = this.requestFactory.createRequest(URL); | ||
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse); | ||
} | ||
@@ -107,3 +78,4 @@ }, { | ||
var URL = this.generateUrl(uri); | ||
return this.requestFactory.makeRequest(URL).then(parseResponse); | ||
var request = this.requestFactory.createRequest(URL); | ||
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse); | ||
} | ||
@@ -114,3 +86,4 @@ }, { | ||
var URL = this.generateUrl(uri); | ||
return this.requestFactory.makeRequest(URL, 'POST', params).then(parseResponse); | ||
var request = this.requestFactory.createRequest(URL, 'POST', params); | ||
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse); | ||
} | ||
@@ -121,3 +94,4 @@ }, { | ||
var URL = this.generateUrl(uri); | ||
return this.requestFactory.makeRequest(URL, 'PUT', params).then(parseResponse); | ||
var request = this.requestFactory.createRequest(URL, 'PUT', params); | ||
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse); | ||
} | ||
@@ -127,4 +101,5 @@ }, { | ||
value: function deleteResource(uri) { | ||
var URI = this.generateUrl(uri); | ||
return this.requestFactory.makeRequest(URI, 'DELETE').then(parseResponse); | ||
var URL = this.generateUrl(uri); | ||
var request = this.requestFactory.createRequest(URL, 'DELETE'); | ||
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse); | ||
} | ||
@@ -414,3 +389,3 @@ | ||
value: function create(token, options) { | ||
return new Client(options || defaultConfig, new TokenRequestFactory(token)); | ||
return new Client(options || defaultConfig, new _TokenRequestFactory2.default(token), new _FetchRequestPerformer2.default(), new _FetchRequestParser2.default()); | ||
} | ||
@@ -417,0 +392,0 @@ }]); |
{ | ||
"name": "clubhouse-lib", | ||
"version": "0.1.7", | ||
"version": "0.2.0", | ||
"description": "A Promise based library to the Clubhouse REST API", | ||
@@ -21,4 +21,4 @@ "files": [ | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1", | ||
"babel-eslint": "^7.2.3", | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^8.0.1", | ||
"babel-plugin-transform-flow-strip-types": "^6.22.0", | ||
@@ -33,15 +33,15 @@ "babel-preset-env": "^1.6.0", | ||
"bluebird": "^3.5.0", | ||
"eslint": "^3.19.0", | ||
"eslint-config-airbnb": "^15.0.2", | ||
"eslint-config-prettier": "^2.3.0", | ||
"eslint-plugin-flowtype": "^2.35.0", | ||
"eslint": "^4.7.2", | ||
"eslint-config-airbnb": "^15.1.0", | ||
"eslint-config-prettier": "^2.6.0", | ||
"eslint-plugin-flowtype": "^2.36.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-jest": "^20.0.3", | ||
"eslint-plugin-jest": "^21.2.0", | ||
"eslint-plugin-jsx-a11y": "^5.1.1", | ||
"eslint-plugin-prettier": "^2.1.2", | ||
"eslint-plugin-react": "^7.1.0", | ||
"flow-bin": "^0.49.1", | ||
"flow-copy-source": "^1.2.0", | ||
"jest": "^20.0.4", | ||
"prettier": "^1.5.2", | ||
"eslint-plugin-prettier": "^2.3.1", | ||
"eslint-plugin-react": "^7.4.0", | ||
"flow-bin": "^0.55.0", | ||
"flow-copy-source": "^1.2.1", | ||
"jest": "^21.2.0", | ||
"prettier": "^1.7.1", | ||
"save": "^2.3.1" | ||
@@ -53,9 +53,9 @@ }, | ||
"<rootDir>/build/", | ||
"<rootDir>/node_modules/" | ||
"<rootDir>/node_modules/", | ||
"(<rootDir>/__tests__/.*|(\\.|/)utils)\\.jsx?$" | ||
] | ||
}, | ||
"dependencies": { | ||
"es6-promise": "^4.1.1", | ||
"fetch-everywhere": "^1.0.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30803
1
14
374
- Removedes6-promise@^4.1.1
- Removedes6-promise@4.2.8(transitive)