-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#720 Initial commit for listing Plans and Plan Accounts #732
Changes from 4 commits
9901531
9157290
2fb4833
6ac3c7e
6c4b54e
bb51e74
f9251be
354464d
46617e6
c4466d1
f2b216a
ecac90f
24610dd
b8f7249
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2013 The go-github AUTHORS. All rights reserved. | ||
// Copyright 2017 The go-github AUTHORS. All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
@@ -20,8 +20,6 @@ type MarketplaceService struct { | |
// instead of production endpoints. Stubbed data is fake data that's useful | ||
// for testing your GitHub Apps. Stubbed data is hard-coded and will not | ||
// change based on actual subscriptions. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/apps/marketplace/ | ||
Stubbed bool | ||
} | ||
|
||
|
@@ -41,17 +39,17 @@ type MarketplacePlan struct { | |
|
||
// MarketplacePurchase represents a GitHub Apps Marketplace Purchase. | ||
type MarketplacePurchase struct { | ||
BillingCycle *string `json:"billing_cycle,omitempty"` | ||
NextBillingDate *string `json:"next_billing_date,omitempty"` | ||
UnitCount *int `json:"unit_count,omitempty"` | ||
Plan *MarketplacePlan `json:"plan,omitempty"` | ||
MarketplacePlanAccount *MarketplacePlanAccount `json:"account,omitempty"` | ||
BillingCycle *string `json:"billing_cycle,omitempty"` | ||
NextBillingDate *string `json:"next_billing_date,omitempty"` | ||
UnitCount *int `json:"unit_count,omitempty"` | ||
Plan *MarketplacePlan `json:"plan,omitempty"` | ||
Account *MarketplacePlanAccount `json:"account,omitempty"` | ||
} | ||
|
||
// MarketplacePlanAccount represents a GitHub Account (user or organization) on a specific plan. | ||
type MarketplacePlanAccount struct { | ||
URL *string `json:"url,omitempty"` | ||
AccountType *string `json:"type,omitempty"` | ||
Type *string `json:"type,omitempty"` | ||
ID *int `json:"id,omitempty"` | ||
Login *string `json:"login,omitempty"` | ||
Email *string `json:"email,omitempty"` | ||
|
@@ -77,13 +75,13 @@ func (s *MarketplaceService) ListPlans(ctx context.Context, opt *ListOptions) ([ | |
// TODO: remove custom Accept header when this API fully launches. | ||
req.Header.Set("Accept", mediaTypeMarketplacePreview) | ||
|
||
var i []*MarketplacePlan | ||
resp, err := s.client.Do(ctx, req, &i) | ||
var plans []*MarketplacePlan | ||
resp, err := s.client.Do(ctx, req, &plans) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return i, resp, nil | ||
return plans, resp, nil | ||
} | ||
|
||
// ListPlanAccountsForPlan lists all GitHub accounts (user or organization) on a specific plan. | ||
|
@@ -104,13 +102,13 @@ func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID | |
// TODO: remove custom Accept header when this API fully launches. | ||
req.Header.Set("Accept", mediaTypeMarketplacePreview) | ||
|
||
var i []*MarketplacePlanAccount | ||
resp, err := s.client.Do(ctx, req, &i) | ||
var accounts []*MarketplacePlanAccount | ||
resp, err := s.client.Do(ctx, req, &accounts) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return i, resp, nil | ||
return accounts, resp, nil | ||
} | ||
|
||
// ListPlanAccountsForAccount lists all GitHub accounts (user or organization) associated with an account. | ||
|
@@ -131,13 +129,13 @@ func (s *MarketplaceService) ListPlanAccountsForAccount(ctx context.Context, acc | |
// TODO: remove custom Accept header when this API fully launches. | ||
req.Header.Set("Accept", mediaTypeMarketplacePreview) | ||
|
||
var i []*MarketplacePlanAccount | ||
resp, err := s.client.Do(ctx, req, &i) | ||
var accounts []*MarketplacePlanAccount | ||
resp, err := s.client.Do(ctx, req, &accounts) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return i, resp, nil | ||
return accounts, resp, nil | ||
} | ||
|
||
// ListMarketplacePurchasesForUser lists all GitHub marketplace purchases made by a user. | ||
|
@@ -162,13 +160,13 @@ func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context | |
// TODO: remove custom Accept header when this API fully launches. | ||
req.Header.Set("Accept", mediaTypeMarketplacePreview) | ||
|
||
var i []*MarketplacePurchase | ||
resp, err := s.client.Do(ctx, req, &i) | ||
var purchaces []*MarketplacePurchase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: s/purchaces/purchases/ |
||
resp, err := s.client.Do(ctx, req, &purchaces) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return i, resp, nil | ||
return purchaces, resp, nil | ||
} | ||
|
||
func (s *MarketplaceService) marketplaceURI(endpoint string) string { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,9 @@ const ( | |
|
||
// https://developer.github.com/v3/apps/marketplace/ | ||
mediaTypeMarketplacePreview = "application/vnd.github.valkyrie-preview+json" | ||
|
||
// https://developer.github.com/changes/2017-08-30-preview-nested-teams/ | ||
mediaTypeNestedTeamsPreview = "application/vnd.github.hellcat-preview+json" | ||
) | ||
|
||
// A Client manages communication with the GitHub API. | ||
|
@@ -136,17 +139,17 @@ type Client struct { | |
Gists *GistsService | ||
Git *GitService | ||
Gitignores *GitignoresService | ||
Licenses *LicensesService | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will it ever end... :P Done |
||
Issues *IssuesService | ||
Marketplace *MarketplaceService | ||
Migrations *MigrationService | ||
Organizations *OrganizationsService | ||
Projects *ProjectsService | ||
PullRequests *PullRequestsService | ||
Reactions *ReactionsService | ||
Repositories *RepositoriesService | ||
Search *SearchService | ||
Users *UsersService | ||
Licenses *LicensesService | ||
Migrations *MigrationService | ||
Reactions *ReactionsService | ||
Marketplace *MarketplaceService | ||
} | ||
|
||
type service struct { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
Stubbed
field is quite unusual and may cause people to seek more information about it. I think it's worth it to include a link to GitHub API documentation for it as well here, as I suggested in #732 (comment):This is also a way of us hinting that it's not our own invention specific to
go-github
Go library, but a GitHub API feature.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis Does that sound good to you?
If so, I can apply it and merge. Edit: @lackerman has already pushed ecac90f.