Esempio n. 1
0
        public async Task<int> SendEmailAsync(EmailRequest emailRequest)
        {
            if (emailRequest == null)
            {
                throw new ArgumentNullException("emailRequest");
            }

            EmailResponse response = await base.RequestWithPayloadAsync<EmailRequest, EmailResponse>(
                method: HttpMethod.Post,
                resourceParts: null,
                query: null,
                payload: emailRequest
                );

            return response.Count ?? 0;
        }
Esempio n. 2
0
        public async Task<int> SendEmailAsync(EmailRequest emailRequest)
        {
            if (emailRequest == null)
            {
                throw new ArgumentNullException("emailRequest");
            }

            string content = contentSerializer.Serialize(emailRequest);
            IHttpRequest request = new HttpRequest(HttpMethod.Post, baseAddress.Build(), baseHeaders, content);

            IHttpResponse response = await httpFacade.RequestAsync(request);
            HttpUtils.ThrowOnBadStatus(response, contentSerializer);

            var emailsSent = new { count = 0 };
            return contentSerializer.Deserialize(response.Body, emailsSent).count;
        }