import { BaseService } from '../BaseService' import type { BaseResponse, PaginationResponse } from '@/types/api/common' import type { GatewayOptions, StopResumeRecord, StopResumeQuery, CardStopResumeQuery, GatewayRule, GatewayRuleQuery, GatewayRuleInput, GatewayRuleTestInput, GatewayRuleTestResult, GatewayGroup, GatewayGroupQuery, GatewayGroupInput, GatewayCarrierStats, GatewayCarrierTrend } from '@/types/api/gateway' const rulesUrl = '/api/admin/gateway-error-classifications' const groupsUrl = '/api/admin/polling-rate-limit-groups' export class GatewayService extends BaseService { static getRecords(params: StopResumeQuery): Promise> { return this.get('/api/admin/card-stop-resume-records', params) } static getCardRecords( id: number, params?: CardStopResumeQuery ): Promise> { return this.get(`/api/admin/iot-cards/${id}/stop-resume-records`, params) } static getRules(params?: GatewayRuleQuery): Promise> { return this.get(rulesUrl, params) } static createRule(data: GatewayRuleInput): Promise> { return this.post(rulesUrl, data) } static updateRule(id: number, data: GatewayRuleInput): Promise> { return this.put(`${rulesUrl}/${id}`, data) } static setRuleStatus(id: number, status: number): Promise> { return this.put(`${rulesUrl}/${id}/status`, { status }) } static deleteRule(id: number): Promise> { return this.delete(`${rulesUrl}/${id}`) } static testRule(data: GatewayRuleTestInput): Promise> { return this.post(`${rulesUrl}/test`, data) } static getOptions(): Promise> { return this.get('/api/admin/polling-options') } static getGroups(params?: GatewayGroupQuery): Promise> { return this.get(groupsUrl, params) } static createGroup(data: GatewayGroupInput): Promise> { return this.post(groupsUrl, data) } static getGroup(id: number): Promise> { return this.get(`${groupsUrl}/${id}`) } static updateGroup(id: number, data: GatewayGroupInput): Promise> { return this.put(`${groupsUrl}/${id}`, data) } static setGroupStatus(id: number, status: number): Promise> { return this.put(`${groupsUrl}/${id}/status`, { status }) } static deleteGroup(id: number): Promise> { return this.delete(`${groupsUrl}/${id}`) } static getCarrierStats(minutes = 15): Promise> { return this.get('/api/admin/polling-stats/carriers', { minutes }) } static getCarrierTrend( carrierId: number, params: { minutes?: number; bucket_minutes?: number } = {} ): Promise> { return this.get(`/api/admin/polling-stats/carriers/${carrierId}/trend`, params) } }