This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api-response): add api client response
- Loading branch information
1 parent
805be5a
commit 893471b
Showing
10 changed files
with
498 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict' | ||
|
||
/* | ||
* adonis-vow | ||
* | ||
* (c) Harminder Virk <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
module.exports = function (BaseResponse) { | ||
/** | ||
* Api response class is used ot read the http | ||
* response values and run assertions on | ||
* them | ||
* | ||
* @class ApiResponse | ||
* @constructor | ||
*/ | ||
class ApiResponse extends BaseResponse { | ||
constructor (res, assert) { | ||
super(assert, res.headers) | ||
this._res = res | ||
} | ||
|
||
/** | ||
* Response status | ||
* | ||
* @attribute status | ||
* | ||
* @return {Number} | ||
*/ | ||
get status () { | ||
return this._res.status | ||
} | ||
|
||
/** | ||
* Response text | ||
* | ||
* @attribute text | ||
* | ||
* @return {String} | ||
*/ | ||
get text () { | ||
return this._res.text | ||
} | ||
|
||
/** | ||
* Response body | ||
* | ||
* @attribute body | ||
* | ||
* @return {Mixed} | ||
*/ | ||
get body () { | ||
return this._res.body | ||
} | ||
|
||
/** | ||
* An array of request redirects | ||
* | ||
* @method redirects | ||
* | ||
* @return {Array} | ||
*/ | ||
get redirects () { | ||
return this._res.redirects | ||
} | ||
} | ||
return ApiResponse | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.