public async static Task <AddIpAddressWhitelistResponse> Add(GetAddesssApi api, AddIpAddressWhitelistRequest request, string path, AdminKey adminKey)
        {
            if (api == null)
            {
                throw new ArgumentNullException(nameof(api));
            }
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            api.SetAuthorizationKey(adminKey);

            var response = await api.Post(path, request);

            var body = await response.Content.ReadAsStringAsync();


            if (response.IsSuccessStatusCode)
            {
                var messageAndId = GetMessageAndId(body);

                return(new AddIpAddressWhitelistResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, messageAndId.Message, messageAndId.Id));
            }

            return(new AddIpAddressWhitelistResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body));
        }
Ejemplo n.º 2
0
        internal async static Task <TestWebhookResponse> Test(GetAddesssApi api, string path, AdminKey adminKey)
        {
            if (api == null)
            {
                throw new ArgumentNullException(nameof(api));
            }

            api.SetAuthorizationKey(adminKey);

            var response = await api.Post(path);

            var body = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                var message = GetMessage(body);

                return(new TestWebhookResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, message, message));
            }

            return(new TestWebhookResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body));
        }