优化
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user