mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-06 06:35:57 -04:00
* 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
53 lines
1.3 KiB
JavaScript
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
|
|
};
|