From 8038839d0231a43a6424668acc8178f6d7a368a1 Mon Sep 17 00:00:00 2001 From: David Gutierrez Date: Mon, 18 Sep 2023 23:45:09 -0400 Subject: [PATCH 1/3] Added Void BillPayment Support --- .../DataServiceTestCases.cs | 5 ++ .../Intuit.Ipp.DataService/DataService.cs | 69 +++++++++++++++++++ .../Interface/IDataService.cs | 7 ++ 3 files changed, 81 insertions(+) diff --git a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService.Test/DataServiceTestCases.cs b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService.Test/DataServiceTestCases.cs index eb5af1bf..7e4b7b51 100644 --- a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService.Test/DataServiceTestCases.cs +++ b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService.Test/DataServiceTestCases.cs @@ -106,6 +106,11 @@ internal void VoidEntity(IEntity entity) this.dataService.Void(entity); } + internal void VoidBillPayment(BillPayment entity) + { + this.dataService.VoidBillPayment(entity); + } + internal void DeleteEntity(IEntity entity) { this.dataService.Delete(entity); diff --git a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs index dd3099da..bc1fd3ac 100644 --- a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs +++ b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs @@ -388,6 +388,75 @@ public T Void(T entity) where T : IEntity this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Finished Executing Method Void."); return (T)(restResponse.AnyIntuitObject as IEntity); } + + /// + /// Voids a bill payment under the specified realm. The realm must be set in the context. + /// + /// Bill Payment to Void + /// Returns the voided entity + public BillPayment VoidBillPayment(BillPayment entity) + { + this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Void."); + + // Validate parameter + if (!ServicesHelper.IsTypeNull(entity)) + { + IdsException exception = new IdsException(Resources.ParameterNotNullMessage, new ArgumentNullException(Resources.EntityString)); + this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Error, string.Format(CultureInfo.InvariantCulture, Resources.ExceptionGeneratedMessage, exception.ToString())); + IdsExceptionManager.HandleException(exception); + } + + + string resourceString = entity.GetType().Name.ToLower(CultureInfo.InvariantCulture); + + // Builds resource Uri + string uri = string.Format(CultureInfo.InvariantCulture, "{0}/company/{1}/{2}?operation=update&include=void", CoreConstants.VERSION, this.serviceContext.RealmId, resourceString); + + // Creates request parameters + RequestParameters parameters; + if (this.serviceContext.IppConfiguration.Message.Request.SerializationFormat == Intuit.Ipp.Core.Configuration.SerializationFormat.Json) + { + parameters = new RequestParameters(uri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONJSON); + } + else + { + parameters = new RequestParameters(uri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONXML); + } + + // Prepares request + HttpWebRequest request = this.restHandler.PrepareRequest(parameters, entity); + + string response = string.Empty; + try + { + // gets response + response = this.restHandler.GetResponse(request); + } + catch (IdsException ex) + { + IdsExceptionManager.HandleException(ex); + } + + CoreHelper.CheckNullResponseAndThrowException(response); + + // de serialize object + IntuitResponse restResponse = (IntuitResponse)CoreHelper.GetSerializer(this.serviceContext, false).Deserialize(response); + + if (restResponse.AnyIntuitObjects != null) + { + IntuitEntity intuitEntity = restResponse.AnyIntuitObject as IntuitEntity; + + if (restResponse != null && restResponse.status != IntuitResponseStatus.Deleted.ToString()) + { + IdsException exception = new IdsException(Resources.CommunicationErrorMessage, new CommunicationException(Resources.StatusNotVoided)); + this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Error, string.Format(CultureInfo.InvariantCulture, Resources.ExceptionGeneratedMessage, exception.ToString())); + IdsExceptionManager.HandleException(exception); + } + } + + this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Finished Executing Method Void."); + return (BillPayment)(restResponse.AnyIntuitObject as IEntity); + } #endregion #region Update diff --git a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/Interface/IDataService.cs b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/Interface/IDataService.cs index 61d0a391..6041a98d 100644 --- a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/Interface/IDataService.cs +++ b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/Interface/IDataService.cs @@ -52,6 +52,13 @@ public interface IDataService /// Entity to Delete. T Void(T entity) where T : IEntity; + /// + /// Voids a bill payment under the specified realm. The realm must be set in the context. + /// + /// Bill Payment to Void + /// Returns the voided entity + public BillPayment VoidBillPayment(BillPayment entity); + /// /// Updates an entity under the specified realm. The realm must be set in the context. /// From 46ae2b4e35c4709aa84da62f62015fa280ae8855 Mon Sep 17 00:00:00 2001 From: David Gutierrez <57277604+davidmailreaderio@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:28:21 -0400 Subject: [PATCH 2/3] Make methods virtual so we can override them in our project to inject token expiration handlers --- .../Code/Intuit.Ipp.DataService/DataService.cs | 10 +++++----- .../Code/Intuit.Ipp.QueryFilter/QueryService.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs index bc1fd3ac..ea5b60f6 100644 --- a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs +++ b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs @@ -195,7 +195,7 @@ public DataService(ServiceContext serviceContext) /// Generic Type T. /// Entity to Add. /// Returns an updated version of the entity with updated identifier and sync token. - public T Add(T entity) where T : IEntity + public virtual T Add(T entity) where T : IEntity { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Add."); @@ -394,7 +394,7 @@ public T Void(T entity) where T : IEntity /// /// Bill Payment to Void /// Returns the voided entity - public BillPayment VoidBillPayment(BillPayment entity) + public virtual BillPayment VoidBillPayment(BillPayment entity) { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Void."); @@ -467,7 +467,7 @@ public BillPayment VoidBillPayment(BillPayment entity) /// Generic Type T. /// Entity to Update. /// Returns an updated version of the entity with updated identifier and sync token. - public T Update(T entity) where T : IEntity + public virtual T Update(T entity) where T : IEntity { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Update."); @@ -1046,7 +1046,7 @@ public ReadOnlyCollection FindByLevel(T entity) where T : IEntity /// The start position to retrieve. /// Maximum no. of results to retrieve /// Returns the list of entities. - public ReadOnlyCollection FindAll(T entity, int startPosition = 1, int maxResults = 500) where T : IEntity + public virtual ReadOnlyCollection FindAll(T entity, int startPosition = 1, int maxResults = 500) where T : IEntity { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method FindAll."); @@ -1997,7 +1997,7 @@ private void CDCAsyncCompleted(object sender, CDCCallCompletedEventArgs eventArg /// Attachment Metadata of Stream to be Uploaded. /// Stream to be uploaded /// Returns an uploaded attachment with updated identifier and sync token. - public Attachable Upload(Attachable entity, System.IO.Stream stream) + public virtual Attachable Upload(Attachable entity, System.IO.Stream stream) { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Upload."); diff --git a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.QueryFilter/QueryService.cs b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.QueryFilter/QueryService.cs index 7f835646..692ee563 100644 --- a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.QueryFilter/QueryService.cs +++ b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.QueryFilter/QueryService.cs @@ -138,7 +138,7 @@ public QueryService(ServiceContext serviceContext) /// The string representation of ids query for getting just the count of records. /// Query Operation Type. Default value is query. /// Count of records. - public long ExecuteIdsQueryForCount(string idsQuery, QueryOperationType queryOperationType = QueryOperationType.query) + public virtual long ExecuteIdsQueryForCount(string idsQuery, QueryOperationType queryOperationType = QueryOperationType.query) { // Validate Parameter if (string.IsNullOrWhiteSpace(idsQuery)) @@ -195,7 +195,7 @@ public long ExecuteIdsQueryForCount(string idsQuery, QueryOperationType queryOpe /// The string representation of ids query. /// Query Operation Type. Default value is query. /// ReadOnly Collection fo items of type T. - public System.Collections.ObjectModel.ReadOnlyCollection ExecuteIdsQuery(string idsQuery, QueryOperationType queryOperationType = QueryOperationType.query) + public virtual System.Collections.ObjectModel.ReadOnlyCollection ExecuteIdsQuery(string idsQuery, QueryOperationType queryOperationType = QueryOperationType.query) { // Validate Parameter if (string.IsNullOrWhiteSpace(idsQuery)) @@ -332,7 +332,7 @@ public System.Collections.ObjectModel.ReadOnlyCollection ExecuteIdsQuery(stri /// } /// /// - public System.Collections.ObjectModel.ReadOnlyCollection> ExecuteMultipleEntityQueries(System.Collections.ObjectModel.ReadOnlyCollection queryOperationValues) where TSource : IEntity + public virtual System.Collections.ObjectModel.ReadOnlyCollection> ExecuteMultipleEntityQueries(System.Collections.ObjectModel.ReadOnlyCollection queryOperationValues) where TSource : IEntity { if (queryOperationValues == null || queryOperationValues.Count == 0) { From c1b538ac710d933613908f0512205b9cea054a14 Mon Sep 17 00:00:00 2001 From: David Gutierrez <57277604+davidmailreaderio@users.noreply.github.com> Date: Thu, 26 Sep 2024 00:04:11 -0400 Subject: [PATCH 3/3] Revert "Make methods virtual so we can override them in our project to inject token expiration handlers" This reverts commit 46ae2b4e35c4709aa84da62f62015fa280ae8855. --- .../Code/Intuit.Ipp.DataService/DataService.cs | 10 +++++----- .../Code/Intuit.Ipp.QueryFilter/QueryService.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs index ea5b60f6..bc1fd3ac 100644 --- a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs +++ b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs @@ -195,7 +195,7 @@ public DataService(ServiceContext serviceContext) /// Generic Type T. /// Entity to Add. /// Returns an updated version of the entity with updated identifier and sync token. - public virtual T Add(T entity) where T : IEntity + public T Add(T entity) where T : IEntity { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Add."); @@ -394,7 +394,7 @@ public T Void(T entity) where T : IEntity /// /// Bill Payment to Void /// Returns the voided entity - public virtual BillPayment VoidBillPayment(BillPayment entity) + public BillPayment VoidBillPayment(BillPayment entity) { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Void."); @@ -467,7 +467,7 @@ public virtual BillPayment VoidBillPayment(BillPayment entity) /// Generic Type T. /// Entity to Update. /// Returns an updated version of the entity with updated identifier and sync token. - public virtual T Update(T entity) where T : IEntity + public T Update(T entity) where T : IEntity { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Update."); @@ -1046,7 +1046,7 @@ public ReadOnlyCollection FindByLevel(T entity) where T : IEntity /// The start position to retrieve. /// Maximum no. of results to retrieve /// Returns the list of entities. - public virtual ReadOnlyCollection FindAll(T entity, int startPosition = 1, int maxResults = 500) where T : IEntity + public ReadOnlyCollection FindAll(T entity, int startPosition = 1, int maxResults = 500) where T : IEntity { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method FindAll."); @@ -1997,7 +1997,7 @@ private void CDCAsyncCompleted(object sender, CDCCallCompletedEventArgs eventArg /// Attachment Metadata of Stream to be Uploaded. /// Stream to be uploaded /// Returns an uploaded attachment with updated identifier and sync token. - public virtual Attachable Upload(Attachable entity, System.IO.Stream stream) + public Attachable Upload(Attachable entity, System.IO.Stream stream) { this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Upload."); diff --git a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.QueryFilter/QueryService.cs b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.QueryFilter/QueryService.cs index 692ee563..7f835646 100644 --- a/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.QueryFilter/QueryService.cs +++ b/IPPDotNetDevKitCSV3/Code/Intuit.Ipp.QueryFilter/QueryService.cs @@ -138,7 +138,7 @@ public QueryService(ServiceContext serviceContext) /// The string representation of ids query for getting just the count of records. /// Query Operation Type. Default value is query. /// Count of records. - public virtual long ExecuteIdsQueryForCount(string idsQuery, QueryOperationType queryOperationType = QueryOperationType.query) + public long ExecuteIdsQueryForCount(string idsQuery, QueryOperationType queryOperationType = QueryOperationType.query) { // Validate Parameter if (string.IsNullOrWhiteSpace(idsQuery)) @@ -195,7 +195,7 @@ public virtual long ExecuteIdsQueryForCount(string idsQuery, QueryOperationType /// The string representation of ids query. /// Query Operation Type. Default value is query. /// ReadOnly Collection fo items of type T. - public virtual System.Collections.ObjectModel.ReadOnlyCollection ExecuteIdsQuery(string idsQuery, QueryOperationType queryOperationType = QueryOperationType.query) + public System.Collections.ObjectModel.ReadOnlyCollection ExecuteIdsQuery(string idsQuery, QueryOperationType queryOperationType = QueryOperationType.query) { // Validate Parameter if (string.IsNullOrWhiteSpace(idsQuery)) @@ -332,7 +332,7 @@ public virtual System.Collections.ObjectModel.ReadOnlyCollection ExecuteIdsQu /// } /// /// - public virtual System.Collections.ObjectModel.ReadOnlyCollection> ExecuteMultipleEntityQueries(System.Collections.ObjectModel.ReadOnlyCollection queryOperationValues) where TSource : IEntity + public System.Collections.ObjectModel.ReadOnlyCollection> ExecuteMultipleEntityQueries(System.Collections.ObjectModel.ReadOnlyCollection queryOperationValues) where TSource : IEntity { if (queryOperationValues == null || queryOperationValues.Count == 0) {