MCPcopy Index your code
hub / github.com/OneSignal/onesignal-node-api / deserialize

Method deserialize

models/ObjectSerializer.ts:339–376  ·  view source on GitHub ↗
(data: any, type: string, format: string)

Source from the content-addressed store, hash-verified

337 }
338
339 public static deserialize(data: any, type: string, format: string) {
340 // polymorphism may change the actual type.
341 type = ObjectSerializer.findCorrectType(data, type);
342 if (data == undefined) {
343 return data;
344 } else if (primitives.indexOf(type.toLowerCase()) !== -1) {
345 return data;
346 } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
347 let subType: string = type.replace("Array<", ""); // Array<Type> => Type>
348 subType = subType.substring(0, subType.length - 1); // Type> => Type
349 let transformedData: any[] = [];
350 for (let index in data) {
351 let date = data[index];
352 transformedData.push(ObjectSerializer.deserialize(date, subType, format));
353 }
354 return transformedData;
355 } else if (type === "Date") {
356 return new Date(data);
357 } else {
358 if (enumsMap.has(type)) {// is Enum
359 return data;
360 }
361
362 if (!typeMap[type]) { // dont know the type
363 return data;
364 }
365 let instance = new typeMap[type]();
366 let attributeTypes = typeMap[type].getAttributeTypeMap();
367 for (let index in attributeTypes) {
368 let attributeType = attributeTypes[index];
369 let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format);
370 if (value !== undefined) {
371 instance[attributeType.name] = value;
372 }
373 }
374 return instance;
375 }
376 }
377
378
379 /**

Callers 15

cancelNotificationMethod · 0.80
copyTemplateToAppMethod · 0.80
createAliasMethod · 0.80
createApiKeyMethod · 0.80
createAppMethod · 0.80
createCustomEventsMethod · 0.80
createNotificationMethod · 0.80
createSegmentMethod · 0.80
createSubscriptionMethod · 0.80
createTemplateMethod · 0.80
createUserMethod · 0.80

Calls 2

findCorrectTypeMethod · 0.80
getAttributeTypeMapMethod · 0.45

Tested by

no test coverage detected