mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 10:30:05 +08:00
feat(github.vim): use web#http
api
This commit is contained in:
parent
b47ebda7b5
commit
b4c14f2253
15
bundle/github.vim/autoload/github/api/users.vim
vendored
15
bundle/github.vim/autoload/github/api/users.vim
vendored
@ -1,3 +1,6 @@
|
||||
let s:HTTP = SpaceVim#api#import('web#http')
|
||||
|
||||
|
||||
""
|
||||
" @public
|
||||
" Get all users
|
||||
@ -9,19 +12,19 @@ endfunction
|
||||
|
||||
|
||||
function! github#api#users#starred(user, page) abort
|
||||
let result = system('curl -s https://api.github.com/users/' .
|
||||
let result = s:HTTP.get('https://api.github.com/users/' .
|
||||
\ a:user . '/starred' . '?page=' . a:page)
|
||||
if !v:shell_error
|
||||
return json_decode(result)
|
||||
if result.status ==# 200
|
||||
return json_decode(result.content)
|
||||
endif
|
||||
" if the command run failed, return empty list
|
||||
return []
|
||||
endfunction
|
||||
|
||||
function! github#api#users#starred_pages(user) abort
|
||||
let result = system('curl -si https://api.github.com/users/' . a:user . '/starred')
|
||||
if !v:shell_error
|
||||
let i = filter(split(result, "\n"), 'v:val =~# "^Link"')[0]
|
||||
let result = s:HTTP.get('https://api.github.com/users/' . a:user . '/starred')
|
||||
if result.status ==# 200
|
||||
let i = filter(result.header, 'v:val =~# "^Link"')[0]
|
||||
return split(matchstr(i,'=\d\+',0,2),'=')[0]
|
||||
endif
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user