OpenFn / adaptors

The new home for OpenFn adaptors; re-usable connectors for the most common DPGs and DPI building blocks.
GNU General Public License v3.0
7 stars 8 forks source link

commcare: generic `post` function #570

Closed aleksa-krolls closed 4 months ago

aleksa-krolls commented 4 months ago

Request

Add generic post function.

See docs on CommCare API endpoints we could use this with: https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143957350/User+Creation+Mobile+Worker https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143950677/Submission+API#Submission-as-the-body-of-a-post https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143946023/Bulk+upload+Lookup+Tables

To test

See LP CommCare Demo Project for a credential to our test project.

josephjclark commented 4 months ago

Looking over those docs it seems there are a few supported formats for the post. But we also already have submit and submitXls operations.

I suggest we keep it simple and just post JSON. Users will be able to set their own headers if they wish to upload a differemt format,

So we probably want an API like:

post(path, data, params, callback)

Where data is a JSON array or object.

It should be a very simple function, like get, which just wraps the existing request handler. The only automation we offer is a) a nice clean API and b) setting up auth according to state.configuration

aleksa-krolls commented 4 months ago

Sounds good to me!

hunterachieng commented 4 months ago

@aleksa-krolls This is under code review