Parallel Parameter Array Vs Single Key/Value List

41 views
Skip to first unread message

Jay C

unread,
Jun 27, 2016, 5:13:11 PM6/27/16
to API Craft
Hello,

I am working on a json-rpc api and I would like some feedback on the parameters for the RPC request.

Background:
Consider this example.  We have a RPC call that sends an email.  The email can go To multiple email addresses but only comes From one email address.  If a user sends an email To 5 people in one request, then when it gets to the server, we separate the request into 5 separate emails.

We also create unique ids ((UUIDs) for the emails, client side so we don't have to wait for the server response.  So each To email address needs an associated UUID.

Question:

What is the best format for the api parameters?

Should it be something like (pseudo json):

Option 1 - Parallel Parameter Arrays
To_IDs = [UUID1, UUID2, UUID3]

Option 2 - Key/Value List

Option 3 - Other

Manu Whig

unread,
Jun 30, 2016, 3:50:31 AM6/30/16
to API Craft
Option 2. Use the map. No chance of error correlating the UUID with the email which is possible in Option 1 depending on the data structure used on the server side. 

Even better would be to make "ToEmails_And_IDs" a list of objects/embedded docs. Each object encapsulates all the information you might want for this emailing feature without leaking that info to the outside documents Also better for future expansion of properties of the UUID_Email document.

Option 3 - Other
Reply all
Reply to author
Forward
0 new messages