flutter api call + json model
Budget: €8 – €30 EUR
Hey, i need help with a specific api post call to display the data i need.
I can receive the json response and it looks good, but i need a data class model to work with this response.
Its a nested json with a dynamic KEY .
At the end, i need the SUM of one data variable out of this model -> to calculate the profit for all entries out of this model. Under "histroy trades" its the ticket ID and within it the data "profits". i need the total sum of all profits out of an api call
example:
{
"status": true,
"data": {
"history_trades": {
"2197653": {
"ticket": 2197653,
"cmd": 4,
"open_time": 0,
"close_time": 1656385204,
"position_id": 0,
"reason": 2,
"profit": -60.776,
"commission": 0,
"swap": 0,
"volume": 0,
"open_price": 0,
"close_price": 0,
"symbol": "",
"comment": "comPF 6600.67 20220627"
},
"2193073": {
"ticket": 2193073,
"cmd": 1,
"open_time": 0,
"close_time": 1656344568,
"position_id": 2045126,
"reason": 2,
"profit": 151.94,
"commission": 0,
"swap": 0,
"volume": 1,
"open_price": 0,
"close_price": 1,
"symbol": "PnL",
"comment": ""
},
"2215477": {
"ticket": 2215477,
"cmd": 4,
"open_time": 0,
"close_time": 1656558004,
"position_id": 0,
"reason": 2,
"profit": -45.748000000000005,
"commission": 0,
"swap": 0,
"volume": 0,
"open_price": 0,
"close_price": 0,
"symbol": "",
"comment": "comPF 6715.04 20220629"
},
"2212003": {
"ticket": 2212003,
"cmd": 1,
"open_time": 0,
"close_time": 1656522173,
"position_id": 2045126,
"reason": 2,
"profit": 114.37,
"commission": 0,
"swap": 0,
"volume": 1,
"open_price": 0,
"close_price": 1,
"symbol": "PnL",
"comment": ""
},
"2228644": {
"ticket": 2228644,
"cmd": 1,
"open_time": 0,
"close_time": 1656689387,
"position_id": 2045126,
"reason": 2,
"profit": 62.33,
"commission": 0,
"swap": 0,
"volume": 1,
"open_price": 0,
"close_price": 1,
"symbol": "PnL",
"comment": ""
},
I can receive the json response and it looks good, but i need a data class model to work with this response.
Its a nested json with a dynamic KEY .
At the end, i need the SUM of one data variable out of this model -> to calculate the profit for all entries out of this model. Under "histroy trades" its the ticket ID and within it the data "profits". i need the total sum of all profits out of an api call
example:
{
"status": true,
"data": {
"history_trades": {
"2197653": {
"ticket": 2197653,
"cmd": 4,
"open_time": 0,
"close_time": 1656385204,
"position_id": 0,
"reason": 2,
"profit": -60.776,
"commission": 0,
"swap": 0,
"volume": 0,
"open_price": 0,
"close_price": 0,
"symbol": "",
"comment": "comPF 6600.67 20220627"
},
"2193073": {
"ticket": 2193073,
"cmd": 1,
"open_time": 0,
"close_time": 1656344568,
"position_id": 2045126,
"reason": 2,
"profit": 151.94,
"commission": 0,
"swap": 0,
"volume": 1,
"open_price": 0,
"close_price": 1,
"symbol": "PnL",
"comment": ""
},
"2215477": {
"ticket": 2215477,
"cmd": 4,
"open_time": 0,
"close_time": 1656558004,
"position_id": 0,
"reason": 2,
"profit": -45.748000000000005,
"commission": 0,
"swap": 0,
"volume": 0,
"open_price": 0,
"close_price": 0,
"symbol": "",
"comment": "comPF 6715.04 20220629"
},
"2212003": {
"ticket": 2212003,
"cmd": 1,
"open_time": 0,
"close_time": 1656522173,
"position_id": 2045126,
"reason": 2,
"profit": 114.37,
"commission": 0,
"swap": 0,
"volume": 1,
"open_price": 0,
"close_price": 1,
"symbol": "PnL",
"comment": ""
},
"2228644": {
"ticket": 2228644,
"cmd": 1,
"open_time": 0,
"close_time": 1656689387,
"position_id": 2045126,
"reason": 2,
"profit": 62.33,
"commission": 0,
"swap": 0,
"volume": 1,
"open_price": 0,
"close_price": 1,
"symbol": "PnL",
"comment": ""
},