Selaa lähdekoodia

feat(rcs-number): 更新 smspva 服务支持更多国家

- 在国家映射中添加了 US1、US2、US3三个新的国家代码
- 修改了 getNumber 方法,以支持新的国家代码
- 优化了国家代码的处理逻辑,提高了代码的灵活性和可维护性
wui 1 vuosi sitten
vanhempi
commit
8202555913
1 muutettua tiedostoa jossa 7 lisäystä ja 5 poistoa
  1. 7 5
      src/rcs-number/impl/smspva.service.ts

+ 7 - 5
src/rcs-number/impl/smspva.service.ts

@@ -12,19 +12,21 @@ const axiosInstance = axios.create({
 
 const countryMap = {
     US: 'US',
-    GB: 'UK',
-    BR: 'BR'
+    US1: 'US',
+    US2: 'US',
+    US3: 'US',
+    GB: 'UK'
 }
 
 export class smspva extends GetNumberService {
     source: RcsNumberSource = RcsNumberSource.smspva
 
     async getNumber(country: string, num?: number): Promise<GetNumberResponse> {
-        const countryCode = countryMap[country]
+        let countryCode = countryMap[country]
         if (!countryCode) {
-            throw new Error('No available country')
+            countryCode = country
         }
-        const res = await axiosInstance.get(`number/${country}/${SERVICE}`, {
+        const res = await axiosInstance.get(`number/${countryCode}/${SERVICE}`, {
             headers: {
                 apikey: API_KEY
             }