Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2 from OpenFn/custom_host_URLs
Browse files Browse the repository at this point in the history
bump to 1.1, allow hostUrl for custom deployments
  • Loading branch information
taylordowns2000 committed Feb 2, 2017
2 parents 33a08e1 + 2ae906a commit daf3147
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -29,7 +29,8 @@ Note that the username is your full email address.
"appId": "the-long-uuid-in-the-url-that-designates-a-unique-commcare-project",
"password": "shhh",
"username": "test@openfn.org",
"applicationName": "some-proof-of-concept"
"applicationName": "some-proof-of-concept",
"hostUrl": "https://www.commcarehq.org"
}
```

Expand Down
3 changes: 2 additions & 1 deletion lib/Adaptor.js
Expand Up @@ -125,9 +125,10 @@ function submit(formData) {
var username = _state$configuration.username;
var password = _state$configuration.password;
var appId = _state$configuration.appId;
var hostUrl = _state$configuration.hostUrl;


var url = 'https://www.commcarehq.org/a/'.concat(applicationName, '/receiver/', appId, '/');
var url = (hostUrl || "https://www.commcarehq.org").concat('/a/', applicationName, '/receiver/', appId, '/');

console.log("Posting to url: ".concat(url));
console.log("Raw JSON body: ".concat(JSON.stringify(jsonBody)));
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "language-commcare",
"version": "1.0.4",
"version": "1.1.0",
"description": "commcare Language Pack for OpenFn",
"main": "lib/index.js",
"scripts": {
Expand Down
29 changes: 16 additions & 13 deletions src/Adaptor.js
Expand Up @@ -53,30 +53,33 @@ export function submit(formData) {
const body = js2xmlparser("data", jsonBody);

const {
// this should be called project URL.
// it is what lives after www.commcarehq.org/a/...
applicationName,
username,
password,
appId
appId,
hostUrl
} = state.configuration;

const url = `https://www.commcarehq.org/a/`.concat(applicationName, '/receiver/', appId, '/')
const url = (hostUrl || "https://www.commcarehq.org").concat('/a/', applicationName, '/receiver/', appId, '/');

console.log("Posting to url: ".concat(url));
console.log("Raw JSON body: ".concat(JSON.stringify(jsonBody)));
console.log("X-form submission: ".concat(body));

return clientPost({
url,
body,
username,
password
})
.then((result) => {
console.log("Success:", result);
return {...state,
references: [result, ...state.references]
}
})
url,
body,
username,
password
})
.then((result) => {
console.log("Success:", result);
return {...state,
references: [result, ...state.references]
}
});

}
}
Expand Down

0 comments on commit daf3147

Please sign in to comment.