Exemplo n.º 1
0
        public void WhenIAddToMySuppressionsList()
        {
            var email = scenarioContext["randomemail"] as string;

            var client = scenarioContext.Get <IClient>();

            UpdateSuppressionResponse response = null;

            Task.Run(async() => { response = await client.Suppressions.CreateOrUpdate(new [] { email }); }).Wait();

            scenarioContext.Set(response);
            scenarioContext.Set <Response>(response);
        }
        public async Task <UpdateSuppressionResponse> CreateOrUpdate(IEnumerable <Suppression> suppressions)
        {
            var request = new Request
            {
                Url    = $"api/{client.Version}/suppression-list",
                Method = "PUT JSON",
                Data   = new
                {
                    recipients = suppressions.Select(x => dataMapper.ToDictionary(x)).ToList()
                }
            };

            var response = await requestSender.Send(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new ResponseException(response);
            }

            var updateSuppressionResponse = new UpdateSuppressionResponse();

            LeftRight.SetValuesToMatch(updateSuppressionResponse, response);
            return(updateSuppressionResponse);
        }