public Result <WarrantyRequest, RequestConversionFailure> Build(
            VerifyWarrantyCaseRequest verifyWarrantyCaseRequest,
            WarrantyCaseOperation operation,
            Guid requestId)
        {
            try
            {
                var(requestType, actionType) = GetRequestTypeActionType(operation);

                var warrantyRequest = new WarrantyRequest
                {
                    RequestId       = requestId,
                    RequestType     = requestType,
                    Action          = actionType,
                    WarrantyCaseId  = verifyWarrantyCaseRequest.WarrantyCaseId,
                    TransactionDate = operation != WarrantyCaseOperation.Cancel
                        ? GetTransactionDateString(verifyWarrantyCaseRequest.TransactionDateTime)
                        : null,
                    OrderDetails = GetOrderDetails(verifyWarrantyCaseRequest, operation),
                };

                return(new Result <WarrantyRequest, RequestConversionFailure>(warrantyRequest));
            }
            catch (Exception e)
            {
                return(new Result <WarrantyRequest, RequestConversionFailure>(
                           new RequestConversionFailure($"Cannot build request of RequestId: `{requestId}` because:" + Environment.NewLine + e.Message)));
            }
        }
Exemplo n.º 2
0
 public ExternalPartyCall(
     WarrantyRequest expectedRequest,
     bool throws,
     WarrantyResponse?response)
 {
     ExpectedRequest = expectedRequest;
     Throws          = throws;
     Response        = response;
 }
Exemplo n.º 3
0
        public async Task <Result <WarrantyResponse, IFailure> > Call(WarrantyRequest request)
        {
            try
            {
                var warrantyResponse = await ExternalPartyProxy.Call(request);

                // potentially save the raw string response, before converting or deserializing to C# object?
                return(new Result <WarrantyResponse, IFailure>(warrantyResponse));
            }
            catch (NetworkException e)
            {
                return(new Result <WarrantyResponse, IFailure>(new NetworkFailure(e.Message)));
            }
        }
 protected override void CalculateRefundFor(WarrantyRequest warrantyRequest)
 {
     WarrantyRequest.AmountToRefund = warrantyRequest.PricePaid * devalutionAmt;
 }
 protected override void GenerateWarrantyTransactionFor(WarrantyRequest warrantyRequest)
 {
     // Code to determine terms of the warranty and devalutionAmt...
 }
Exemplo n.º 6
0
 protected override void CalculateRefundFor(WarrantyRequest warrantyRequest)
 {
     WarrantyRequest.AmountToRefund = warrantyRequest.PostageCost;
 }
Exemplo n.º 7
0
 protected override void GenerateWarrantyTransactionFor(WarrantyRequest warrantyRequest)
 {
     // Code to generate replacement order
 }