-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path__init__.py
More file actions
28 lines (22 loc) · 906 Bytes
/
__init__.py
File metadata and controls
28 lines (22 loc) · 906 Bytes
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
import logging
log = logging.getLogger("socketdev")
# TODO: Add response type classes for NPM endpoints
class NPM:
def __init__(self, api):
self.api = api
def issues(self, package: str, version: str) -> list:
path = f"npm/{package}/{version}/issues"
response = self.api.do_request(path=path)
if response.status_code == 200:
return response.json()
log.error(f"Error getting npm issues: {response.status_code}")
log.error(response.text)
return []
def score(self, package: str, version: str) -> list:
path = f"npm/{package}/{version}/score"
response = self.api.do_request(path=path)
if response.status_code == 200:
return response.json()
log.error(f"Error getting npm score: {response.status_code}")
log.error(response.text)
return []