Class: Githubgrab::Gateway

Inherits:
Object
  • Object
show all
Defined in:
lib/githubgrab/gateway.rb

Class Method Summary collapse

Class Method Details

.call(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/githubgrab/gateway.rb', line 7

def self.call args
  begin 
    response = RestClient.get "https://api.github.com/search/repositories?q=#{args.join('+')}"
    {body: response.body, code: response.code.to_i}
  rescue RestClient::ExceptionWithResponse => e
    {body:  e.response, code: 1000}
  rescue SocketError
    {body:  'Network connectivity issue, please check your network', code: 1001} 
  end
end