-
Notifications
You must be signed in to change notification settings - Fork 14
/
github.rb
41 lines (33 loc) · 1.16 KB
/
github.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'json'
require './network_utils'
class Github
include NetworkUtils
def self.prepare_gh_key_pair
params = {
"client_id" => ENV["GH_KEY_PAIR_ID"],
"client_secret" => ENV["GH_KEY_PAIR_SECRET"]
}
params
end
def self.get_sheets branch_name
sheet_folder_uri = "https://api.github.com/repos/secreek/drinkup/contents/sheets"
params = self.prepare_gh_key_pair
params["ref"] = branch_name
return NetworkUtils.do_request_returning_json sheet_folder_uri, params
end
def self.get_raw_content branch_name, path
content_uri = "https://raw.github.com/secreek/drinkup/#{branch_name}/#{path}"
params = self.prepare_gh_key_pair
return NetworkUtils.do_request_returning_json content_uri, params
end
def self.get_user_info_from_id inner_id
user_uri = "https://api.github.com/user/" + inner_id
params = self.prepare_gh_key_pair
return NetworkUtils.do_request_returning_json user_uri, params
end
def self.get_user_info_from_login login
user_uri = "https://api.github.com/users/" + login
params = self.prepare_gh_key_pair
return NetworkUtils.do_request_returning_json user_uri, params
end
end