it( 'yields fetch action for getting checkin record', () => { fetchDoActual(); reset(); const { value } = fulfillment.next(); expect( value ).toEqual( fetch( { path: getEndpoint( 'checkin' ) + '/?where[REG_ID]=10&where[DTT_ID]=20' + '&order_by[CHK_timestamp]=DESC&limit=1', method: 'GET', } ) ); } );
const getRelationRequestUrl = ( modelName, entityIds, relationName, relationSchema, relationType, hasJoinTable, calculatedFields, ) => { let path; switch ( true ) { case hasJoinTable: path = getEndpoint( singularModelName( relationSchema.joining_model_name ) .toLowerCase() ); path += '/?where' + getPrimaryKeyQueryString( singularModelName( modelName ), entityIds ); path += `&include=${ modelNameForQueryString( relationName ) }.*`; path = appendCalculatedFieldsToPath( path, calculatedFields, singularModelName( relationName ) ); break; case isBelongsToRelation( relationType ): path = getEndpoint( modelName ); path += `/?where${ getPrimaryKeyQueryString( modelName, entityIds ) }`; path += `&include=${ modelNameForQueryString( relationName ) }.*`; path = appendCalculatedFieldsToPath( path, calculatedFields, singularModelName( relationName ) ); break; default: // we do the reverse endpoint so that we are getting the belongs to // relation responses back and including the relation entities we // want in the response (belongs to). So for instance if the // incoming arguments are: // `getRelatedEntitiesForEntityIds( // 'attendee', // [ 10, 20], // 'registration' // ) // then the query would be: // /registrations/?where[ATT_ID][IN]=10,20&include=Attendee.* // basically the goal here is to get one to one relations returned // in the query for easier parsing/dispatching. // @todo, currently this will NOT account for paging. path = getEndpoint( singularModelName( relationName ) ); path += `/?where${ getPrimaryKeyQueryString( modelName, entityIds ) }`; path += `&include=${ modelNameForQueryString( modelName ) }.*`; path = appendCalculatedFieldsToPath( path, calculatedFields, ); break; } return path; };