Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:implement dynamic request function in commcare #755

Merged
merged 5 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/commcare/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-commcare

## 3.2.0

### Minor Changes

- c800948: Implement a generic request funciton for generic HTTP calls
- cff886e: Implement bulk function for lookup-table and case-data bulk uploads

## 3.1.2

### Patch Changes
Expand Down
151 changes: 151 additions & 0 deletions packages/commcare/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,157 @@
]
},
"valid": true
},
{
"name": "request",
"params": [
"method",
"path",
"body",
"options"
],
"docs": {
"description": "Make a general HTTP request against the Commcare server.",
"tags": [
{
"title": "example",
"description": "request(\"GET\", \"/a/asri/api/v0.5/case\");",
"caption": "Make a GET request to get cases"
},
{
"title": "function",
"description": null,
"name": null
},
{
"title": "public",
"description": null,
"type": null
},
{
"title": "param",
"description": "HTTP method to use",
"type": {
"type": "NameExpression",
"name": "string"
},
"name": "method"
},
{
"title": "param",
"description": "Path to resource",
"type": {
"type": "NameExpression",
"name": "string"
},
"name": "path"
},
{
"title": "param",
"description": "Object which will be attached to the body",
"type": {
"type": "NameExpression",
"name": "object"
},
"name": "body"
},
{
"title": "param",
"description": "Optional request params",
"type": {
"type": "NameExpression",
"name": "RequestOptions"
},
"name": "options"
},
{
"title": "returns",
"description": null,
"type": {
"type": "NameExpression",
"name": "Operation"
}
},
{
"title": "state",
"description": "{CommcareHttpState}"
}
]
},
"valid": true
},
{
"name": "bulk",
"params": [
"type",
"data",
"params"
],
"docs": {
"description": "Bulk upload data to CommCare for case-data or lookup-table. Accepts an array of objects, converts them into\nan XLS representation, and uploads.",
"tags": [
{
"title": "public",
"description": null,
"type": null
},
{
"title": "function",
"description": null,
"name": null
},
{
"title": "example",
"description": "bulk(\n [\n {name: 'Mamadou', phone: '000000'},\n ],\n {\n case_type: 'student',\n search_field: 'external_id',\n create_new_cases: 'on',\n }\n)",
"caption": "Upload a single row of data for case-data"
},
{
"title": "example",
"description": "bulk(\n 'lookup-table'\n {\n types: [{\n\n 'DELETE(Y/N)':'N',\n table_id: 'fruit',\n 'is_global?':'yes',\n 'field 1': 'type',\n 'field 2': 'name',\n }],\n fruit: [{\n UID: '',\n 'DELETE(Y/N)':'N',\n 'field:type': 'citrus',\n 'field:name': 'Orange',\n }],\n }\n)",
"caption": "Upload a single row of data for a lookup-table"
},
{
"title": "param",
"description": "case-data or lookup-table",
"type": {
"type": "NameExpression",
"name": "string"
},
"name": "type"
},
{
"title": "param",
"description": "Array of objects to upload",
"type": {
"type": "NameExpression",
"name": "array"
},
"name": "data"
},
{
"title": "param",
"description": "Input parameters, see {@link https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143946459/Bulk+Upload+Case+Data CommCare docs} for case-data and {@link https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143946023/Bulk+upload+Lookup+Tables Commcare Docs} for lookup-table.",
"type": {
"type": "NameExpression",
"name": "Object"
},
"name": "params"
},
{
"title": "state",
"description": "data - the response from the CommCare Server"
},
{
"title": "returns",
"description": null,
"type": {
"type": "NameExpression",
"name": "Operation"
}
}
]
},
"valid": true
}
],
"exports": [],
Expand Down
4 changes: 2 additions & 2 deletions packages/commcare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-commcare",
"version": "3.1.2",
"version": "3.2.0",
"description": "Commcare Language Pack for OpenFn",
"homepage": "https://docs.openfn.org",
"repository": {
Expand Down Expand Up @@ -50,4 +50,4 @@
},
"./package.json": "./package.json"
}
}
}
Loading
Loading