UNPKG

1.73 kBJavaScriptView Raw
1/*!
2 * Copyright 2016 Amazon.com,
3 * Inc. or its affiliates. All Rights Reserved.
4 *
5 * Licensed under the Amazon Software License (the "License").
6 * You may not use this file except in compliance with the
7 * License. A copy of the License is located at
8 *
9 * http://aws.amazon.com/asl/
10 *
11 * or in the "license" file accompanying this file. This file is
12 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13 * CONDITIONS OF ANY KIND, express or implied. See the License
14 * for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/** @class */
19export default class CognitoUserAttribute {
20 /**
21 * Constructs a new CognitoUserAttribute object
22 * @param {string=} Name The record's name
23 * @param {string=} Value The record's value
24 */
25 constructor({ Name, Value } = {}) {
26 this.Name = Name || '';
27 this.Value = Value || '';
28 }
29
30 /**
31 * @returns {string} the record's value.
32 */
33 getValue() {
34 return this.Value;
35 }
36
37 /**
38 * Sets the record's value.
39 * @param {string} value The new value.
40 * @returns {CognitoUserAttribute} The record for method chaining.
41 */
42 setValue(value) {
43 this.Value = value;
44 return this;
45 }
46
47 /**
48 * @returns {string} the record's name.
49 */
50 getName() {
51 return this.Name;
52 }
53
54 /**
55 * Sets the record's name
56 * @param {string} name The new name.
57 * @returns {CognitoUserAttribute} The record for method chaining.
58 */
59 setName(name) {
60 this.Name = name;
61 return this;
62 }
63
64 /**
65 * @returns {string} a string representation of the record.
66 */
67 toString() {
68 return JSON.stringify(this);
69 }
70
71 /**
72 * @returns {object} a flat object representing the record.
73 */
74 toJSON() {
75 return {
76 Name: this.Name,
77 Value: this.Value,
78 };
79 }
80}