public async Task <string> SendShipmentCreatedMessage([FromBody] ShipmentMessage notification, [FromQuery] string configid)
        {
            try
            {
                var mergeVars = BuildShipmentVars(notification);
                return(await _mandrillSend.SendAsync(configid, notification, mergeVars));
            }
            catch (Exception e)
            {
                return(e.ToString());

                throw;
            }
        }
 public async Task <MessageResource> SendShipmentCreated([FromBody] ShipmentMessage notification)
 {
     return(await SendTwilio($"Your order has shipped. Tracking number {notification.EventBody.Shipment.TrackingNumber}", notification));
 }
        private List <GlobalMergeVar> BuildShipmentVars(ShipmentMessage notification)
        {
            var mergeVars = BuildOrderMergeVars(notification.EventBody);

            mergeVars.Add(new GlobalMergeVar {
                name = "ShipmentID", content = notification.EventBody.Shipment.ID
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "ShipmentTrackingNumber", content = notification.EventBody.Shipment.TrackingNumber
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "Shipper", content = notification.EventBody.Shipment.Shipper
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "dateShipped", content = notification.EventBody.Shipment.DateShipped
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressID", content = notification.EventBody.Shipment.ToAddress?.ID
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressCompany", content = notification.EventBody.Shipment.ToAddress?.CompanyName
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressFirstName", content = notification.EventBody.Shipment.ToAddress?.FirstName
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressLastName", content = notification.EventBody.Shipment.ToAddress?.LastName
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressStreet1", content = notification.EventBody.Shipment.ToAddress?.Street1
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressStreet2", content = notification.EventBody.Shipment.ToAddress?.Street2
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressCity", content = notification.EventBody.Shipment.ToAddress?.City
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressState", content = notification.EventBody.Shipment.ToAddress?.State
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressPostalCode", content = notification.EventBody.Shipment.ToAddress?.Zip
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressCountry", content = notification.EventBody.Shipment.ToAddress?.Country
            });
            mergeVars.Add(new GlobalMergeVar {
                name = "toAddressName", content = notification.EventBody.Shipment.ToAddress?.AddressName
            });
            mergeVars.Add(new GlobalMergeVar
            {
                name    = "shipmentItems",
                content = notification.EventBody.ShipmentItems
                          .Where(si => si.OrderID == notification.EventBody.Order.ID)
                          .Select(si =>
                {
                    var msi = new MandrillShipmentItem
                    {
                        Cost            = si.LineTotal,
                        QuantityShipped = si.QuantityShipped,
                        ProductDesc     = notification.EventBody.Products.FirstOrDefault(p => p.ID == si.ProductID)?.Description,
                        ProductID       = si.ProductID,
                        ProductName     = notification.EventBody.Products.FirstOrDefault(p => p.ID == si.ProductID)?.Name
                    };
                    return(msi);
                }).ToArray()
            });
            return(mergeVars);
        }
 public void SendShipment(ShipmentMessage message)
 {
     throw new NotImplementedException();
 }