public virtual APIResult <CardPointsCampaign> AddPoints(string numPoints, string campaignId, string customerId) { APIResult <CardPointsCampaign> res = new APIResult <CardPointsCampaign>(); FidelityCustomer customer; if (customerId == null) { customer = GetCustomerFromAuthenticatedUser(); } else { customer = GetCustomerFromIdOrEmail(customerId); } FidelityCampaign campaign = new FidelityCampaign(); campaign.Id = campaignId; if (customer != null) { APIResult <bool> resAdd = _sendService.SendAddPoints(settingsPart, customer, campaign, numPoints); if (!resAdd.success) { res = new APIResult <CardPointsCampaign> { success = false, data = null, message = resAdd.message }; } else { APIResult <FidelityCustomer> resCust = _sendService.SendCustomerDetails(settingsPart, customer); if (!resCust.success) { res = new APIResult <CardPointsCampaign> { success = false, data = null, message = resCust.message }; } else { res.success = resAdd.success; res.message = resAdd.message; CardPointsCampaign data = new CardPointsCampaign() { idCampaign = campaignId, idCustomer = customer.Id, points = resCust.data.PointsInCampaign[campaignId] }; res.data = data; } } } else { res = new APIResult <CardPointsCampaign> { success = false, data = null, message = "The user is not configured to use " + GetProviderName() }; } _workflowManager.TriggerEvent("AddFidelityPoints", null, () => new Dictionary <string, object> { { "result", res } }); return(res); }