public static ListSubaccountResponse CreateFromResponse(Response response)
        {
            var result = new ListSubaccountResponse();

            LeftRight.SetValuesToMatch(result, response);

            var results     = Jsonification.DeserializeObject <dynamic>(response.Content).results;
            var subaccounts = new List <Subaccount>();

            foreach (var r in results)
            {
                subaccounts.Add(ConvertToSubaccount(r));
            }

            result.Subaccounts = subaccounts;
            return(result);
        }
Beispiel #2
0
        public static ListWebhookResponse CreateFromResponse(Response response)
        {
            var result = new ListWebhookResponse();

            LeftRight.SetValuesToMatch(result, response);

            var results  = Jsonification.DeserializeObject <dynamic>(result.Content).results;
            var webhooks = new List <Webhook>();

            foreach (var r in results)
            {
                webhooks.Add(ConvertToAWebhook(r));
            }

            result.Webhooks = webhooks;
            return(result);
        }
Beispiel #3
0
        public async Task <Response> Create(Webhook webhook)
        {
            var request = new Request
            {
                Url    = $"api/{client.Version}/webhooks",
                Method = "POST",
                Data   = dataMapper.ToDictionary(webhook)
            };

            var response = await requestSender.Send(request);

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

            var updateSuppressionResponse = new Response();

            LeftRight.SetValuesToMatch(updateSuppressionResponse, response);
            return(updateSuppressionResponse);
        }
        public async Task <Response> Update(RelayWebhook relayWebhook)
        {
            var request = new Request
            {
                Url    = $"api/{client.Version}/relay-webhooks/{relayWebhook.Id}",
                Method = "PUT",
                Data   = dataMapper.ToDictionary(relayWebhook)
            };

            var response = await requestSender.Send(request);

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

            var createWebhookResponse = new Response();

            LeftRight.SetValuesToMatch(createWebhookResponse, response);
            return(createWebhookResponse);
        }
Beispiel #5
0
        public async Task <Response> Create(InboundDomain inboundDomain)
        {
            var request = new Request
            {
                Url    = $"api/{client.Version}/inbound-domains",
                Method = "POST",
                Data   = dataMapper.ToDictionary(inboundDomain)
            };

            var response = await requestSender.Send(request);

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

            var createInboundDomainResponse = new Response();

            LeftRight.SetValuesToMatch(createInboundDomainResponse, response);
            return(createInboundDomainResponse);
        }
        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);
        }