-
Notifications
You must be signed in to change notification settings - Fork 4
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
Method to call CKAN action API #10
Projects
Comments
10 tasks
Use in Datapub: await client.put('resource_create', resource.descriptor) The SDK implemented: index.js const ActionApi = require('./util/action-api')
class Client {
constructor(authToken, organizationId, datasetId, api) {
this.authToken = authToken
this.organizationId = organizationId
this.datasetId = datasetId
this.api = api
}
put(actionType, data) {
return ActionApi.action(this.api, this.authToken, actionType, data)
}
.
.
.
}
module.exports = {
Client,
} Action function: const ActionApi = {
// Call the ckan api actions ie. 'package_create'
action: async (baseUrl, authToken, actionType, data) => {
const path = `/api/3/action/${actionType}`
const config = {
headers: {
'Content-Type': 'application/json;charset=utf-8',
Authorization: authToken,
}
}
const body = JSON.stringify(data)
const response = await axios.post(`${baseUrl}${path}`, data, config)
if (!response.data.success) {
throw `Action response: ${response.statusText}`
}
return response.data
},
} |
The class Client {
// Call the ckan api actions ie. 'package_create'
action: async(actionType, payload, forceHttpGet=false) => {
const path = `/api/3/action/${actionType}`
const config = {
headers: {
'Content-Type': 'application/json;charset=utf-8',
Authorization: this.authToken,
}
}
const body = JSON.stringify(data)
// TODO: if forceHttpGet then ...
const response = await axios.post(`${baseUrl}${path}`, data, config)
if (!response.data.success) {
throw `Action response: ${response.statusText}`
}
return response.data
},
} |
kmanaseryan
added a commit
that referenced
this issue
Sep 14, 2020
rufuspollock
added a commit
that referenced
this issue
Sep 14, 2020
#10 - Improved the action() function and write tests
mariorodeghiero
added a commit
that referenced
this issue
Sep 14, 2020
Covered in #14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We can copy this from old okfn/ckan.js
Acceptance
async client.action(actionName, payload, useHttpGet=false)
calls CKAN action API and returns the result[ ] the method is documented in code and READMECreated a separate issue for this #22
Tasks
* [ ] Browser (?)I don't think we need this for now, because the implementation of
action()
is platform agnostic, i.e. there is no any platform related implementation for now.The text was updated successfully, but these errors were encountered: