Package com.github.api.v2.services.constant.GitHubApiUrls

Examples of com.github.api.v2.services.constant.GitHubApiUrls.GitHubApiUrlBuilder


  /* (non-Javadoc)
   * @see com.github.api.v2.services.UserService#searchUsersByName(java.lang.String)
   */
  @Override
  public List<User> searchUsersByName(String name) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.UserApiUrls.SEARCH_USERS_BY_NAME_URL);
        String                apiUrl  = builder.withField(ParameterNames.USER_NAME, name).buildUrl();
        JsonObject json = unmarshall(callApiGet(apiUrl));
       
    Gson gson = getGsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").create();
    return gson.fromJson(json.get("users"), new TypeToken<List<User>>(){}.getType());
  }
View Full Code Here


    /* (non-Javadoc)
     * @see com.google.code.facebook.graph.client.oauth.FacebookOAuthService#getAuthorizationUrl(java.lang.String)
     */
    @Override
  public String getAuthorizationUrl(String callBackUrl) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.OAuthUrls.AUTHORIZE_URL);
    builder.withParameter(ParameterNames.CLIENT_ID, clientId).withParameter(ParameterNames.REDIRECT_URI, callBackUrl);
    return builder.buildUrl();
  }
View Full Code Here

   * @see com.google.code.facebook.graph.client.oauth.FacebookOAuthService#getAuthorizationUrl(java.lang.String, java.util.Set)
   */
  @Override
  public String getAuthorizationUrl(String callBackUrl,
      Set<Scope> permissions) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.OAuthUrls.AUTHORIZE_URL);
    builder.withParameter(ParameterNames.CLIENT_ID, clientId).withParameter(ParameterNames.REDIRECT_URI, callBackUrl);
    builder.withParameterEnumSet(ParameterNames.SCOPE, permissions, ",");
    return builder.buildUrl();
  }
View Full Code Here

     * @see com.google.code.facebook.graph.client.oauth.FacebookOAuthService#getAccessToken(java.lang.String, java.lang.String)
     */
    @Override
  public String getAccessToken(String callBackUrl, String code) {
      try {
        GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.OAuthUrls.ACCESS_TOKEN_URL);
        builder.withParameter(ParameterNames.CLIENT_ID, clientId);
        builder.withParameter(ParameterNames.CLIENT_SECRET, secret);
        builder.withParameter(ParameterNames.REDIRECT_URI, callBackUrl);
        builder.withParameter(ParameterNames.CODE, code);
       
      String response = convertStreamToString(callApiGet(builder.buildUrl()));
      Matcher matcher = ApplicationConstants.ACCESS_TOKEN_PATTERN.matcher(response);
      if (matcher.find()) {
              return matcher.group(1);
            } else {
              throw new GitHubException(response);
View Full Code Here

  /* (non-Javadoc)
   * @see com.github.api.v2.services.RepositoryService#searchRepositories(java.lang.String, com.github.api.v2.schema.Language)
   */
  @Override
  public List<Repository> searchRepositories(String query, Language language) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.RepositoryApiUrls.SEARCH_REPOSITORIES_URL);
        String                apiUrl  = builder.withField(ParameterNames.KEYWORD, query).withParameterEnum(ParameterNames.LANGUAGE, language).buildUrl();
        JsonObject json = unmarshall(callApiGet(apiUrl));
       
        return unmarshall(new TypeToken<List<Repository>>(){}, json.get("repositories"));
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.github.api.v2.services.RepositoryService#searchRepositories(java.lang.String, int)
   */
  @Override
  public List<Repository> searchRepositories(String query, int pageNumber) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.RepositoryApiUrls.SEARCH_REPOSITORIES_URL);
        String                apiUrl  = builder.withField(ParameterNames.KEYWORD, query).withParameter(ParameterNames.START_PAGE, String.valueOf(pageNumber)).buildUrl();
        JsonObject json = unmarshall(callApiGet(apiUrl));
       
        return unmarshall(new TypeToken<List<Repository>>(){}, json.get("repositories"));
  }
View Full Code Here

   * @see com.github.api.v2.services.RepositoryService#searchRepositories(java.lang.String, com.github.api.v2.schema.Language, int)
   */
  @Override
  public List<Repository> searchRepositories(String query, Language language,
      int pageNumber) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.RepositoryApiUrls.SEARCH_REPOSITORIES_URL);
        String                apiUrl  = builder.withField(ParameterNames.KEYWORD, query).withParameterEnum(ParameterNames.LANGUAGE, language).withParameter(ParameterNames.START_PAGE, String.valueOf(pageNumber)).buildUrl();
        JsonObject json = unmarshall(callApiGet(apiUrl));
       
        return unmarshall(new TypeToken<List<Repository>>(){}, json.get("repositories"));
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.github.api.v2.services.RepositoryService#unwatchRepository(java.lang.String, java.lang.String)
   */
  @Override
  public void unwatchRepository(String userName, String repositoryName) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.RepositoryApiUrls.UNWATCH_REPOSITORY_URL);
        String                apiUrl  = builder.withField(ParameterNames.USER_NAME, userName).withField(ParameterNames.REPOSITORY_NAME, repositoryName).buildUrl();
        unmarshall(callApiPost(apiUrl, new HashMap<String, String>()));
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.github.api.v2.services.RepositoryService#updateRepository(com.github.api.v2.schema.Repository)
   */
  @Override
  public void updateRepository(Repository repository) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.RepositoryApiUrls.UPDATE_REPOSITORY_URL);
        String                apiUrl  = builder.withField(ParameterNames.USER_NAME, repository.getOwner()).withField(ParameterNames.REPOSITORY_NAME, repository.getName()).buildUrl();
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("values[" + ParameterNames.DESCRIPTION + "]", repository.getDescription());
        parameters.put("values[" + ParameterNames.HOME_PAGE + "]", repository.getHomepage());
        parameters.put("values[" + ParameterNames.HAS_WIKI + "]", String.valueOf(repository.isHasWiki()));
        parameters.put("values[" + ParameterNames.HAS_ISSUES + "]", String.valueOf(repository.isHasIssues()));
View Full Code Here

  /* (non-Javadoc)
   * @see com.github.api.v2.services.RepositoryService#watchRepository(java.lang.String, java.lang.String)
   */
  @Override
  public void watchRepository(String userName, String repositoryName) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.RepositoryApiUrls.WATCH_REPOSITORY_URL);
        String                apiUrl  = builder.withField(ParameterNames.USER_NAME, userName).withField(ParameterNames.REPOSITORY_NAME, repositoryName).buildUrl();
        unmarshall(callApiPost(apiUrl, new HashMap<String, String>()));
  }
View Full Code Here

TOP

Related Classes of com.github.api.v2.services.constant.GitHubApiUrls.GitHubApiUrlBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.