import { API } from "./API" ; import { APIUtils } from "./APIUtils" ; const ValidationRulesAPI = { getValidationRules : async ( projectId , options ? ) => { return API . getRequest ( `projects/${ projectId }/validation-rules` , true , { search : options && options . search , page : options && options . page , per_page : options && options . perPage } ) . then ( APIUtils . handleErrors ) . catch ( APIUtils . handleErrors ) ; } , createValidationRule : async ( options ) => { return API . postRequest ( `projects/${ options . projectId }/validation-rules` , true , { name : options . name , type : options . type , content : options . content } ) . then ( APIUtils . handleErrors ) . catch ( APIUtils . handleErrors ) ; } , updateValidationRule : async ( options ) => { return API . putRequest ( `projects/${ options . projectId }/validation-rules/${ options . ruleId }` , true , { name : options . name , type : options . type , content : options . content } ) . then ( APIUtils . handleErrors ) . catch ( APIUtils . handleErrors ) ; } , deleteValidationRules : async ( projectId , rules ) => { return API . deleteRequest ( `projects/${ projectId }/validation-rules` , true , { rules : rules } ) . then ( APIUtils . handleErrors ) . catch ( APIUtils . handleErrors ) ; } } ; export { ValidationRulesAPI } ;