Skip to content

Commit b9e583d

Browse files
authored
fix: json representation for node (#777)
preview pr - twilio/twilio-node#1181
1 parent 090802c commit b9e583d

11 files changed

Lines changed: 117 additions & 157 deletions

File tree

examples/node/src/rest/api/v2010/account.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -675,34 +675,30 @@ export class AccountInstance {
675675
/**
676676
* Provide a user-friendly representation
677677
*
678-
* @returns String
678+
* @returns Object
679679
*/
680680
toJSON() {
681-
return JSON.stringify(
682-
{
683-
accountSid: this.accountSid,
684-
sid: this.sid,
685-
testString: this.testString,
686-
testInteger: this.testInteger,
687-
testObject: this.testObject,
688-
testDateTime: this.testDateTime,
689-
testNumber: this.testNumber,
690-
from: this.from,
691-
priceUnit: this.priceUnit,
692-
testNumberFloat: this.testNumberFloat,
693-
testNumberDecimal: this.testNumberDecimal,
694-
testEnum: this.testEnum,
695-
a2pProfileBundleSid: this.a2pProfileBundleSid,
696-
testArrayOfIntegers: this.testArrayOfIntegers,
697-
testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers,
698-
testArrayOfObjects: this.testArrayOfObjects,
699-
testArrayOfEnum: this.testArrayOfEnum,
700-
status: this.status,
701-
message: this.message,
702-
},
703-
null,
704-
2,
705-
);
681+
return {
682+
accountSid: this.accountSid,
683+
sid: this.sid,
684+
testString: this.testString,
685+
testInteger: this.testInteger,
686+
testObject: this.testObject,
687+
testDateTime: this.testDateTime,
688+
testNumber: this.testNumber,
689+
from: this.from,
690+
priceUnit: this.priceUnit,
691+
testNumberFloat: this.testNumberFloat,
692+
testNumberDecimal: this.testNumberDecimal,
693+
testEnum: this.testEnum,
694+
a2pProfileBundleSid: this.a2pProfileBundleSid,
695+
testArrayOfIntegers: this.testArrayOfIntegers,
696+
testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers,
697+
testArrayOfObjects: this.testArrayOfObjects,
698+
testArrayOfEnum: this.testArrayOfEnum,
699+
status: this.status,
700+
message: this.message,
701+
};
706702
}
707703

708704
[inspect.custom](_depth: any, options: InspectOptions) {

examples/node/src/rest/api/v2010/account/call.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -418,34 +418,30 @@ export class CallInstance {
418418
/**
419419
* Provide a user-friendly representation
420420
*
421-
* @returns String
421+
* @returns Object
422422
*/
423423
toJSON() {
424-
return JSON.stringify(
425-
{
426-
accountSid: this.accountSid,
427-
sid: this.sid,
428-
testString: this.testString,
429-
testInteger: this.testInteger,
430-
testObject: this.testObject,
431-
testDateTime: this.testDateTime,
432-
testNumber: this.testNumber,
433-
from: this.from,
434-
priceUnit: this.priceUnit,
435-
testNumberFloat: this.testNumberFloat,
436-
testNumberDecimal: this.testNumberDecimal,
437-
testEnum: this.testEnum,
438-
a2pProfileBundleSid: this.a2pProfileBundleSid,
439-
testArrayOfIntegers: this.testArrayOfIntegers,
440-
testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers,
441-
testArrayOfObjects: this.testArrayOfObjects,
442-
testArrayOfEnum: this.testArrayOfEnum,
443-
status: this.status,
444-
message: this.message,
445-
},
446-
null,
447-
2,
448-
);
424+
return {
425+
accountSid: this.accountSid,
426+
sid: this.sid,
427+
testString: this.testString,
428+
testInteger: this.testInteger,
429+
testObject: this.testObject,
430+
testDateTime: this.testDateTime,
431+
testNumber: this.testNumber,
432+
from: this.from,
433+
priceUnit: this.priceUnit,
434+
testNumberFloat: this.testNumberFloat,
435+
testNumberDecimal: this.testNumberDecimal,
436+
testEnum: this.testEnum,
437+
a2pProfileBundleSid: this.a2pProfileBundleSid,
438+
testArrayOfIntegers: this.testArrayOfIntegers,
439+
testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers,
440+
testArrayOfObjects: this.testArrayOfObjects,
441+
testArrayOfEnum: this.testArrayOfEnum,
442+
status: this.status,
443+
message: this.message,
444+
};
449445
}
450446

451447
[inspect.custom](_depth: any, options: InspectOptions) {

examples/node/src/rest/api/v2010/account/call/feedbackCallSummary.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -398,34 +398,30 @@ export class FeedbackCallSummaryInstance {
398398
/**
399399
* Provide a user-friendly representation
400400
*
401-
* @returns String
401+
* @returns Object
402402
*/
403403
toJSON() {
404-
return JSON.stringify(
405-
{
406-
accountSid: this.accountSid,
407-
sid: this.sid,
408-
testString: this.testString,
409-
testInteger: this.testInteger,
410-
testObject: this.testObject,
411-
testDateTime: this.testDateTime,
412-
testNumber: this.testNumber,
413-
from: this.from,
414-
priceUnit: this.priceUnit,
415-
testNumberFloat: this.testNumberFloat,
416-
testNumberDecimal: this.testNumberDecimal,
417-
testEnum: this.testEnum,
418-
a2pProfileBundleSid: this.a2pProfileBundleSid,
419-
testArrayOfIntegers: this.testArrayOfIntegers,
420-
testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers,
421-
testArrayOfObjects: this.testArrayOfObjects,
422-
testArrayOfEnum: this.testArrayOfEnum,
423-
status: this.status,
424-
message: this.message,
425-
},
426-
null,
427-
2,
428-
);
404+
return {
405+
accountSid: this.accountSid,
406+
sid: this.sid,
407+
testString: this.testString,
408+
testInteger: this.testInteger,
409+
testObject: this.testObject,
410+
testDateTime: this.testDateTime,
411+
testNumber: this.testNumber,
412+
from: this.from,
413+
priceUnit: this.priceUnit,
414+
testNumberFloat: this.testNumberFloat,
415+
testNumberDecimal: this.testNumberDecimal,
416+
testEnum: this.testEnum,
417+
a2pProfileBundleSid: this.a2pProfileBundleSid,
418+
testArrayOfIntegers: this.testArrayOfIntegers,
419+
testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers,
420+
testArrayOfObjects: this.testArrayOfObjects,
421+
testArrayOfEnum: this.testArrayOfEnum,
422+
status: this.status,
423+
message: this.message,
424+
};
429425
}
430426

431427
[inspect.custom](_depth: any, options: InspectOptions) {

examples/node/src/rest/flexApi/v1/call.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,12 @@ export class CallInstance {
202202
/**
203203
* Provide a user-friendly representation
204204
*
205-
* @returns String
205+
* @returns Object
206206
*/
207207
toJSON() {
208-
return JSON.stringify(
209-
{
210-
sid: this.sid,
211-
},
212-
null,
213-
2,
214-
);
208+
return {
209+
sid: this.sid,
210+
};
215211
}
216212

217213
[inspect.custom](_depth: any, options: InspectOptions) {

examples/node/src/rest/flexApi/v1/credential/aws.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -785,19 +785,15 @@ export class AwsInstance {
785785
/**
786786
* Provide a user-friendly representation
787787
*
788-
* @returns String
788+
* @returns Object
789789
*/
790790
toJSON() {
791-
return JSON.stringify(
792-
{
793-
accountSid: this.accountSid,
794-
sid: this.sid,
795-
testString: this.testString,
796-
testInteger: this.testInteger,
797-
},
798-
null,
799-
2,
800-
);
791+
return {
792+
accountSid: this.accountSid,
793+
sid: this.sid,
794+
testString: this.testString,
795+
testInteger: this.testInteger,
796+
};
801797
}
802798

803799
[inspect.custom](_depth: any, options: InspectOptions) {

examples/node/src/rest/flexApi/v1/credential/aws/history.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,19 +331,15 @@ export class HistoryInstance {
331331
/**
332332
* Provide a user-friendly representation
333333
*
334-
* @returns String
334+
* @returns Object
335335
*/
336336
toJSON() {
337-
return JSON.stringify(
338-
{
339-
accountSid: this.accountSid,
340-
sid: this.sid,
341-
testString: this.testString,
342-
testInteger: this.testInteger,
343-
},
344-
null,
345-
2,
346-
);
337+
return {
338+
accountSid: this.accountSid,
339+
sid: this.sid,
340+
testString: this.testString,
341+
testInteger: this.testInteger,
342+
};
347343
}
348344

349345
[inspect.custom](_depth: any, options: InspectOptions) {

examples/node/src/rest/flexApi/v1/credential/newCredentials.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,19 +324,15 @@ export class NewCredentialsInstance {
324324
/**
325325
* Provide a user-friendly representation
326326
*
327-
* @returns String
327+
* @returns Object
328328
*/
329329
toJSON() {
330-
return JSON.stringify(
331-
{
332-
accountSid: this.accountSid,
333-
sid: this.sid,
334-
testString: this.testString,
335-
testInteger: this.testInteger,
336-
},
337-
null,
338-
2,
339-
);
330+
return {
331+
accountSid: this.accountSid,
332+
sid: this.sid,
333+
testString: this.testString,
334+
testInteger: this.testInteger,
335+
};
340336
}
341337

342338
[inspect.custom](_depth: any, options: InspectOptions) {

examples/node/src/rest/oauth/v2/token.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,20 +273,16 @@ export class TokenInstance {
273273
/**
274274
* Provide a user-friendly representation
275275
*
276-
* @returns String
276+
* @returns Object
277277
*/
278278
toJSON() {
279-
return JSON.stringify(
280-
{
281-
accessToken: this.accessToken,
282-
refreshToken: this.refreshToken,
283-
idToken: this.idToken,
284-
tokenType: this.tokenType,
285-
expiresIn: this.expiresIn,
286-
},
287-
null,
288-
2,
289-
);
279+
return {
280+
accessToken: this.accessToken,
281+
refreshToken: this.refreshToken,
282+
idToken: this.idToken,
283+
tokenType: this.tokenType,
284+
expiresIn: this.expiresIn,
285+
};
290286
}
291287

292288
[inspect.custom](_depth: any, options: InspectOptions) {

examples/node/src/rest/versionless/deployed_devices/fleet.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -257,22 +257,18 @@ export class FleetInstance {
257257
/**
258258
* Provide a user-friendly representation
259259
*
260-
* @returns String
260+
* @returns Object
261261
*/
262262
toJSON() {
263-
return JSON.stringify(
264-
{
265-
name: this.name,
266-
testIntMap: this.testIntMap,
267-
testNestedObject: this.testNestedObject,
268-
testNestedArray: this.testNestedArray,
269-
testNestedArrayOfObjects: this.testNestedArrayOfObjects,
270-
sid: this.sid,
271-
friendlyName: this.friendlyName,
272-
},
273-
null,
274-
2,
275-
);
263+
return {
264+
name: this.name,
265+
testIntMap: this.testIntMap,
266+
testNestedObject: this.testNestedObject,
267+
testNestedArray: this.testNestedArray,
268+
testNestedArrayOfObjects: this.testNestedArrayOfObjects,
269+
sid: this.sid,
270+
friendlyName: this.friendlyName,
271+
};
276272
}
277273

278274
[inspect.custom](_depth: any, options: InspectOptions) {

examples/node/src/rest/versionless/understand/assistant.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,17 +408,13 @@ export class AssistantInstance {
408408
/**
409409
* Provide a user-friendly representation
410410
*
411-
* @returns String
411+
* @returns Object
412412
*/
413413
toJSON() {
414-
return JSON.stringify(
415-
{
416-
sid: this.sid,
417-
friendlyName: this.friendlyName,
418-
},
419-
null,
420-
2,
421-
);
414+
return {
415+
sid: this.sid,
416+
friendlyName: this.friendlyName,
417+
};
422418
}
423419

424420
[inspect.custom](_depth: any, options: InspectOptions) {

0 commit comments

Comments
 (0)