Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
pablopareja committed Nov 27, 2019
2 parents b32eb83 + 3a2a8ec commit aaa8719
Show file tree
Hide file tree
Showing 18 changed files with 231 additions and 124 deletions.
32 changes: 26 additions & 6 deletions services/areas.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { WRIAPI } from 'utils/axios';
import { logger } from 'utils/logs';

/**
* Get area
* Get area.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#get-area|here}
* @param {String} id Area id.
* @param {Object} params Request paremeters.
* @param {Object} headers Request headers.
* @returns {Object}
*/
export const fetchArea = (id, params = {}, headers = {}) => {
logger.info(`Fetch area ${id}`);
Expand All @@ -28,7 +33,10 @@ export const fetchArea = (id, params = {}, headers = {}) => {
};

/**
* Get user areas
* Get user areas.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#get-user-areas|here}
* @param {String} token user's token.
* @returns {Object}
*/
export const fetchUserAreas = (token) => {
logger.info('Fetch user areas');
Expand All @@ -48,8 +56,9 @@ export const fetchUserAreas = (token) => {

/**
* Deletes an area
* @param {areaId} ID of the area that will be deleted
* @param {token} User token
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#delete-area|here}
* @param {String} areaId - ID of the area that will be deleted
* @param {String} token - User token
* @returns {Promise}
*/
export const deleteArea = (areaId, token) => {
Expand All @@ -63,7 +72,12 @@ export const deleteArea = (areaId, token) => {
};

/**
* Create new area
* Create new area.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#create-area|here}
* @param {String} name
* @param {String} geostore Geostore ID
* @param {String} token user's token
* @returns {Object}
*/
export const createArea = (name, geostore, token) => {
logger.info('Create area');
Expand All @@ -84,7 +98,13 @@ export const createArea = (name, geostore, token) => {
};

/**
* Update area
* Update area.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#areas|here}
* @param {String} id
* @param {String} name Name of the new area
* @param {String} token user's token.
* @param {String} geostore Geostore ID
* @returns {Object}
*/
export const updateArea = (id, name, token, geostore) => {
logger.info(`Update area ${id}`);
Expand Down
3 changes: 2 additions & 1 deletion services/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { logger } from 'utils/logs';
/**
* Fetchs posts from wordpress API.
*
* @param {Object[]} params - params sent to the API.
* @param {Object} params - params sent to the API.
* @param {Object} headers - headers sent to the API.
* @returns {Object[]} array of parsed posts.
*/
export const fetchPosts = (params = {}, headers = {}) => {
Expand Down
40 changes: 20 additions & 20 deletions services/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { logger } from 'utils/logs';

/**
* Retrieve all collections of the user
* @param {*} token User's token
* @param {*} params Request optional parameters
* @param {String} token User's token
* @param {Object} params Request optional parameters
*/
export const fetchAllCollections = (
token,
Expand All @@ -33,9 +33,9 @@ export const fetchAllCollections = (
};
/**
* Retrieve data of a specific collection
* @param {*} token User's token
* @param {*} collectionId Id of the collection we are asking for.
* @param {*} params Request parameters
* @param {String} token User's token
* @param {String} collectionId Id of the collection we are asking for.
* @param {Object} params Request parameters
*/
export const fetchCollection = (
token,
Expand Down Expand Up @@ -63,8 +63,8 @@ export const fetchCollection = (

/**
* Creates a new collection attached to the current user
* @param {*} token User's token
* @param {*} data collection data
* @param {String} token User's token
* @param {Object} data collection data
*/
export const createCollection = (token, data = {}) => {
logger.info('Create collection');
Expand All @@ -90,8 +90,8 @@ export const createCollection = (token, data = {}) => {

/**
* Deletes an existing collection attached to the current user
* @param {*} token User's token
* @param {*} collectionId Id of the collection to be removed
* @param {String} token User's token
* @param {String} collectionId Id of the collection to be removed
*/
export const deleteCollection = (token, collectionId) => {
logger.info(`Delete collection ${collectionId}`);
Expand All @@ -106,9 +106,9 @@ export const deleteCollection = (token, collectionId) => {

/**
* Update an existing collection attached to the current user
* @param {*} token User's token
* @param {*} collectionId Id of the collection to be edited
* @param {*} data Data to be updated
* @param {String} token User's token
* @param {String} collectionId Id of the collection to be edited
* @param {Object} data Data to be updated
*/
export const updateCollection = (token, collectionId, data) => {
logger.info(`Update collection ${collectionId}`);
Expand All @@ -129,10 +129,10 @@ export const updateCollection = (token, collectionId, data) => {
/* Resources management */

/**
*
* @param {*} token User's token
* @param {*} collectionId Id of the collection to be edited
* @param {*} resource Resource to be addded to the collection
* Add a resource to the collection
* @param {String} token User's token
* @param {String} collectionId Id of the collection to be edited
* @param {Object} resource Resource to be addded to the collection
*/
export const addResourceToCollection = (token, collectionId, resource = {}) => {
logger.info(`Add resource to collection ${collectionId}`);
Expand All @@ -157,10 +157,10 @@ export const addResourceToCollection = (token, collectionId, resource = {}) => {
};

/**
*
* @param {*} token User's token
* @param {*} collectionId Id of the collection to be edited
* @param {*} resource Resource to be removed from the collection
* Remove resource from collection
* @param {String} token User's token
* @param {String} collectionId Id of the collection to be edited
* @param {Object} resource Resource to be removed from the collection
*/
export const removeResourceFromCollection = (token, collectionId, resource = {}) => {
logger.info(`Remove resource from collection ${collectionId}`);
Expand Down
6 changes: 6 additions & 0 deletions services/contact-us.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
import { WRIAPI } from 'utils/axios';
import { logger } from 'utils/logs';

/**
* Sends a contact form including a topic, email address, and a message.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#contact-us|here}
* @param {Object} params Request paremeters to API.
* @returns {Promise}
*/
export const contactUs = (params) => {
logger.info('Contact us');
return WRIAPI.post('contact-us', params)
Expand Down
21 changes: 11 additions & 10 deletions services/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { logger } from 'utils/logs';

/**
* Fetchs dashboards according to params.
*
* @param {Object[]} params - params sent to the API.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#getting-all-dashboards|here}
* @param {Object} params Request paremeters to API.
* @param {Object} headers Request headers to API.
* @returns {Object[]} array of serialized dashboards.
*/
export const fetchDashboards = (params = {}, headers = {}) => {
Expand Down Expand Up @@ -43,7 +44,7 @@ export const fetchDashboards = (params = {}, headers = {}) => {

/**
* fetchs data for a specific dashboard.
*
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#dashboard|here}
* @param {String} id - dashboard id.
* @returns {Object} serialized specified dashboard.
*/
Expand Down Expand Up @@ -78,7 +79,7 @@ export const fetchDashboard = (id) => {
/**
* Creates a dashboard with the provided data.
* This fetch needs authentication.
*
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#dashboard|here}
* @param {Object} body - data provided to create the new dashboard.
* @param {String} token - user's token.
* @returns {Object} serialized created dashboard.
Expand Down Expand Up @@ -115,7 +116,7 @@ export const createDashboard = (body, token) => {
/**
* Updates a specified dashboard with the provided data.
* This fetch needs authentication.
*
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#dashboard|here}
* @param {String} id - dashboard ID to be updated.
* @param {Object} body - data provided to update the dashboard.
* @param {String} token - user's token
Expand Down Expand Up @@ -149,9 +150,9 @@ export const updateDashboard = (id, body, token) => {
/**
* Deletes a specified dashboard.
* This fetch needs authentication.
*
* @param {*} id - dashboard ID to be deleted.
* @param {string} token - user's token.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#dashboard|here}
* @param {String} id - dashboard ID to be deleted.
* @param {String} token - user's token.
* @returns {Object} fetch response.
*/
export const deleteDashboard = (id, token) => {
Expand Down Expand Up @@ -180,9 +181,9 @@ export const deleteDashboard = (id, token) => {
/**
* Clones a topic to convert it into a dashboard based on topic's data.
* This fetch needs authentication.
*
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#clone-dashboard216|here}
* @param {String} id - topic ID to be cloned.
* @param {string} token - user's token.
* @param {String} token - user's token.
* @return {Object} serialized dashboard cloned based on the ID topic.
*/
export const cloneDashboard = (id, token) => {
Expand Down
62 changes: 44 additions & 18 deletions services/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ export const fetchDatasets = (params = {}, headers = {}, _meta = false) => {


/**
* fetches data for a specific dataset.
*
* Fetches a dataset by id.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#how-to-get-a-dataset-by-id|here}
* @param {String} id - dataset id.
* @param {Object[]} params - params sent to the API.
* @param {Object} params - params sent to the API.
* @returns {Object} serialized specified dataset.
*/
export const fetchDataset = (id, params = {}) => {
Expand Down Expand Up @@ -102,8 +102,12 @@ export const fetchDataset = (id, params = {}) => {
};

/**
* Get dataset tags
*/
* Get dataset tags.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#tags-definition|here}
* @param {String} datasetId - dataset id.
* @param {Object} params - params sent to the API.
* @returns {Object}
*/
export const fetchDatasetTags = (datasetId, params = {}) => {
logger.info(`Fetch dataset tags: ${datasetId}`);
return WRIAPI.get(`dataset/${datasetId}/vocabulary`,
Expand All @@ -122,9 +126,9 @@ export const fetchDatasetTags = (datasetId, params = {}) => {
/**
* Deletes a specified dataset.
* This fetch needs authentication.
*
* @param {*} id - dataset ID to be deleted.
* @param {string} token - user's token.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#deleting-a-dataset|here}
* @param {String} id - dataset ID to be deleted.
* @param {String} token - user's token.
* @returns {Object} fetch response.
*/
export const deleteDataset = (id, token) => {
Expand Down Expand Up @@ -157,6 +161,14 @@ export const deleteDataset = (id, token) => {
});
};

/**
* Create a Dataset.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#creating-a-dataset|here}
* @param {String} token - user's token.
* @param {Object} params - params sent to the API.
* @param {Object} headers - headers sent to the API.
* @returns {Object}
*/
export const createDataset = (token, params = {}, headers) => {
logger.info('Create dataset');

Expand All @@ -172,6 +184,14 @@ export const createDataset = (token, params = {}, headers) => {
});
};

/**
* Update a Dataset.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#updating-a-dataset|here}
* @param {String} id - dataset id.
* @param {String} token - user's token.
* @param {Object} params - params sent to the API.
* @returns {Object}
*/
export const updateDataset = (id, token, params = {}) => {
logger.info(`Update dataset: ${id}`);

Expand All @@ -186,8 +206,14 @@ export const updateDataset = (id, token, params = {}) => {
};

/**
* Update dataset tags
*/
* Update dataset tags.
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#updating-tags-of-an-existing-relationship|here}
* @param {String} datasetId - dataset id.
* @param {Object[]} tags - user's token.
* @param {String} token - user's token.
* @param {boolean} usePatch - user's token.
* @returns {Object}
*/
export const updateDatasetTags = (datasetId, tags, token, usePatch = false) => {
logger.info(`Update dataset tags: ${datasetId}`);

Expand Down Expand Up @@ -240,12 +266,12 @@ export const updateDatasetTags = (datasetId, tags, token, usePatch = false) => {
};

/**
* Creates a metadata object in the specified dataset
* Creates a metadata object in the specified dataset.
* This methods requires authentication.
*
* @param {*} datasetId - dataset ID where the metadata will be attached
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#creating-a-metadata-object|here}
* @param {String} datasetId - dataset ID where the metadata will be attached
* @param {Object} params - metadata object
* @param {string} token - user's token.
* @param {String} token - user's token.
* @returns {Object} serialized metadata object.
*/
export const createMetadata = (datasetId, params = {}, token, headers = {}) => {
Expand All @@ -269,12 +295,12 @@ export const createMetadata = (datasetId, params = {}, token, headers = {}) => {
};

/**
* Updates a metadata object in the specified dataset
* Updates a metadata object in the specified dataset.
* This methods requires authentication.
*
* @param {*} datasetId - dataset ID where the metadata will be attached
* Check out the API docs for this endpoint {@link https://resource-watch.github.io/doc-api/index-rw.html#updating-a-metadata|here}
* @param {String} datasetId - dataset ID where the metadata will be attached
* @param {Object} params - metadata object
* @param {string} token - user's token.
* @param {String} token - user's token.
* @returns {Object} serialized metadata object.
*/
export const updateMetadata = (datasetId, params = {}, token, headers = {}) => {
Expand Down
Loading

0 comments on commit aaa8719

Please sign in to comment.