Files
admin-web/src/modules/dimension-config/api.ts
T

36 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-08-07 19:23:43 +08:00
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import type {
CustomerDimensionConfig,
UpdateCustomerDimensionConfigRequest,
} from './types'
const dimensionConfigPath = '/platform/v1/first-leg/customer-dimension-config'
type RawDimensionConfig = Omit<CustomerDimensionConfig, 'tenantId'> & {
tenantId: string | number
}
function normalizeConfig(config: RawDimensionConfig): CustomerDimensionConfig {
return {
...config,
tenantId: String(config.tenantId),
}
}
export async function getCustomerDimensionConfig(tenantId: string): Promise<CustomerDimensionConfig> {
const response = await http.get<never, ApiEnvelope<RawDimensionConfig>>(dimensionConfigPath, {
params: { tenantId },
})
return normalizeConfig(unwrapApiResponse(response))
}
export async function updateCustomerDimensionConfig(
tenantId: string,
request: UpdateCustomerDimensionConfigRequest,
): Promise<CustomerDimensionConfig> {
const response = await http.put<never, ApiEnvelope<RawDimensionConfig>>(dimensionConfigPath, request, {
params: { tenantId },
})
return normalizeConfig(unwrapApiResponse(response))
}