def get(self, request, provider=None): social_token = get_integration_token(request.user, provider, task=request.GET.get('task')) if not social_token: return Response({'status': 'Unauthorized'}, status.HTTP_401_UNAUTHORIZED) if provider == GitHubProvider.id: r = github.api(endpoint='/user/issues', method='get', params={'filter': 'all'}, access_token=social_token.token) if r.status_code == 200: issues = [] for issue in r.json(): if 'pull_request' in issue: continue # Github returns both issues and pull requests from this endpoint issue_info = {} for key in github.ISSUE_FIELDS: if key == 'repository': issue_info[key] = github.extract_repo_info( issue[key]) else: issue_info[key] = issue[key] issues.append(issue_info) return Response(issues) return Response(r.json(), r.status_code) return Response({'status': 'Not implemented'}, status.HTTP_501_NOT_IMPLEMENTED)
def get(self, request, provider=None): social_token = get_integration_token(request.user, provider, task=request.GET.get('task')) if not social_token: return Response({'status': 'Unauthorized'}, status.HTTP_401_UNAUTHORIZED) if provider == GitHubProvider.id: r = github.api(endpoint='/user/repos', method='get', access_token=social_token.token) if r.status_code == 200: repos = [github.extract_repo_info(repo) for repo in r.json()] return Response(repos) return Response(r.json(), r.status_code) return Response({'status': 'Not implemented'}, status.HTTP_501_NOT_IMPLEMENTED)
def get(self, request, provider=None): social_token = get_integration_token(request.user, provider, task=request.GET.get('task')) if not social_token: return Response({'status': 'Unauthorized'}, status.HTTP_401_UNAUTHORIZED) if provider == GitHubProvider.id: r = github.api(endpoint='/user/repos', method='get', access_token=social_token.token) if r.status_code == 200: repos = [github.extract_repo_info(repo) for repo in r.json()] return Response(repos) return Response(r.json(), r.status_code) return Response({'status': 'Not implemented'}, status.HTTP_501_NOT_IMPLEMENTED)
def get(self, request, provider=None): social_token = get_social_token(user=request.user, provider=provider) if not social_token: return Response({'status': 'Unauthorized'}, status.HTTP_401_UNAUTHORIZED) if provider == 'github': r = github.api(endpoint='/user/issues', method='get', params={'filter': 'all'}, access_token=social_token.token) if r.status_code == 200: issues = [] for issue in r.json(): if 'pull_request' in issue: continue # Github returns both issues and pull requests from this endpoint issue_info = {} for key in ISSUE_FIELDS: if key == 'repository': issue_info[key] = extract_repo_info(issue[key]) else: issue_info[key] = issue[key] issues.append(issue_info) return Response(issues) return Response(r.json(), r.status_code) return Response({'status': 'Not implemented'}, status.HTTP_501_NOT_IMPLEMENTED)