There is an external system, from which I need to pull (via REST request) information about, let's say, brands and their categories. After the request, I need to collect the data in such structure:
public class Wrapper {
String brandId;
List<String> categories;
}
Then I need to insert records in Salesforce, but due to the huge process, there is also a limitation of, let's say, 5 records during the transaction. That's why in the case when there are more than 5 categories for one brand, I need to make 2 Wrappers.
Example: We have 2 brands:
- "Abibas" with 6 categories ("Shoes", "Hats", "Shorts", "Sweaters", "Socks", "Balls");
- "Nite" with 2 categories ("Clothes", "Sports")
I need the logic to distribute the data above to this structure:
[ {
"categories" : [ "Shoes", "Hats", "Shorts", "Sweaters", "Socks" ],
"brandId" : "Abibas"
}, {
"categories" : [ "Balls" ],
"brandId" : "Abibas"
}, {
"categories" : [ "Clothes", "Sports" ],
"brandId" : "Nite"
} ]
Please advise not heavy solution to distribute records in described structure.