Package com.github.api.v2.services

Examples of com.github.api.v2.services.OAuthServiceTest


  /* (non-Javadoc)
   * @see com.github.api.v2.services.UserService#getUserFollowing(java.lang.String)
   */
  @Override
  public List<String> getUserFollowing(String userName) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.UserApiUrls.GET_USER_FOLLOWING_URL);
        String                apiUrl  = builder.withField(ParameterNames.USER_NAME, userName).buildUrl();
        JsonObject json = unmarshall(callApiGet(apiUrl));
       
        return unmarshall(new TypeToken<List<String>>(){}, json.get("users"));
  }
View Full Code Here


  /* (non-Javadoc)
   * @see com.github.api.v2.services.UserService#getWatchedRepositories(java.lang.String)
   */
  @Override
  public List<Repository> getWatchedRepositories(String userName) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.UserApiUrls.GET_WATCHED_REPOSITORIES_URL);
        String                apiUrl  = builder.withField(ParameterNames.USER_NAME, userName).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.UserService#removeEmail(java.lang.String)
   */
  @Override
  public void removeEmail(String email) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.UserApiUrls.REMOVE_EMAIL_URL);
        String                apiUrl  = builder.buildUrl();
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put(ParameterNames.EMAIL, email);
    callApiPost(apiUrl, parameters);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.github.api.v2.services.UserService#removeKey(java.lang.String)
   */
  @Override
  public void removeKey(String id) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.UserApiUrls.REMOVE_KEY_URL);
        String                apiUrl  = builder.buildUrl();
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put(ParameterNames.ID, id);
    callApiPost(apiUrl, parameters);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.github.api.v2.services.UserService#getUserByEmail(java.lang.String)
   */
  @Override
  public User getUserByEmail(String email) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.UserApiUrls.SEARCH_USERS_BY_EMAIL_URL);
        String                apiUrl  = builder.withField(ParameterNames.EMAIL, email).buildUrl();
        JsonObject json = unmarshall(callApiGet(apiUrl));
       
        return unmarshall(new TypeToken<User>(){}, json.get("user"));
  }
View Full Code Here

  /* (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

TOP

Related Classes of com.github.api.v2.services.OAuthServiceTest

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.