class UserHttpHandler

Public Class Methods

get_auth_token() click to toggle source
# File lib/github_api_ruby_lib/http/user_http_handler.rb, line 25
def self.get_auth_token
  @@app_token
end
new() click to toggle source
# File lib/github_api_ruby_lib/http/user_http_handler.rb, line 12
def initialize
  @response_status=false
  @uri_builder=UriBuilder.new
end
set_auth_token(token) click to toggle source

Set the authentication token

Attribute

  • token -> token generated that is needed to make authentication calls

# File lib/github_api_ruby_lib/http/user_http_handler.rb, line 21
def self.set_auth_token (token)
  @@app_token=token
end

Public Instance Methods

get_response_status() click to toggle source

returns the response status that is true if request was successful

# File lib/github_api_ruby_lib/http/user_http_handler.rb, line 94
def get_response_status
  @response_status
end
get_user_followers(params) { |JSON| ... } click to toggle source

get all the followers of the given user

Attributes

  • params -> optional parameters for getting followers

# File lib/github_api_ruby_lib/http/user_http_handler.rb, line 32
def get_user_followers(params) # :yields: JSON
  uri=URI.parse(@uri_builder.get_user_contents(Api_options::USER::FOLLOWERS,username:params[:username], token:@@app_token))
  http=HttpHandler.initiate_http(uri)
  begin
    if @@app_token == nil
      raise "Authentication not provided"
    end
    response=HttpHandler.get_response(http,uri)
  rescue ArgumentError
    puts "Request failed with code: #{response.code}"
  else
    @response_status=true
    return response
  end
end
search_for_user(params) { |JSON| ... } click to toggle source

Search and retrieve user information based on search parameters

Attributes

  • params -> optional filters for getting users

# File lib/github_api_ruby_lib/http/user_http_handler.rb, line 53
def search_for_user(params) # :yields: JSON
  uri=URI.parse(@uri_builder.get_user_contents(Api_options::USER::SEARCH, params))
  http=HttpHandler.initiate_http(uri)
  begin
    response=HttpHandler.get_response(http,uri)
  rescue ArgumentError
    puts "Request failed with code: #{response.code}"
  else
    @response_status=true
    return response
  end
end
search_for_user_email(username) { |JSON| ... } click to toggle source

Search for email address of user

Attributes

  • username -> username id to get email

# File lib/github_api_ruby_lib/http/user_http_handler.rb, line 71
def search_for_user_email(username) # :yields: JSON
  begin
  if @@app_token == nil
    raise "Authentication not provided"
  end
  uri=URI.parse(@uri_builder.get_user_contents(Api_options::USER::EMAIL,username:username, app_token:@@app_token))
  @uri_builder=nil

  HttpHandler.create_http uri

  response=HttpHandler.get_response(@@http,uri)
    @response_status=true
    return response

end





end