-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from ahwm/httpclient-update
initial updates to HttpClient
- Loading branch information
Showing
18 changed files
with
336 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ obj | |
bin | ||
.vs | ||
*.user | ||
*.runsettings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using GodaddyWrapper; | ||
#if NETCORE | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
#endif | ||
|
||
namespace GodaddyWrapper.Tests | ||
{ | ||
#if NETCORE | ||
public class Startup | ||
{ | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
string AccessKey = Environment.GetEnvironmentVariable("GODADDY_ACCESS_KEY").Trim(); | ||
string ApiSecret = Environment.GetEnvironmentVariable("GODADDY_API_SECRET").Trim(); | ||
services.AddGoDaddy(AccessKey, ApiSecret, true); | ||
//services.AddTransient<IDomainService, OpenSRSDomainService>(); | ||
} | ||
} | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,46 @@ | ||
using GodaddyWrapper.Responses; | ||
using GodaddyWrapper.Requests; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Threading.Tasks; | ||
using System.ComponentModel.DataAnnotations; | ||
using GodaddyWrapper.Helper; | ||
using GodaddyWrapper.Helper; | ||
using GodaddyWrapper.Requests; | ||
using GodaddyWrapper.Responses; | ||
using Newtonsoft.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace GodaddyWrapper | ||
{ | ||
public partial class Client | ||
{ | ||
/// <summary> | ||
/// Create a new abuse ticket | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <returns></returns> | ||
public async Task<AbuseTicketIdResponse> CreateAbuseTicket(AbuseTicketCreate request) | ||
{ | ||
var client = GetBaseHttpClient(); | ||
var response = await client.PostAsync($"abuse/tickets", JsonConvert.SerializeObject(request, JsonSettings)); | ||
await CheckResponseMessageIsValid(response); | ||
return await response.Content.ReadAsAsync<AbuseTicketIdResponse>(); | ||
} | ||
/// <summary> | ||
/// List all abuse tickets ids that match user provided filters | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <returns></returns> | ||
public async Task<AbuseTicketListResponse> RetrieveAbuseTickets(AbuseTicketRetrieve request) | ||
{ | ||
var client = GetBaseHttpClient(); | ||
var response = await client.GetAsync($"abuse/tickets{QueryStringBuilder.RequestObjectToQueryString(request)}"); | ||
await CheckResponseMessageIsValid(response); | ||
return await response.Content.ReadAsAsync<AbuseTicketListResponse>(); | ||
} | ||
|
||
/// <summary> | ||
/// Return the abuse ticket data for a given ticket id | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <returns></returns> | ||
public async Task<AbuseTicketResponse> RetrieveAbuseTicketDetail(AbuseTicketDetailRetrieve request) | ||
{ | ||
var client = GetBaseHttpClient(); | ||
var response = await client.GetAsync($"abuse/tickets/{request.TicketId}"); | ||
await CheckResponseMessageIsValid(response); | ||
return await response.Content.ReadAsAsync<AbuseTicketResponse>(); | ||
} | ||
|
||
} | ||
} | ||
namespace GodaddyWrapper | ||
{ | ||
public partial class GoDaddyClient | ||
{ | ||
/// <summary> | ||
/// Create a new abuse ticket | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <returns></returns> | ||
public async Task<AbuseTicketIdResponse> CreateAbuseTicket(AbuseTicketCreate request) | ||
{ | ||
var response = await httpClient.PostAsync($"abuse/tickets", JsonConvert.SerializeObject(request, JsonSettings)); | ||
await CheckResponseMessageIsValid(response); | ||
return await response.Content.ReadAsAsync<AbuseTicketIdResponse>(); | ||
} | ||
/// <summary> | ||
/// List all abuse tickets ids that match user provided filters | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <returns></returns> | ||
public async Task<AbuseTicketListResponse> RetrieveAbuseTickets(AbuseTicketRetrieve request) | ||
{ | ||
var response = await httpClient.GetAsync($"abuse/tickets{QueryStringBuilder.RequestObjectToQueryString(request)}"); | ||
await CheckResponseMessageIsValid(response); | ||
return await response.Content.ReadAsAsync<AbuseTicketListResponse>(); | ||
} | ||
|
||
/// <summary> | ||
/// Return the abuse ticket data for a given ticket id | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <returns></returns> | ||
public async Task<AbuseTicketResponse> RetrieveAbuseTicketDetail(AbuseTicketDetailRetrieve request) | ||
{ | ||
var response = await httpClient.GetAsync($"abuse/tickets/{request.TicketId}"); | ||
await CheckResponseMessageIsValid(response); | ||
return await response.Content.ReadAsAsync<AbuseTicketResponse>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.