chulkilee / ex_force

A Salesforce REST API wrapper for Elixir
https://hex.pm/packages/ex_force
MIT License
38 stars 28 forks source link

Use own struct, not Tesla's #25

Closed chulkilee closed 4 years ago

chulkilee commented 6 years ago

Currently ExForce returns plain Tesla struct, such as Tesla.Env. That works well for ad-hoc client, but since ExForce is standalone application, it may be better to use own struct.

zblanco commented 6 years ago

Using an internal struct instead of Tesla's would also be convenient to use the Composite and Batch endpoints. An %ExForce.Request{} could enable control over how we compose sets of requests. Since a composite request is a list of subrequests we could build an %ExForce.CompositeRequest{} with some helper functions.

Same concept for Batch requests. You build a valid %ExForce.BatchRequest{} struct out of a list of %ExForce.Request{} structs, and do some struct -> map conversion prior to hitting the endpoints.

Since Composite requests use a referenceId and Batch has it's own unique request parameters the builder pipeline could require those keys to build a valid Composite/Batch struct.

Then we'd just need some mapping functions that take a valid Request struct of any kind and make compatible for Tesla.