/api/v1/fileGenerator/download
which receives
the payload that differs from one user to another user at run time. Payload example is as follows:
{
"fileType": "",
"headers": {
"email": {
"type": "email",
"prefix": "abc",
"postfix": "abc.io",
"value": "demoemail"
},
"phone": {
"type": "phone",
"prefix": "+977",
"value": "9867612345"
},
"name": {
"type": "name",
"prefix": "John",
"postfix": "Doe",
"value": "Demo"
},
"address": {
"type": "string",
"prefix": "BGL-",
"value": "Nepal"
},
"dummy": {
"type": "",
"prefix": "",
"postfix": ""
}
},
"noOfRecords": 20
}
if else
is cumbersome and it never meets the requirements for all the possible values that users may enter.
Another example could be, let us say user entered the completely uncommon header, then addressing with if else also becomes almost not feasible and type of data would just look too random and additionally not meaningful even though it will contain some type of random data.
{
"email" : {
"type" : "email",
"prefix": "cse-",
"postfix" : "ubc.com",
"value": "some_value"
}
}
In such case, one of the example emails which would be generated is cse-111222@ubc.com, where 111222 will be some randomly generated value. If we include value as well, it will just be appended to the prefix.
docker pull badripaudel77/dynamic-excel-generator
docker run -p 8080:8080 badripaudel77/dynamic-excel-generator:latest
curl -X POST http://localhost:8080/api/v1/fileGenerator/download \
-H "Content-Type: application/json" \
-d '{
"fileType": "",
"headers": {
"email": {
"type": "email",
"prefix": "abc",
"postfix": "abc.io",
"value": "demoemail"
},
"phone": {
"type": "phone",
"prefix": "+977",
"value": "9867612345"
},
"name": {
"type": "name",
"prefix": "John",
"postfix": "Doe",
"value": "Demo"
},
"address": {
"type": "string",
"prefix": "BGL-",
"value": "Nepal"
},
"dummy": {
"type": "",
"prefix": "",
"postfix": ""
}
},
"noOfRecords": 20
}'