/// <summary> /// Get customer data /// </summary> /// <param name="siteUserGuid">siteuserGuid</param> /// <returns>statuscode and Customer data</returns> public ApiResponse <Customer> GetCustomer(int siteUserGuid) { var myClassname = MethodBase.GetCurrentMethod().Name; var config = this.GetDefaultApiConfiguration(); var api = new CustomerApi(config); for (var i = 0; i <= MaxNoOfRetries; i++) { try { var res = api.GetCustomerWithHttpInfo(siteUserGuid.ToString()); if (res.StatusCode != (int)HttpStatusCode.OK) { this._log.Error($"Unexpected answer from reepay. {myClassname} Errorcode {res.StatusCode}"); } return(res); } catch (ApiException apiException) { this._log.Error($"{myClassname} {apiException.ErrorCode} {apiException.ErrorContent}"); return(new ApiResponse <Customer>(apiException.ErrorCode, null, null)); } catch (Exception) when(i < MaxNoOfRetries) { this._log.Debug($"{myClassname} retry attempt {i}"); } } return(new ApiResponse <Customer>((int)HttpStatusCode.InternalServerError, null, null)); }
/// <summary> /// Check if customer has active subscription /// </summary> /// <param name="siteUserGuid">siteuserGuid</param> /// <returns>true, if customer has an active subscription</returns> public bool HasActiveSubscription(int siteUserGuid) { var myClassname = MethodBase.GetCurrentMethod().Name; var config = this.GetDefaultApiConfiguration(); var api = new CustomerApi(config); for (var i = 0; i <= MaxNoOfRetries; i++) { try { var res = api.GetCustomerWithHttpInfo(siteUserGuid.ToString()); return(res.Data.ActiveSubscriptions > 0); } catch (ApiException apiException) { this._log.Error($"{myClassname} {apiException.ErrorCode} {apiException.ErrorContent}"); return(false); } catch (Exception) when(i < MaxNoOfRetries) { this._log.Debug($"{myClassname} retry attempt {i}"); } } return(false); }