Skip to content

Commit 2a25ad3

Browse files
committedJan 16, 2023
update name/value to key/value for Metadata
·
1.4.41.4.0
1 parent e3ccd2e commit 2a25ad3

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed
 

‎examples/basic/basicSendComplexExample.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ message.tags.push("has-attachments:true");
149149

150150
// Add Tags using the addCustomHeaders function
151151
message.addTag("I am a test message");
152+
message.addTag("nodejs-Example");
152153

153154

154155
/**

‎examples/bulk/bulkSendComplexExample.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ message.tags.push("has-attachments:true");
189189

190190
// Add Tags using the addCustomHeaders function
191191
message.addTag("I am a test message");
192+
message.addTag("nodejs-Example");
192193

193194
/**
194195
* Create the client

‎src/helpers/toMetadata.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class ToMetadata {
2121
}
2222
else if (typeof value === 'object') {
2323
var n, v;
24-
if ('name' in value) {
25-
n = value.name;
24+
if ('key' in value) {
25+
n = value.key;
2626
}
2727
if ('value' in value) {
2828
v = value.value;

‎src/message/metadata.js‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
'use strict';
22

33
/**
4-
* Represents Metadata as a name and value pair.
4+
* Represents Metadata as a key and value pair.
55
* @example
66
* var metadata = require('./metadata');
77
* ...
88
*
9-
* var header1 = new metadata("name1", "value1");
9+
* var metadata1 = new metadata("key1", "value1");
1010
*/
1111
class Metadata {
1212

1313
/**
1414
* Creates a new instance of the Metadata class.
1515
* @constructor
16-
* @param {string} name, The name of your custom header.
16+
* @param {string} key, The key of your custom header.
1717
* @param {string} value, The value of your custom header.
1818
* @example
19-
* var header1 = Metadata("name1", "value1");
19+
* var metadata1 = Metadata("key1", "value1");
2020
*
2121
*/
22-
constructor(name, value) {
23-
this.setName(name);
22+
constructor(key, value) {
23+
this.setKey(key);
2424
this.setValue(value);
2525
}
2626

2727
/**
28-
* Sets the Metadata Name.
28+
* Sets the Metadata Key.
2929
* @param {string} value
3030
*/
31-
setName(value) {
31+
setKey(value) {
3232
if (typeof value === 'undefined' || !value) {
3333
return;
3434
}
3535
if (typeof value !== 'string') {
36-
throw new Error("Invalid custom header name, type of 'string' was expected.");
36+
throw new Error("Invalid metadata, type of 'string' was expected.");
3737
}
3838
/**
39-
* The Metadata Name.
39+
* The Metadata Key.
4040
*/
41-
this.name = value;
41+
this.key = value;
4242
}
4343

4444
/**
@@ -62,23 +62,23 @@ class Metadata {
6262
* A quick check to ensure that the Metadata is valid.
6363
*/
6464
isValid() {
65-
if ((!this.name && this.name !== "") && (!this.value && this.value !== ""))
65+
if ((!this.key && this.key !== "") && (!this.value && this.value !== ""))
6666
return false;
6767
return true;
6868
}
6969
/**
7070
* String representation of the Metadata class.
7171
*/
7272
toString() {
73-
return `${this.name}, ${this.value}`;
73+
return `${this.key}, ${this.value}`;
7474
}
7575
/**
7676
* JSON string representation of the Metadata class.
7777
*/
7878
toJSON() {
7979

8080
return {
81-
name: this.name,
81+
key: this.key,
8282
value: this.value
8383
};
8484

0 commit comments

Comments
 (0)
Please sign in to comment.