rest-client-sdk
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -6,2 +6,6 @@ # Changelog | ||
## [1.1.1] - 2017-10-08 | ||
### Changed | ||
* upgrade rollup to 0.50.0 | ||
## [1.1.0] - 2017-08-30 | ||
@@ -8,0 +12,0 @@ ### Changed |
{ | ||
"name": "rest-client-sdk", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Rest Client SDK for API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -68,12 +68,12 @@ /** | ||
case response.status === 403: | ||
throw new ForbiddenError(response); | ||
throw new ForbiddenError(null, response); | ||
case response.status === 404: | ||
throw new ResourceNotFoundError(response); | ||
throw new ResourceNotFoundError(null, response); | ||
case response.status >= 400 && response.status < 500: | ||
throw new BadRequestError(response); | ||
throw new BadRequestError(null, response); | ||
case response.status >= 500 && response.status < 600: | ||
throw new InternalServerError(response); | ||
throw new InternalServerError(null, response); | ||
@@ -80,0 +80,0 @@ default: |
@@ -26,2 +26,6 @@ /* global fetch */ | ||
if (this.tokenGeneratorConfig.scope && !parameters.scope) { | ||
parameters.scope = this.tokenGeneratorConfig.scope; | ||
} | ||
const uri = new URI(this.tokenGeneratorConfig.path).scheme( | ||
@@ -28,0 +32,0 @@ this.tokenGeneratorConfig.scheme |
@@ -6,3 +6,3 @@ /* global fetch */ | ||
import { memoizePromise } from '../decorator'; | ||
import { handleBadResponse } from '../Error'; | ||
import { AccessDeniedError, handleBadResponse, HttpError } from '../Error'; | ||
@@ -33,3 +33,7 @@ const ERROR_CONFIG_EMPTY = 'TokenGenerator config must be set'; | ||
return this._doFetch(parameters); | ||
if (this.tokenGeneratorConfig.scope && !parameters.scope) { | ||
parameters.scope = this.tokenGeneratorConfig.scope; | ||
} | ||
return this._doFetch(parameters).then(response => response.json()); | ||
} | ||
@@ -49,6 +53,16 @@ | ||
parameters.client_secret = this.tokenGeneratorConfig.clientSecret; | ||
if (this.tokenGeneratorConfig.scope && !parameters.scope) { | ||
parameters.scope = this.tokenGeneratorConfig.scope; | ||
} | ||
parameters.refresh_token = accessToken.refresh_token; | ||
return this._doFetch(parameters); | ||
return this._doFetch(parameters) | ||
.then(response => response.json()) | ||
.catch(err => { | ||
if (err instanceof HttpError) { | ||
throw new AccessDeniedError(null, err.baseResponse); | ||
} | ||
throw err; | ||
}); | ||
} | ||
@@ -84,7 +98,7 @@ | ||
}).then(response => { | ||
if (response.status !== 200) { | ||
return handleBadResponse(response); | ||
if (response.status >= 400) { | ||
handleBadResponse(response); | ||
} | ||
return response.json(); | ||
return response; | ||
}); | ||
@@ -91,0 +105,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
742965
8217