UNPKG

986 BJavaScriptView Raw
1/**
2 * @file Defines the UpdateOneResponse class.
3 *
4 * @author Luke Chavers <luke@c2cschools.com>
5 * @author Kevin Sanders <kevin@c2cschools.com>
6 * @since 5.0.0
7 * @license See LICENSE.md for details about licensing.
8 * @copyright 2017 C2C Schools, LLC
9 */
10
11"use strict";
12
13const SuccessResponse = require( "./SuccessResponse" );
14
15/**
16 * This response class represents an API response for a 'UpdateOne' endpoint.
17 *
18 * @memberOf Response
19 * @extends Response.SuccessResponse
20 */
21module.exports = class UpdateOneResponse extends SuccessResponse {
22
23 /**
24 * Creates a JSON-API compatible scaffold for the response body [object].
25 *
26 * This method extends the `BaseResponse` scaffold by adding the data.
27 *
28 * @private
29 * @returns {Object} Response body.
30 */
31 _createResponseBody() {
32
33 const me = this;
34
35 let sBody = super._createResponseBody();
36
37 if ( me.data ) {
38
39 sBody.data = me.data._serializeToJsonApiObject();
40
41 } else {
42
43 sBody.data = {};
44 }
45
46 return sBody;
47 }
48};