public VoucherListRequest(CallerRequest callerRequest) { AppKey = callerRequest.AppKey; FromAccount = callerRequest.FromAccount; ToAccount = callerRequest.ToAccount; Token = callerRequest.Token; }
/// <summary> /// 获取标准的请求类型实例 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> protected async Task <T> GetRequestTypeAsync <T>() where T : ApiRequest, new() { T t = new T(); switch (t.GetType().Name) { case nameof(TokenRequest): t = new TokenRequest { AppKey = _appKey, AppSecret = _appSecret, FromAccount = _fromAccount } as T; break; case nameof(CallerRequest): t = new CallerRequest { AppKey = _appKey, FromAccount = _fromAccount, ToAccount = _toAccount, Token = await TokenManager.GetTokenAsync(BaseUrl, _appKey, _appSecret, _fromAccount, _toAccount), } as T; break; case nameof(DsRequest): t = new DsRequest { AppKey = _appKey, FromAccount = _fromAccount, ToAccount = _toAccount, Token = await TokenManager.GetTokenAsync(BaseUrl, _appKey, _appSecret, _fromAccount, _toAccount), } as T; break; case nameof(BaseRequest): default: t = new BaseRequest { AppKey = _appKey, FromAccount = _fromAccount, Token = await TokenManager.GetTokenAsync(BaseUrl, _appKey, _appSecret, _fromAccount, _toAccount), } as T; break; } return(t); }