فهرست منبع

feat(rcs-number): 添加 sms4verify03 供应商并优化短信验证码服务

- 在 rcs-number.entity.ts 中添加 sms4verify03 列举值
- 在 rcs-number.service.ts 中创建 sms4verify03 实例并配置价格参数
- 修改 sms4verify.service.ts,增加 max_price 参数并调整请求参数
- 优化短信验证码服务,支持根据价格选择供应商
wui 8 ماه پیش
والد
کامیت
698bf1b300

+ 1 - 0
src/rcs-number/entities/rcs-number.entity.ts

@@ -43,6 +43,7 @@ export enum RcsNumberSource {
     sms797902 = 'sms797902',
     sms4verify01 = 'sms4verify01',
     sms4verify02 = 'sms4verify02',
+    sms4verify03 = 'sms4verify03',
     sms23256 = 'sms23256',
     svenkvint = 'svenkvint',
     smsapi = 'smsapi',

+ 18 - 3
src/rcs-number/impl/sms4verify.service.ts

@@ -13,22 +13,37 @@ export class sms4verify extends GetNumberService {
 
     apikey: string
 
-    constructor(apikey: string, source: RcsNumberSource) {
+    max_price: string
+
+    constructor(apikey: string, maxPrice: string, source: RcsNumberSource) {
         super()
         this.apikey = apikey
         this.source = source
+        this.max_price = maxPrice
     }
 
     async getNumber(country: string, num?: number): Promise<GetNumberResponse> {
         if (country !== 'US') {
             throw new Error(`Platform ${this.source} only support US.`)
         }
-        const res = await axiosInstance.get('handler_api.php', {
-            params: {
+        let params: { api_key: string; action: string; service: string; max_price?: string }
+        if (this.max_price !== '0') {
+            params = {
+                api_key: this.apikey,
+                action: 'getNumber',
+                service: service,
+                max_price: this.max_price
+            }
+        } else {
+            params = {
                 api_key: this.apikey,
                 action: 'getNumber',
                 service: service
             }
+        }
+        console.log(params)
+        const res = await axiosInstance.get('handler_api.php', {
+            params
         })
 
         const data = res.data

+ 6 - 2
src/rcs-number/rcs-number.service.ts

@@ -54,6 +54,7 @@ export class RcsNumberService {
     private sms797902: sms7979
     private sms4verify01: sms4verify
     private sms4verify02: sms4verify
+    private sms4verify03: sms4verify
     private smspva: smspva
     private smspva02: smspva
     private smstiger: smstiger
@@ -97,8 +98,9 @@ export class RcsNumberService {
         this.cloud037 = new cloud214('100037', 'aaec6c21e54dc53b92e472df21a95bb7', RcsNumberSource.cloud037)
         this.cloud041 = new cloud214('100041', '8174f3107605645d17fd6c5edc0bfb7d', RcsNumberSource.cloud041)
         this.cloud050 = new cloud214('100050', '6c0f25c802b82d2a5c78f01fb627be2c', RcsNumberSource.cloud050)
-        this.sms4verify01 = new sms4verify('Yt8kbBGbvMTL3OBZ2dvwXCm78MI59D', RcsNumberSource.sms4verify01)
-        this.sms4verify02 = new sms4verify('402qwEj44JiaWMOOBPIxMnWaqeyIuV', RcsNumberSource.sms4verify02)
+        this.sms4verify01 = new sms4verify('Yt8kbBGbvMTL3OBZ2dvwXCm78MI59D', '0', RcsNumberSource.sms4verify01)
+        this.sms4verify02 = new sms4verify('402qwEj44JiaWMOOBPIxMnWaqeyIuV', '0', RcsNumberSource.sms4verify02)
+        this.sms4verify03 = new sms4verify('LFSsOnOjipHUE6jtgCpcEy7M9SEGme', '0.45', RcsNumberSource.sms4verify03)
         this.sms7979 = new sms7979('BbrlHwT4IWrfxR1tbSP6O8RkzW7Gdh', 45, RcsNumberSource.sms7979)
         this.sms797902 = new sms7979('BbrlHwT4IWrfxR1tbSP6O8RkzW7Gdh', 45, RcsNumberSource.sms797902)
         this.smspva = new smspva('uNW56fGr0zstfs87Xn0e1l2gCYVnb1', RcsNumberSource.smspva)
@@ -364,6 +366,8 @@ export class RcsNumberService {
                 return this.sms4verify01
             case RcsNumberSource.sms4verify02:
                 return this.sms4verify02
+            case RcsNumberSource.sms4verify03:
+                return this.sms4verify03
             case RcsNumberSource.sms23256:
                 return this.sms23256
             case RcsNumberSource.svenkvint: