UNPKG

1.11 kBJavaScriptView Raw
1/**
2 * @file Defines the ReadOneEndpoint 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 BaseEndpoint = require( "./BaseEndpoint" );
14
15/**
16 * The parent class for all READ ('GET') endpoints that return one record based
17 * on a single ID value.
18 *
19 * @memberOf Endpoint
20 * @extends Endpoint.BaseEndpoint
21 */
22class ReadOneEndpoint extends BaseEndpoint {
23
24 /**
25 * @param {Object} cfg - Basic endpoint settings.
26 * @param {Object} [overrides] - A configuration object that allows certain,
27 * default, behaviors to be overridden. This parameter is primarily
28 * used by testing interfaces.
29 */
30 constructor( cfg, overrides ) {
31
32 // Apply Overrides
33 cfg = Object.assign( {}, cfg, overrides );
34
35 // Set Endpoint Type
36 cfg.endpointType = "readOne";
37
38 // Define the default response class
39 cfg.defaultSuccessResponse = "ReadOneResponse";
40
41 // Call Parent
42 super( cfg );
43 }
44}
45
46module.exports = ReadOneEndpoint;