Files
iNaturalistReactNative/src/api/relationships.js
Amanda Bullington 21b9cc6a97 Update Eslint to support TypeScript (#1419)
* Add typescript parser and fix Flow errors in JS files

* Uninstall packages from react-native/eslint-config

* Fix all flow errors (or ignore them for unknowns
2024-04-18 21:35:26 -07:00

53 lines
1.3 KiB
JavaScript

// @flow
import inatjs from "inaturalistjs";
import handleError from "./error";
const PARAMS = {
fields: "all"
};
const fetchRelationships = async ( params: Object = {}, opts: Object = {} ): Promise<?Object> => {
try {
const response = await inatjs.relationships.search( { ...PARAMS, ...params }, opts );
return response;
} catch ( e ) {
return handleError( e );
}
};
const createRelationships = async ( params: Object = {}, opts: Object = {} ): Promise<?Object> => {
try {
const response = await inatjs.relationships.create( { ...PARAMS, ...params }, opts );
return response;
} catch ( e ) {
return handleError( e );
}
};
const updateRelationships = async ( params: Object = {}, opts: Object = {} ): Promise<?Object> => {
try {
const response = await inatjs.relationships.update( { ...PARAMS, ...params }, opts );
return response;
} catch ( e ) {
return handleError( e );
}
};
const deleteRelationships = async ( params: Object = {}, opts: Object = {} ): Promise<?Object> => {
try {
const response = await inatjs.relationships.delete( params, opts );
return response;
} catch ( e ) {
return handleError( e );
}
};
export {
createRelationships,
deleteRelationships,
fetchRelationships,
updateRelationships
};