Exemplo n.º 1
0
        public async Task <UpdateSendingDomainResponse> Update(SendingDomain sendingDomain)
        {
            var request = new Request
            {
                Url    = $"/api/{client.Version}/sending-domains/{sendingDomain.Domain}",
                Method = "PUT",
                Data   = dataMapper.ToDictionary(sendingDomain)
            };

            var response = await requestSender.Send(request);

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

            var result = Jsonification.DeserializeObject <dynamic>(response.Content).results;

            return(result != null ? new UpdateSendingDomainResponse
            {
                ReasonPhrase = response.ReasonPhrase,
                StatusCode = response.StatusCode,
                Content = response.Content,
                Domain = result.domain,
                TrackingDomain = result.tracking_domain,
                Dkim = Dkim.ConvertToDkim(result.dkim),
            }
                : null);
        }
Exemplo n.º 2
0
        private static IEnumerable <SendingDomain> BuildTheSendingDomains(dynamic results)
        {
            var sendingDomains = new List <SendingDomain>();

            foreach (var r in results)
            {
                sendingDomains.Add(SendingDomain.ConvertToSendingDomain(r));
            }
            return(sendingDomains);
        }
        public async Task<CreateSendingDomainResponse> Create(SendingDomain sendingDomain)
        {
            var request = new Request
            {
                Url = $"/api/{client.Version}/sending-domains", 
                Method = "POST",
                Data = dataMapper.ToDictionary(sendingDomain)
            };

            var response = await requestSender.Send(request);
            if (response.StatusCode != HttpStatusCode.OK) throw new ResponseException(response);

            var result = Jsonification.DeserializeObject<dynamic>(response.Content).results;
            return result != null ? new CreateSendingDomainResponse
                {
                    ReasonPhrase = response.ReasonPhrase,
                    StatusCode = response.StatusCode,
                    Content = response.Content,
                    Domain = result.domain,
                    Dkim = Dkim.ConvertToDkim(result.dkim),
                }
                : null;
        }
Exemplo n.º 4
0
        public async Task <GetSendingDomainResponse> Retrieve(string domain)
        {
            var request = new Request
            {
                Url    = $"/api/{client.Version}/sending-domains/{domain}",
                Method = "GET",
            };

            var response = await requestSender.Send(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new ResponseException(response);
            }
            var result = Jsonification.DeserializeObject <dynamic>(response.Content).results;

            return(new GetSendingDomainResponse
            {
                ReasonPhrase = response.ReasonPhrase,
                StatusCode = response.StatusCode,
                Content = response.Content,
                SendingDomain = SendingDomain.ConvertToSendingDomain(result)
            });
        }
Exemplo n.º 5
0
 public virtual IDictionary <string, object> ToDictionary(SendingDomain sendingDomain)
 {
     return(WithCommonConventions(sendingDomain));
 }