Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Void BillPayment Support #319

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
69 changes: 69 additions & 0 deletions IPPDotNetDevKitCSV3/Code/Intuit.Ipp.DataService/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,75 @@ public T Void<T>(T entity) where T : IEntity
this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Finished Executing Method Void.");
return (T)(restResponse.AnyIntuitObject as IEntity);
}

/// <summary>
/// Voids a bill payment under the specified realm. The realm must be set in the context.
/// </summary>
/// <param name="entity">Bill Payment to Void</param>
/// <returns name="T">Returns the voided entity</returns>
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<IntuitResponse>(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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public interface IDataService
/// <param name="entity">Entity to Delete.</param>
T Void<T>(T entity) where T : IEntity;

/// <summary>
/// Voids a bill payment under the specified realm. The realm must be set in the context.
/// </summary>
/// <param name="entity">Bill Payment to Void</param>
/// <returns name="T">Returns the voided entity</returns>
public BillPayment VoidBillPayment(BillPayment entity);

/// <summary>
/// Updates an entity under the specified realm. The realm must be set in the context.
/// </summary>
Expand Down