Skip to content

Commit

Permalink
Added recent nominations endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
babelshift committed Feb 17, 2017
1 parent d0836a3 commit c61b641
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ProPublicaCongressAPI/AutoMapperConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public static void Initialize()
opts => opts.ResolveUsing<DateTimeResolver, string>(s => s.DateLatestMajorAction))
.ForMember(dest => dest.DateSenatePassageVote,
opts => opts.ResolveUsing<NullableDateTimeResolver, string>(s => s.DateSenatePassageVote));
x.CreateMap<InternalModels.RecentNomination, Contracts.RecentNomination>();
});
}

Expand Down
16 changes: 16 additions & 0 deletions ProPublicaCongressAPI/Contracts/RecentNomination.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace ProPublicaCongressAPI.Contracts
{
public class RecentNomination
{
public string NominationId { get; set; }
public string NominationDetailUrl { get; set; }
public DateTime DateReceived { get; set; }
public string Description { get; set; }
public string NomineeState { get; set; }
public string CommitteeDetailUrl { get; set; }
public DateTime DateLatestAction { get; set; }
public string Status { get; set; }
}
}
11 changes: 11 additions & 0 deletions ProPublicaCongressAPI/Contracts/RecentNominationType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace ProPublicaCongressAPI.Contracts
{
public enum RecentNominationType
{
Unknown,
Received,
Updated,
Confirmed,
Withdrawn
}
}
32 changes: 32 additions & 0 deletions ProPublicaCongressAPI/InternalModels/RecentNomination.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Newtonsoft.Json;
using System;

namespace ProPublicaCongressAPI.InternalModels
{
internal class RecentNomination
{
[JsonProperty("id")]
public string NominationId { get; set; }

[JsonProperty("uri")]
public string NominationDetailUrl { get; set; }

[JsonProperty("date_received")]
public DateTime DateReceived { get; set; }

[JsonProperty("description")]
public string Description { get; set; }

[JsonProperty("nominee_state")]
public string NomineeState { get; set; }

[JsonProperty("committee_uri")]
public string CommitteeDetailUrl { get; set; }

[JsonProperty("latest_action_date")]
public DateTime DateLatestAction { get; set; }

[JsonProperty("status")]
public string Status { get; set; }
}
}
3 changes: 3 additions & 0 deletions ProPublicaCongressAPI/ProPublicaCongressAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
<Compile Include="Contracts\RecentBillsContainer.cs" />
<Compile Include="Contracts\RecentBillByMemberType.cs" />
<Compile Include="Contracts\RecentBillType.cs" />
<Compile Include="Contracts\RecentNomination.cs" />
<Compile Include="Contracts\RecentNominationType.cs" />
<Compile Include="Contracts\RollCallVote.cs" />
<Compile Include="Contracts\RollCallVoteContainer.cs" />
<Compile Include="Contracts\RollCallVotesContainer.cs" />
Expand Down Expand Up @@ -99,6 +101,7 @@
<Compile Include="InternalModels\RecentBillByMember.cs" />
<Compile Include="InternalModels\RecentBillsByMemberContainer.cs" />
<Compile Include="InternalModels\RecentBillsContainer.cs" />
<Compile Include="InternalModels\RecentNomination.cs" />
<Compile Include="InternalModels\RollCallVoteContainer.cs" />
<Compile Include="InternalModels\RollCallVoteSummaryDemocratic.cs" />
<Compile Include="InternalModels\RollCallVoteSummaryIndependent.cs" />
Expand Down
12 changes: 12 additions & 0 deletions ProPublicaCongressAPI/ProPublicaCongressApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ public ProPublicaCongressApiClient(string apiKey)
AutoMapperConfiguration.Initialize();
}

public async Task<IReadOnlyCollection<Contracts.RecentNomination>> GetRecentNominations(int congress, RecentNominationType nominationType)
{
string url = apiBaseUrl + String.Format(recentNominationsByTypeUrl, congress, nominationType.ToString().ToLower());

var internalModel = await GetMultipleResultDataAsync<InternalModels.RecentNomination>(url);
var contract = AutoMapperConfiguration.Mapper.Map<
IReadOnlyCollection<InternalModels.RecentNomination>,
IReadOnlyCollection< Contracts.RecentNomination>>(internalModel.Results);

return contract;
}

public async Task<Contracts.BillCosponsorContainer> GetBillCosponsors(int congress, string billId)
{
string url = apiBaseUrl + String.Format(billCosponsorsUrl, congress, billId);
Expand Down

0 comments on commit c61b641

Please sign in to comment.