Getting the organizations of the authenticated user
Assuming your app has the necessary authorization, you can use GetOrganizations
method to request a list of the organizations the authenticated user is a part of:
@using Skybrud.Social.GitHub.Models.Organizations
@using Skybrud.Social.GitHub.Responses.Organizations
@inherits WebViewPage<Skybrud.Social.GitHub.GitHubService>
@{
// Make the request to the API
GitHubGetOrganizationsResponse response = Model.Organizations.GetOrganizations();
// Get the organizations from the response body
GitHubOrganizationItem[] body = response.Body;
// Iterate through the organizations
foreach (GitHubOrganizationItem org in body) {
<p>ID: @org.Id</p>
<p>Login: @org.Login</p>
<br />
}
}
As the response from the GitHub API is a list of organizations, the returned JSON will contain fewer properties for each organizations compared to when requesting a single organization. As a result of this, each organization in the list is represented by the GitHubOrganizationItem
class (opposed to the GitHubOrganizationItem
class when getting a single organization).