Skip to content
New issue

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

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

Already on GitHub? # to your account

kobotoolbox: switch baseURL to baseUrl #989

Merged
merged 4 commits into from
Feb 10, 2025
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
5 changes: 5 additions & 0 deletions .changeset/red-coats-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/language-kobotoolbox': major
---

Renaming `baseURL` to `baseUrl` to match all other adaptors, and logging a warning if `baseURL` is used
18 changes: 15 additions & 3 deletions packages/kobotoolbox/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "getForms",
"params": [],
"docs": {
"description": "Make a request to fetch all survey forms accessible to the user's API token. The url is `/assets/?asset_type=survey`.",
"description": "Make a request to fetch all survey forms accessible to the user's API token. Calls `/api/v2/assets/?asset_type=survey`.",
"tags": [
{
"title": "public",
Expand All @@ -20,6 +20,10 @@
"description": null,
"name": null
},
{
"title": "state",
"description": "data - an array of form objects"
},
{
"title": "returns",
"description": null,
Expand All @@ -39,7 +43,7 @@
"options"
],
"docs": {
"description": "Get submissions for a specific form",
"description": "Get submissions for a specific form. Calls `/api/v2/assets/<id>/data/`.",
"tags": [
{
"title": "example",
Expand Down Expand Up @@ -83,6 +87,10 @@
"name": "options",
"default": "{}"
},
{
"title": "state",
"description": "data - an array of submission objects"
},
{
"title": "returns",
"description": null,
Expand All @@ -101,7 +109,7 @@
"formId"
],
"docs": {
"description": "Get deployment information for a specific form",
"description": "Get deployment information for a specific form. Calls `/api/v2/assets/<id>/deployment/`.",
"tags": [
{
"title": "example",
Expand All @@ -126,6 +134,10 @@
},
"name": "formId"
},
{
"title": "state",
"description": "data - an object containing deployment information"
},
{
"title": "returns",
"description": null,
Expand Down
6 changes: 3 additions & 3 deletions packages/kobotoolbox/configuration-schema.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"baseURL": {
"title": "Base URL",
"baseUrl": {
"title": "Base Url",
"type": "string",
"default": "https://kf.kobotoolbox.org",
"description": "Kobotoolbox URL",
Expand Down Expand Up @@ -46,7 +46,7 @@
"additionalProperties": true,
"required": [
"username",
"baseURL",
"baseUrl",
"password",
"apiVersion"
]
Expand Down
13 changes: 12 additions & 1 deletion packages/kobotoolbox/src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ export const prepareNextState = (state, response) => {
export async function request(state, method, path, opts) {
const { baseURL, apiVersion, username, password } = state.configuration;

let baseUrl;

if (!state.configuration.baseUrl && baseURL) {
baseUrl = baseURL;
console.warn(
'No baseUrl found in state.configuration. baseURL will be used instead, but this will be deprecated in the future.'
);
} else {
baseUrl = state.configuration.baseUrl;
}

const {
data = {},
query = {},
Expand All @@ -41,7 +52,7 @@ export async function request(state, method, path, opts) {
...query,
},
parseAs,
baseUrl: `${baseURL}/api/${apiVersion}`,
baseUrl: `${baseUrl}/api/${apiVersion}`,
};

if (paginate) {
Expand Down
2 changes: 1 addition & 1 deletion packages/kobotoolbox/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const configuration = {
username: 'test',
password: 'strongpassword',
apiVersion: 'v2',
baseURL: 'https://test.kobotoolbox.org',
baseUrl: 'https://test.kobotoolbox.org',
};

const defaultObjects = [
Expand Down