def get_feed(self, entity, isorg): if not isorg: return build_call("get", "users/" + entity + "/received_events", self.requester, self.authstring, {}, self.istoken) else: return build_call("get", "orgs/" + entity + "/events", self.requester, self.authstring, {}, self.istoken)
def new_trending(self, days): st = datetime.datetime.fromtimestamp( time.time()) - datetime.timedelta(days=days) st = st.strftime('%Y-%m-%dT%H:%M:%S') params = { 'q': 'created:>' + st, 'sort': 'stars', 'order': 'desc', 'per_page': 25 } return build_call("get", "search/repositories", self.requester, self.authstring, params, self.istoken)
def get_token(self, clientid, clientsecret, scopes = []): options = { 'note': "get-me-token", 'client_id': clientid,'client_secret': clientsecret,'fingerprint': self.authbearer["login"], 'scopes': scopes} if self.istoken: return self.authstring else: r = build_call("post", "authorizations", self.authbearer["login"], self.authstring, options) try: self.authstring = r['token'] self.istoken = True return self.authstring except: return "You already have a token corresponding to this app!"
def get_notifs(self): return build_call("get", "notifications", self.requester, self.authstring, {}, self.istoken)
def repo_notif(self, owner, name): return build_call("get", "repos/" + owner + "/" + name + "/notifications", self.requester, self.authstring, {}, self.istoken)
def __init__(self, username, authstring, token = False): self.authstring = authstring self.istoken = token self.authbearer = build_call("get", "user", username, authstring, {}, token)
def my_followers(self): return build_call("get", "user/followers", self.requester, self.authstring, {}, self.istoken)
def get_following(self, username): return build_call("get", "users/" + username + "/following", self.requester, self.authstring, {}, self.istoken)
def get_stargazers(self, owner, name): return build_call("get", "repos/" + owner + "/" + name + "/stargazers", self.requester, self.authstring, {}, self.istoken)
def unstar_it(self, owner, name): return build_call("delete", "user/starred/" + owner + "/" + name, self.requester, self.authstring, {}, self.istoken)