import { inject , injectable } from 'inversify' ; import * as apid from '../../../../../api' ; import IRepositoryModel from '../IRepositoryModel' ; import IRuleApiModel from './IRuleApiModel' ; @ injectable ( ) export default class RuleApiModel implements IRuleApiModel { private repository : IRepositoryModel ; constructor ( @ inject ( 'IRepositoryModel' ) repository ) { this . repository = repository ; } param ruleId return public async get ( ruleId ) { const result = await this . repository . get ( `/rules/${ ruleId }` ) ; return result . data ; } param option return public async gets ( option ) { const result = await this . repository . get ( '/rules' , { params : option , } ) ; return result . data ; } param option return public async searchKeyword ( option ) { const result = await this . repository . get ( '/rules/keyword' , { params : option , } ) ; return result . data . items ; } param rule return public async add ( rule ) { const result = await this . repository . post ( '/rules' , rule ) ; return result . data ; } param ruleId param rule return public async update ( ruleId , rule ) { await this . repository . put ( `/rules/${ ruleId }` , rule ) ; } param ruleId return public async enable ( ruleId ) { await this . repository . put ( `/rules/${ ruleId }/enable` ) ; } param ruleId return public async disable ( ruleId ) { await this . repository . put ( `/rules/${ ruleId }/disable` ) ; } param ruleId return public async delete ( ruleId ) { await this . repository . delete ( `/rules/${ ruleId }` ) ; } }