public async static Task <GetUsageResponse> Get(GetAddesssApi api, string path, AdminKey adminKey, int day, int month, int year) { var fullPath = $"{path}{day}/{month}/{year}"; return(await Get(api, fullPath, adminKey)); }
public async static Task <ListInvoicesResponse> List(GetAddesssApi api, string path, AdminKey adminKey) { if (api == null) { throw new ArgumentNullException(nameof(api)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } api.SetAuthorizationKey(adminKey); var response = await api.Get(path); var body = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { var list = GetInvoiceList(body); return(new ListInvoicesResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, list)); } return(new ListInvoicesResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body)); }
public async Task <GetUsageResponse> Get(AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.Usage.Get()); } }
public async Task <RemoveWebhookResponse> Remove(RemoveWebhookRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.FirstLimitReachedWebhook.Remove(request)); } }
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)); }
public async Task <AddWebhookResponse> Add(AddWebhookRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.PaymentFailedWebhook.Add(request)); } }
public async Task <ListWebhookResponse> List(AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.ExpiredWebhook.List()); } }
public async Task <ListPermissionResponse> List(AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.Permission.List()); } }
public async Task <UpdatePermissionResponse> Update(UpdatePermissionRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.Permission.Update(request)); } }
public async static Task <RemovePrivateAddressResponse> Remove(GetAddesssApi api, RemovePrivateAddressRequest request, string path, AdminKey adminKey) { if (api == null) { throw new ArgumentNullException(nameof(api)); } if (request == null) { throw new ArgumentNullException(nameof(request)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } var fullPath = $"{path}{request.Postcode}/{request.Id}"; api.SetAuthorizationKey(adminKey); var response = await api.Delete(fullPath); var body = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(new RemovePrivateAddressResponse.Success((int)response.StatusCode, response.ReasonPhrase, body)); } return(new RemovePrivateAddressResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body)); }
public async static Task <ListPrivateAddressResponse> List(GetAddesssApi api, ListPrivateAddressRequest request, string path, AdminKey adminKey) { if (api == null) { throw new ArgumentNullException(nameof(api)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } if (request == null) { throw new ArgumentNullException(nameof(request)); } var fullPath = path + request.Postcode; api.SetAuthorizationKey(adminKey); var response = await api.Get(fullPath); var body = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { var addresses = GetPrivateAddresses(body); return(new ListPrivateAddressResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, addresses)); } return(new ListPrivateAddressResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body)); }
public async static Task <EmailAddressResponse> Update(GetAddesssApi api, string path, AdminKey adminKey, UpdateEmailAddressRequest request) { if (api == null) { throw new ArgumentNullException(nameof(api)); } api.SetAuthorizationKey(adminKey); var response = await api.Put(path, request); var body = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(new EmailAddressResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, request.NewEmailAddress)); } if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) { var message = GetMessage(body); return(new EmailAddressResponse.FailedInvalidEmailAddress((int)response.StatusCode, response.ReasonPhrase, body, message)); } return(new EmailAddressResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body)); }
public async Task <RemoveExpiredCCResponse> Remove(RemoveExpiredCCRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.ExpiredCC.Remove(request)); } }
public async static Task <GetUsageResponse> Get(GetAddesssApi api, string path, AdminKey adminKey) { if (api == null) { throw new ArgumentNullException(nameof(api)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } if (adminKey == null) { throw new ArgumentNullException(nameof(adminKey)); } api.SetAuthorizationKey(adminKey); var response = await api.Get(path); var body = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { var usage = GetUsage(body); return(new GetUsageResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, usage.Count, usage.Limit1, usage.Limit2)); } return(new GetUsageResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body)); }
public async Task <PlaceDetailsResponse> PlaceDetails(PlaceDetailsRequest request, ApiKey apiKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(apiKey ?? ApiKey, HttpClient ?? httpClient)) { return(await api.Address.PlaceDetails(request)); } }
public async Task <ListInvoiceCCResponse> List(AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, httpClient)) { return(await api.InvoiceCC.List()); } }
public async Task <DistanceResponse> Get(DistanceRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.Distance.Get(request)); } }
public async Task <GetInvoiceCCResponse> Get(GetInvoiceCCRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.InvoiceCC.Get(request)); } }
public async Task <SubscriptionResponse> Subscription(AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.Subscription.Get()); } }
public async static Task <UnsubscribeResponse> Unsubscribe(GetAddesssApi api, string path, AdminKey adminKey, string code = null) { if (api == null) { throw new ArgumentNullException(nameof(api)); } api.SetAuthorizationKey(adminKey); var fullPath = path + "unsubscribe"; if (!string.IsNullOrWhiteSpace(code)) { fullPath += $"?code={code}"; } var response = await api.Put(fullPath); var body = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(new UnsubscribeResponse.Success((int)response.StatusCode, response.ReasonPhrase, body)); } return(new UnsubscribeResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body)); }
public async Task <GetWebhookResponse> Get(GetWebhookRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.ExpiredWebhook.Get(request)); } }
public async Task GetWebhook() { var apiKey = KeyHelper.GetAdminKey(); using (var api = new GetAddesssApi(new AdminKey(apiKey))) { var addResult = await api.ExpiredWebhook.Add("https://enow375xiqy9k.x.pipedream.net/"); Assert.IsTrue(addResult.IsSuccess); var getResult = await api.ExpiredWebhook.Get(addResult.SuccessfulResult.Id); Assert.IsTrue(getResult.IsSuccess); var listResult = await api.ExpiredWebhook.List(); Assert.IsTrue(listResult.IsSuccess && listResult.SuccessfulResult.Webhooks.Any()); var testResult = await api.ExpiredWebhook.Test(); Assert.IsTrue(testResult.IsSuccess); var removeResult = await api.ExpiredWebhook.Remove(addResult.SuccessfulResult.Id); Assert.IsTrue(removeResult.IsSuccess); } }
public async Task <TestWebhookResponse> Test(AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.FirstLimitReachedWebhook.Test()); } }
public async Task All_Methods() { var apiKey = KeyHelper.GetAdminKey(); using (var api = new GetAddesssApi(new AdminKey(apiKey))) { var listResult = await api.ExpiredCC.List(); Assert.IsTrue(listResult.IsSuccess); foreach (var cc in listResult.SuccessfulResult.ExpiredCCs) { var deleteResult = await api.ExpiredCC.Remove(cc.Id); Assert.IsTrue(deleteResult.IsSuccess); } var addResult = await api.ExpiredCC.Add("*****@*****.**"); Assert.IsTrue(addResult.IsSuccess); var getResult = await api.ExpiredCC.Get(addResult.SuccessfulResult.Id); Assert.IsTrue(getResult.IsSuccess); var listResult2 = await api.ExpiredCC.List(); Assert.IsTrue(listResult2.IsSuccess && listResult2.SuccessfulResult.ExpiredCCs.Count() == 1); var deleteResult2 = await api.ExpiredCC.Remove(addResult.SuccessfulResult.Id); Assert.IsTrue(deleteResult2.IsSuccess); } }
public async static Task <RemoveIpAddressWhitelistResponse> Remove(GetAddesssApi api, RemoveIpAddressWhitelistRequest request, string path, AdminKey adminKey) { if (api == null) { throw new ArgumentNullException(nameof(api)); } if (request == null) { throw new ArgumentNullException(nameof(request)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } var fullPath = path + request.Id; api.SetAuthorizationKey(adminKey); var response = await api.Delete(fullPath); var body = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { var message = GetMessage(body); return(new RemoveIpAddressWhitelistResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, message)); } return(new RemoveIpAddressWhitelistResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body)); }
public async Task <EmailAddressResponse> Update(UpdateEmailAddressRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.EmailAddress.Update(request)); } }
private async static Task <GetInvoiceResponse> GetInternal(GetAddesssApi api, string path, AdminKey adminKey, string number) { if (api == null) { throw new ArgumentNullException(nameof(api)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } if (adminKey == null) { throw new ArgumentNullException(nameof(adminKey)); } api.SetAuthorizationKey(adminKey); var response = await api.Get(path); var body = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { var invoice = GetInvoice(body, number); return(new GetInvoiceResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, invoice)); } return(new GetInvoiceResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body)); }
public async Task <GetExpandedAddressResponse> GetExpanded(GetAddressRequest request, ApiKey apiKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(apiKey ?? ApiKey, HttpClient ?? httpClient)) { return(await api.Address.GetExpanded(request)); } }
public async Task <ListUsageResponse> List(ListUsageRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.Usage.List(request)); } }
public async Task <GetDomainWhitelistResponse> Get(GetDomainWhitelistRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.DomainWhitelist.Get(request)); } }