Hello,
I have been extensively reviewing Epicor REST Integration examples and noticed that they are all using anonymous object types to interact with the API. Does anyone have any input regarding using strongly-typed objects instead when interacting with the API? This would greatly benefit integrators such as myself who would rather provide and receive a strongly-typed object to/from the API (e.g. doing a GET against Erp.Bo.SalesRepSvc returns a JSON body that can be deserialized into a “SalesRepRow” type), but currently it’s up to the integrator to create these types.
The closest thing I’ve found to what I’m after is within these Nuget packages by Jose Gomez but they only seem to include a couple object types unless I’m missing something: NuGet Gallery | josecgomez
Ideally Epicor would provide the complete collection of C# types (or the complete API wrapper) as a Nuget package so integrators can dive right in to API interaction without having to worry about generating the types.
Here’s an example I’ve written using strongly-typed objects generated using a REST generator I’ve adapted from Ed Welsh (GitHub - martin-technology-group/EpicorRESTClientGenerator)
public class SalesReps : ICRUDAsync<SalesRepRow, string>
{
private ErpBOSalesRepSvc SalesRepService { get; set; }
public SalesReps()
{
SalesRepService = new ErpBOSalesRepSvc();
}
public async Task<SalesRepRow> Create(SalesRepRow salesRep)
{
if (string.IsNullOrWhiteSpace(salesRep.Company))
{
salesRep.Company = "Denmar";
}
return await SalesRepService.SalesRepsAsync(salesRep);
}
public async Task<SalesRepRow> Read(string salesRepCode)
{
return await SalesRepService.GetById_SalesRepAsync("Denmar", salesRepCode, null, null, null);
}
public async Task<ODataSetResponseOfListOfSalesRepRow> ReadMany(string select = null,
string expand = null, string filter = null, string orderby = null, string top = null, string skip = null)
{
return await SalesRepService.GetRows_SalesRepsAsync(select, expand, filter, orderby, top, skip);
}
public async Task Update(SalesRepRow salesRep)
{
await SalesRepService.UpdateExt_SalesRepAsync("Denmar", salesRep.SalesRepCode, salesRep);
}
public async Task Delete(string salesRepCode)
{
await SalesRepService.DeleteUpdateExt_SalesRepAsync("Denmar", salesRepCode);
}
}
Thanks for your time!