got the repos into a list! woo!
This commit is contained in:
parent
622086c0eb
commit
204df552a1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,48 +7,60 @@ using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
class Request
|
||||
{
|
||||
// TODO: this is rudimentary, fix it
|
||||
// i.e. try catch statements
|
||||
// i.e. try catch statements\
|
||||
// TODO: find how to access a list index
|
||||
// TODO: find how to access the deserialized
|
||||
|
||||
private string _apiEndpoint = "https://api.github.com/";
|
||||
private string _query;
|
||||
|
||||
public List<RepoDetail> RepoDetail { get; set; }
|
||||
|
||||
public Request(string query)
|
||||
{
|
||||
_query = query;
|
||||
}
|
||||
|
||||
//public Request(string query, Object function)
|
||||
//{
|
||||
// _query = query;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Calls API for repo and user data an stores it in RepoList
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void SearchRequest()
|
||||
{
|
||||
var client = new RestClient(_apiEndpoint);
|
||||
RestRequest requestRepo = new RestRequest($"users/{_query}/repos", Method.GET);
|
||||
|
||||
RestRequest requestRepo = new RestRequest($"users//{_query}//repos", Method.GET);
|
||||
|
||||
var response = client.Execute(requestRepo).ToString();
|
||||
|
||||
Deserialize(response);
|
||||
var response = client.Execute(requestRepo);
|
||||
var x = response.Content;
|
||||
var deserialized = JsonConvert.DeserializeObject<ObservableCollection<RepoDetail>>(x);
|
||||
|
||||
RepoList.repoDetail = deserialized;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deprecated: Calls API for user data
|
||||
/// </summary>
|
||||
public void UserRequest()
|
||||
{
|
||||
var client = new RestClient(_apiEndpoint);
|
||||
|
||||
RestRequest requestUser = new RestRequest($"users//{_query}", Method.GET);
|
||||
RestRequest requestUser = new RestRequest($"users/{_query}", Method.GET);
|
||||
|
||||
string response = client.Execute(requestUser).ToString();
|
||||
|
||||
Deserialize(response);
|
||||
}
|
||||
|
||||
private void Deserialize(string response)
|
||||
{
|
||||
var deserialized = JsonConvert.DeserializeObject<RepoDetail>(response);
|
||||
var response = client.Execute(requestUser);
|
||||
string x = response.ToString();
|
||||
var deserialized = JsonConvert.DeserializeObject<User>(x);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ namespace DeskHubSharp
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void btn_detail_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -4,7 +4,7 @@ namespace DeskHubSharp
|
||||
{
|
||||
private string _toEmail = "wjmiller2016@gmail.com";
|
||||
private string _fromEmail = "wjmiller2016@gmail.com";
|
||||
private string _passwordEmail = "IhaveanAMDRX580";
|
||||
private string _passwordEmail = "password";
|
||||
|
||||
public string Password
|
||||
{
|
||||
|
@ -102,293 +102,296 @@ namespace DeskHubSharp
|
||||
public string node_id { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int id { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string node_id { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string full_name { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string privates { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Owner owner { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string html_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string description { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string fork { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string forks_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string keys_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string collaborators_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string teams_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string hooks_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string issue_events_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string events_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string assignees_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string branches_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string tags_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string blobs_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string git_tags_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string git_refs_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string trees_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string statuses_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string languages_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string stargazers_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string contributors_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string subscribers_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string subscription_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string commits_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string git_commits_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string comments_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string issue_comment_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string contents_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string compare_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string merges_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string archive_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string downloads_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string issues_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string pulls_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string milestones_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string notifications_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string labels_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string releases_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string deployments_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string created_at { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string updated_at { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string pushed_at { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string git_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ssh_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string clone_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string svn_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string homepage { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int size { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int stargazers_count { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int watchers_count { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string language { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_issues { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_projects { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_downloads { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_wiki { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_pages { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int forks_count { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string mirror_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string archived { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int open_issues_count { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public License license { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int forks { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int open_issues { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int watchers { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string default_branch { get; set; }
|
||||
public class Root
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int id { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string node_id { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string full_name { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//public string private { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Owner owner { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string html_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string description { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string fork { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string forks_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string keys_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string collaborators_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string teams_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string hooks_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string issue_events_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string events_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string assignees_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string branches_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string tags_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string blobs_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string git_tags_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string git_refs_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string trees_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string statuses_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string languages_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string stargazers_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string contributors_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string subscribers_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string subscription_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string commits_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string git_commits_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string comments_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string issue_comment_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string contents_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string compare_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string merges_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string archive_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string downloads_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string issues_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string pulls_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string milestones_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string notifications_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string labels_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string releases_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string deployments_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string created_at { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string updated_at { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string pushed_at { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string git_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ssh_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string clone_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string svn_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string homepage { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int size { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int stargazers_count { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int watchers_count { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string language { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_issues { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_projects { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_downloads { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_wiki { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string has_pages { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int forks_count { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string mirror_url { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string archived { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int open_issues_count { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public License license { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int forks { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int open_issues { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int watchers { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string default_branch { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@ -7,8 +7,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
class RepoList : ObservableCollection<RepoDetail>
|
||||
class RepoList
|
||||
{
|
||||
private static ObservableCollection<RepoDetail> _repoDetail;
|
||||
|
||||
public static ObservableCollection<RepoDetail> repoDetail
|
||||
{
|
||||
get { return _repoDetail; }
|
||||
set { _repoDetail = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<Label x:Name="lbl_search" Content="Search" HorizontalAlignment="Left" Margin="17,15,0,0" VerticalAlignment="Top" FontSize="20" Padding="2,5,5,5"/>
|
||||
<TextBox x:Name="txtbox_query" HorizontalAlignment="Left" Height="23" Margin="17,79,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="465"/>
|
||||
<Label x:Name="lbl_user" Content="User:" HorizontalAlignment="Left" Margin="17,52,0,0" VerticalAlignment="Top" Padding="3,5,5,5" RenderTransformOrigin="0.686,0.474"/>
|
||||
<Button x:Name="btn_search" Content="GO!" HorizontalAlignment="Left" Margin="327,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFC4FF93"/>
|
||||
<Button x:Name="btn_search" Content="GO!" HorizontalAlignment="Left" Margin="327,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFC4FF93" Click="btn_search_Click"/>
|
||||
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="407,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFA1A1" Click="btn_close_Click"/>
|
||||
|
||||
</Grid>
|
||||
|
@ -28,5 +28,11 @@ namespace DeskHubSharp
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btn_search_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Request request = new Request(txtbox_query.Text);
|
||||
request.SearchRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user