private RequestCreateBranchHandler GetHandler() { this.configurationManager = Substitute.For <IConfigurationManager>(); this.gitHubApi = Substitute.For <IGitHubApi>(); return(new RequestCreateBranchHandler(this.configurationManager, this.gitHubApi)); }
/// <summary> /// /// </summary> /// <param name="uri"></param> /// <returns></returns> private async Task <byte[]> ExtractFromUrl(Uri uri) { //using (HttpClient client = new HttpClient()) //{ // //var y = await client.GetByteArrayAsync(uri); // client.BaseAddress = uri; // client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/zip")); // var response = await client.GetAsync(uri); // if (response.IsSuccessStatusCode) // return response.Content.ReadAsByteArrayAsync().Result; // else return null; //} // Create an implementation of that interface // We'll pass in the base URL for the API IGitHubApi api = RestClient.For <IGitHubApi>(uri.AbsoluteUri); // Now we can simply call methods on it var response = await api.GetByteAsync(); if (response.ResponseMessage.IsSuccessStatusCode) { return(response.GetContent()); } else { return(null); } }
public ApiService() { _api = Refit.RestService.For <IGitHubApi>(KeyValues.ApiBaseUrl); _hasInternet = Connectivity.NetworkAccess == NetworkAccess.Internet; Connectivity.ConnectivityChanged += ConnectivityOnConnectivityChanged; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = { new StringEnumConverter() } }; gitHubApi = RestService.For <IGitHubApi>("https://api.github.com"); list_series = FindViewById <ListView>(Resource.Id.list_series); tableItems = new List <UsersTest>(); getUsers(); list_series.ItemClick += List_series_ItemClick; }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); gitHubApi = RestService.For <IGitHubApi>("https://api.github.com"); cake_button = FindViewById <Button>(Resource.Id.btn_list_users); listView = FindViewById <ListView>(Resource.Id.listview_users); cake_button.Click += Cake_Button_Click; JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = { new StringEnumConverter() } }; }catch { Toast.MakeText(this, "Error", ToastLength.Short).Show(); } }
private RequestCheckCommentAnswerHandler GetHandler() { this.configurationManager = Substitute.For <IConfigurationManager>(); this.gitHubApi = Substitute.For <IGitHubApi>(); return(new RequestCheckCommentAnswerHandler(this.configurationManager, this.gitHubApi)); }
IObservable <GitHubOrgInfo> getUserAsOrgInfo(IGitHubApi api) { return(api.GetCurrentUser() .Select(x => new GitHubOrgInfo() { login = x.login, avatar_url = x.avatar_url, url = x.url })); }
public GitHubApiBusiness(IContextRepository context, IGitHubApi gitHubApi, IMapperGitHubRepository mapperGitHubRepository, IMapperRepository mapperRepository, IMapperFavorite mapperFavorite) { _context = context; _gitHubApi = gitHubApi; _mapperRepository = mapperRepository; _mapperGitHubRepository = mapperGitHubRepository; _mapperFavorite = mapperFavorite; }
public GitHub(string accessToken) { var client = new HttpClient(new AuthenticatedHttpClientHandler(accessToken)) { BaseAddress = new Uri("https://api.github.com") }; _gitHub = RestService.For <IGitHubApi>(client); }
public HomeController() { _client = new HttpClient { BaseAddress = new Uri("https://api.github.com"), DefaultRequestHeaders = { UserAgent = { ProductInfoHeaderValue.Parse("NakWarsi") } } }; _restApiService = RestService.For <IGitHubApi>(_client); }
public string FetchRestEase() { IGitHubApi api = RestEase.RestClient.For <IGitHubApi>("https://jsonplaceholder.typicode.com/"); List <Item> user = api.GetPhotosAsync("photos").Result; string u; u = user.ToString(); return(u); }
public Apis() { var client = new HttpClient(new UriQueryUnescapingHandler()) { BaseAddress = new Uri("https://api.github.com"), Timeout = TimeSpan.FromSeconds(10) }; GitHub = RestService.For <IGitHubApi>(client); }
public async Task <Either <BaseError, string> > GetLatestReleaseNotes(CancellationToken cancellationToken) { try { IGitHubApi service = RestService.For <IGitHubApi>("https://api.github.com"); return(await service.GetReleases(cancellationToken).Map(releases => releases.Head().Body)); } catch (Exception ex) { return(BaseError.New(ex.ToString())); } }
public static void Main(string[] args) { IGitHubApi api = RestClient.For <IGitHubApi>("https://api.github.com"); Console.WriteLine("Type your GitHub username: "******"Name: {user.Name}. Blog: {user.Blog}. CreatedAt: {user.CreatedAt}"); Console.ReadLine(); }
public RepositoryService(IMapper mapper, IRepositoryRepository repositoryRepository, IOwnerRepository ownerRepository) { var httpClient = new HttpClient { BaseAddress = new Uri(Environment.GetEnvironmentVariable("GitHubUrl")), DefaultRequestHeaders = { { "User-Agent", "GitHubApi" } } }; _mapper = mapper; _repositoryRepository = repositoryRepository; _ownerRepository = ownerRepository; _githubService = RestService.For <IGitHubApi>(httpClient); }
public RepoSelectionViewModel(IScreen hostScreen, IGitHubApi api) { HostScreen = hostScreen; var orgs = api.GetOrganizationsForUser(); var userInfo = getUserAsOrgInfo(api); var repoTable = orgs.SelectMany(x => x.ToObservable()) .Select(x => new { Key = x, Value = api.GetReposFromOrganization(x) }) .Concat(userInfo.Select(x => new { Key = x, Value = api.GetReposForUser() })); Organizations = repoTable.Select(x => new OrganizationTileViewModel(x.Key, x.Value)).CreateCollection(); FinishedLoading = repoTable.Aggregate(Unit.Default, (acc, x) => Unit.Default); }
public static async Task Main(string[] args) { IGitHubApi gitHubApi = RestClient.For <IGitHubApi>("https://api.github.com", new JsonRestSettings() { HttpMessageHandlerFactory = () => new DelegatingLoggingHandler(new HttpClientHandler()) }); User user = await gitHubApi.GetUserAsync("lestar"); Console.WriteLine($"Login: {user.Login}, Url:{user.Url}"); SearchResult <User> results = await gitHubApi.FindUsersAsync("tom+repos:<42+followers:<1000"); Console.Read(); }
private async void GetAccessToken() { //var auth = AspNet.Security.OAuth.GitHub.GitHubAuthenticationDefaults. Uri gitHubUri = new Uri("https://api.github.com"); // Create an implementation of that interface // We'll pass in the base URL for the API IGitHubApi api = RestClient.For <IGitHubApi>(gitHubUri.AbsoluteUri); // Sends a GET request to https://api.github.com var repositories = await api.GetTokenAsync(); // string tokenString = "66d32909b6aafe5f7b311984f303b3df25e2d7fe"; }
private async Task <string> ScrapeRepo() { Uri gitHubUri = new Uri("https://api.github.com"); // Create an implementation of that interface // We'll pass in the base URL for the API IGitHubApi api = RestClient.For <IGitHubApi>(gitHubUri.AbsoluteUri); // Sends a GET request to https://api.github.com var repositories = await api.GetReposAsync(); //get the response header var headers = repositories.ResponseMessage.Headers; string nextRepoList = ""; IEnumerable <string> headerValues; if (headers.TryGetValues("link", out headerValues)) //find the link field in response header { nextRepoList = headerValues.First(); } //here we are getting the link to the next page using a regex split string nextPageLink = ""; foreach (string pair in nextRepoList.Split(',')) { var splitPair = pair.Split(';'); var re = new Regex("<(.*)>"); string URI = re.Match(splitPair[0]).Groups[1].Value; if (splitPair[1].Contains("next")) { nextPageLink = URI; } } //getting a list of tags from each repository List <Repos> repoList = repositories.GetContent(); List <string> tagList = new List <string>(); foreach (Repos repo in repoList) { tagList.Add(repo.url); Uri tagUri = new Uri(repo.url); var tags = await GetRepoTags(tagUri); } return(nextPageLink); }
/// <summary> /// <inheritdoc/> /// </summary> /// <returns><inheritdoc/></returns> public async Task <Install> InstallEliteInsights() { IGitHubApi githubApi = RestClient.For <IGitHubApi>(new Uri(@"https://api.github.com")); var repo = await githubApi.GetLatestRelease("baaron4", "GW2-Elite-Insights-Parser").ConfigureAwait(false); if (repo == null) { return(Install.Error); } string fileVersion = GetFileVersionInfo(); if (!string.IsNullOrWhiteSpace(fileVersion) && repo.TagName.Contains(fileVersion, StringComparison.InvariantCultureIgnoreCase)) { return(Install.UpToDate); } var asset = repo.Assets.FirstOrDefault(a => a.Name.Equals("GW2EI.zip", StringComparison.Ordinal)); if (asset == null) { return(Install.Error); } string destinationPath = Path.Combine(AssemblyLocation, BaseEIPath); if (Directory.Exists(destinationPath)) { Directory.Delete(destinationPath, true); } Directory.CreateDirectory(destinationPath); string zipFile = Path.Combine(destinationPath, asset.Name); using var client = new WebClient(); client.Headers.Add(HttpRequestHeader.UserAgent, "LogParser"); client.DownloadFile(asset.DownloadUrl, zipFile); if (File.Exists(zipFile)) { ZipFile.ExtractToDirectory(zipFile, destinationPath); File.Delete(zipFile); } return(Install.Success); }
private async Task <List <Tags> > GetRepoTags(Uri repoTagUrl) { // Create an implementation of that interface // We'll pass in the base URL for the API IGitHubApi api = RestClient.For <IGitHubApi>(repoTagUrl.AbsoluteUri); // Now we can simply call methods on it var response = await api.GetTagsAsync(); if (response.ResponseMessage.IsSuccessStatusCode) { return(response.GetContent()); } else { return(null); } }
public static async Task <string> CheckForNewVersion() { string link = null; IGitHubApi githubApi = RestClient.For <IGitHubApi>(new Uri(@"https://api.github.com")); var repos = await githubApi.GetReleases("KojimaKumiko", "LogParser").ConfigureAwait(true); if (repos == null || repos.Count <= 0) { throw new InvalidOperationException(); } var version = GetVersion(); var latest = repos.First(); if (!latest.TagName.Contains(version, StringComparison.InvariantCultureIgnoreCase)) { link = latest.Assets.First().DownloadUrl.ToString(); } return(link); }
protected override void OnCreate(Bundle bundle) { try { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); cake_lyf_button = FindViewById <Button>(Resource.Id.btn_list_users); listView = FindViewById <ListView>(Resource.Id.listview_users); cake_lyf_button.Click += Cake_lyf_button_Click; JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = { new StringEnumConverter() } }; gitHubApi = RestService.For <IGitHubApi>("https://api.github.com"); } catch (Exception ex) { Log.Error("Ozioma See", ex.Message); } }
public GitHubApi () { api = RestService.For<IGitHubApi>("https://api.github.com"); JsonConvert.DefaultSettings = () => new JsonSerializerSettings { ContractResolver = new SnakeCasePropertyNamesContractResolver() }; }
public ServerInstaller(IGitHubApi githubApi) { _githubApi = githubApi; }
public UserService(IGitHubApi gitHubApi) => this.gitHubApi = gitHubApi;
public RequestAddCommentHandler(IConfigurationManager configurationManager, IGitHubApi gitHubApi) { this.configurationManager = configurationManager; this.gitHubApi = gitHubApi; }
public ApiProvider() { _api = new GitHubApi(); }
public GithubService() { apiProxy = RestService.For <IGitHubApi>(apiUrl); }
public GitHubService(IAuthenticationFactory authenticationFactory, IGitHubApi api) { _authenticationFactory = authenticationFactory; _api = api; }
public RequestCreateBranchHandler(IConfigurationManager configurationManager, IGitHubApi gitHubApi) { this.configurationManager = configurationManager; this.gitHubApi = gitHubApi; }
public GitHubApiBusiness(IContextRepository context, IGitHubApi gitHubApi) { _context = context; _gitHubApi = gitHubApi; }
IObservable<GitHubOrgInfo> getUserAsOrgInfo(IGitHubApi api) { return api.GetCurrentUser() .Select( x => new GitHubOrgInfo() {login = x.login, avatar_url = x.avatar_url, url = x.url}); }