Skip to content

Commit 9465d46

Browse files
update README to include requester arg to both concrete GitHubAPI classes (#68)
1 parent 45f1f8a commit 9465d46

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

README.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,10 @@ For Django projects running with ASGI or in async views, the async client provid
331331
from django_github_app.github import AsyncGitHubAPI
332332
from django_github_app.models import Installation
333333
334+
334335
# Access public endpoints without authentication
335336
async def get_public_repo():
336-
async with AsyncGitHubAPI() as gh:
337+
async with AsyncGitHubAPI("example-github-app") as gh:
337338
return await gh.getitem("/repos/django/django")
338339
339340
@@ -344,14 +345,16 @@ async def create_comment(repo_full_name: str):
344345
repositories__full_name=repo_full_name
345346
)
346347
347-
async with AsyncGitHubAPI(installation_id=installation.installation_id) as gh:
348+
async with AsyncGitHubAPI(
349+
"example-github-app", installation_id=installation.installation_id
350+
) as gh:
348351
await gh.post(
349352
f"/repos/{repo_full_name}/issues/1/comments", data={"body": "Hello!"}
350353
)
351354
352355
# You can either provide the `installation_id` as above, or the `Installation` instance
353356
# itself
354-
async with AsyncGitHubAPI(installation=installation) as gh:
357+
async with AsyncGitHubAPI("example-github-app", installation=installation) as gh:
355358
await gh.post(
356359
f"/repos/{repo_full_name}/issues/1/comments", data={"body": "World!"}
357360
)
@@ -365,9 +368,10 @@ For traditional Django applications running under WSGI, the sync client provides
365368
from django_github_app.github import SyncGitHubAPI
366369
from django_github_app.models import Installation
367370
371+
368372
# Access public endpoints without authentication
369373
def get_public_repo_sync():
370-
with SyncGitHubAPI() as gh:
374+
with SyncGitHubAPI("example-github-app") as gh:
371375
return gh.getitem("/repos/django/django")
372376
373377
@@ -376,12 +380,14 @@ def create_comment_sync(repo_full_name: str):
376380
# Get the installation for the repository
377381
installation = Installation.objects.get(repositories__full_name=repo_full_name)
378382
379-
with SyncGitHubAPI(installation_id=installation.installation_id) as gh:
383+
with SyncGitHubAPI(
384+
"example-github-app", installation_id=installation.installation_id
385+
) as gh:
380386
gh.post(f"/repos/{repo_full_name}/issues/1/comments", data={"body": "Hello!"})
381387
382388
# You can either provide the `installation_id` as above, or the `Installation` instance
383389
# itself
384-
with SyncGitHubAPI(installation=installation) as gh:
390+
with SyncGitHubAPI("example-github-app", installation=installation) as gh:
385391
gh.post(f"/repos/{repo_full_name}/issues/1/comments", data={"body": "World!"})
386392
```
387393

0 commit comments

Comments
 (0)