Skip to content
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

Merged
merged 14 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions github/apps_marketplace.go
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.
Expand All @@ -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
Copy link
Member

@dmitshur dmitshur Nov 1, 2017

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):

 // Stubbed controls whether endpoints that return stubbed data are used
 // 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

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.

Copy link
Member

@dmitshur dmitshur Nov 12, 2017

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.

}

Expand All @@ -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"`
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 {
Expand Down
2 changes: 1 addition & 1 deletion github/apps_marketplace_test.go
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.
Expand Down
16 changes: 8 additions & 8 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -136,17 +139,17 @@ type Client struct {
Gists *GistsService
Git *GitService
Gitignores *GitignoresService
Licenses *LicensesService
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Licenses after Issues, please. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 {
Expand Down