I want to design a model/class for my Angular App using the provided response template:
{
"id": {integer},
"name": {string},
"make": {
"id": {integer},
"name": {string},
"niceName": {string}
},
"model": {
"id": {string},
"name": {string},
"niceName": {string}
},
"year": {
"id": {integer},
"year": {integer}
},
"submodel": {
"body": {string},
"fuel": {string}, // not always available
"tuner": {string}, // not always available
"modelName": {string},
"niceName": {string}
},
"trim": {string},
"states": {array},
"engine": {object},
"transmission": {object},
"options": [
{
"category": {string},
"options": {array}
}
],
"colors": [
{
"category": {string},
"options": {array}
}
],
"drivenWheels": {string},
"numOfDoors": {string},
"squishVins": {array},
"categories": {object},
"MPG": {object},
"manufacturerCode": {string},
"price": {object}
}
to be transformed into something like this:
class SearchResult {
id: number;
name: string;
make: {
id: number;
name: string;
niceName: string;
};
model: {
id: number;
name: string;
niceName: string;
};
year: {
id: number;
year: number;
};
Certain considerations include:
Many fields have multiple objects/data for "colors" (Interior and Exterior) and Options (5 different categories). How can I implement a flexible loop to handle variable amounts of colors and other data?
Some fields return an object. How should I address this?
For instance, "model" is an object with three fields, similar to 'make' and 'submodel'. How should this be structured?