diff --git a/github/apps_marketplace.go b/github/apps_marketplace.go index 3f35b915576..6dd568a2dc0 100644 --- a/github/apps_marketplace.go +++ b/github/apps_marketplace.go @@ -27,36 +27,52 @@ type MarketplaceService struct { // MarketplacePlan represents a GitHub Apps Marketplace Listing Plan. type MarketplacePlan struct { - URL *string `json:"url,omitempty"` - AccountsURL *string `json:"accounts_url,omitempty"` - ID *int64 `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Description *string `json:"description,omitempty"` - MonthlyPriceInCents *int `json:"monthly_price_in_cents,omitempty"` - YearlyPriceInCents *int `json:"yearly_price_in_cents,omitempty"` - PriceModel *string `json:"price_model,omitempty"` - UnitName *string `json:"unit_name,omitempty"` - Bullets *[]string `json:"bullets,omitempty"` + URL *string `json:"url,omitempty"` + AccountsURL *string `json:"accounts_url,omitempty"` + ID *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + MonthlyPriceInCents *int `json:"monthly_price_in_cents,omitempty"` + YearlyPriceInCents *int `json:"yearly_price_in_cents,omitempty"` + // The pricing model for this listing. Can be one of "flat-rate", "per-unit", or "free". + PriceModel *string `json:"price_model,omitempty"` + UnitName *string `json:"unit_name,omitempty"` + Bullets *[]string `json:"bullets,omitempty"` + // State can be one of the values "draft" or "published". + State *string `json:"state,omitempty"` + HasFreeTrial *bool `json:"has_free_trial,omitempty"` } // MarketplacePurchase represents a GitHub Apps Marketplace Purchase. type MarketplacePurchase struct { + // BillingCycle can be one of the values "yearly", "monthly" or nil. BillingCycle *string `json:"billing_cycle,omitempty"` - NextBillingDate *string `json:"next_billing_date,omitempty"` + NextBillingDate *Timestamp `json:"next_billing_date,omitempty"` UnitCount *int `json:"unit_count,omitempty"` Plan *MarketplacePlan `json:"plan,omitempty"` Account *MarketplacePlanAccount `json:"account,omitempty"` + OnFreeTrial *bool `json:"on_free_trial,omitempty"` + FreeTrialEndsOn *Timestamp `json:"free_trial_ends_on,omitempty"` +} + +// MarketplacePendingChange represents a pending change to a GitHub Apps Marketplace Plan. +type MarketplacePendingChange struct { + EffectiveDate *Timestamp `json:"effective_date,omitempty"` + UnitCount *int `json:"unit_count,omitempty"` + ID *int64 `json:"id,omitempty"` + Plan *MarketplacePlan `json:"plan,omitempty"` } // MarketplacePlanAccount represents a GitHub Account (user or organization) on a specific plan. type MarketplacePlanAccount struct { - URL *string `json:"url,omitempty"` - Type *string `json:"type,omitempty"` - ID *int64 `json:"id,omitempty"` - Login *string `json:"login,omitempty"` - Email *string `json:"email,omitempty"` - OrganizationBillingEmail *string `json:"organization_billing_email,omitempty"` - MarketplacePurchase *MarketplacePurchase `json:"marketplace_purchase,omitempty"` + URL *string `json:"url,omitempty"` + Type *string `json:"type,omitempty"` + ID *int64 `json:"id,omitempty"` + Login *string `json:"login,omitempty"` + Email *string `json:"email,omitempty"` + OrganizationBillingEmail *string `json:"organization_billing_email,omitempty"` + MarketplacePurchase *MarketplacePurchase `json:"marketplace_purchase,omitempty"` + MarketplacePendingChange *MarketplacePendingChange `json:"marketplace_pending_change,omitempty"` } // ListPlans lists all plans for your Marketplace listing. @@ -155,7 +171,6 @@ func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context if err != nil { return nil, resp, err } - return purchases, resp, nil } diff --git a/github/apps_marketplace_test.go b/github/apps_marketplace_test.go index 0c1f86c7c00..e293c83a16d 100644 --- a/github/apps_marketplace_test.go +++ b/github/apps_marketplace_test.go @@ -111,7 +111,7 @@ func TestMarketplaceService_ListPlanAccountsForAccount(t *testing.T) { mux.HandleFunc("/marketplace_listing/accounts/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `[{"id":1}]`) + fmt.Fprint(w, `[{"id":1, "marketplace_pending_change": {"id": 77}}]`) }) opt := &ListOptions{Page: 1, PerPage: 2} @@ -121,7 +121,7 @@ func TestMarketplaceService_ListPlanAccountsForAccount(t *testing.T) { t.Errorf("Marketplace.ListPlanAccountsForAccount returned error: %v", err) } - want := []*MarketplacePlanAccount{{ID: Int64(1)}} + want := []*MarketplacePlanAccount{{ID: Int64(1), MarketplacePendingChange: &MarketplacePendingChange{ID: Int64(77)}}} if !reflect.DeepEqual(accounts, want) { t.Errorf("Marketplace.ListPlanAccountsForAccount returned %+v, want %+v", accounts, want) } diff --git a/github/event_types.go b/github/event_types.go index 1792f43c732..d3f7d332025 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -308,7 +308,7 @@ type LabelEvent struct { // Github API docs: https://developer.github.com/v3/activity/events/types/#marketplacepurchaseevent type MarketplacePurchaseEvent struct { // Action is the action that was performed. Possible values are: - // "purchased", "cancelled", "changed". + // "purchased", "cancelled", "pending_change", "pending_change_cancelled", "changed". Action *string `json:"action,omitempty"` // The following fields are only populated by Webhook events. diff --git a/github/github-accessors.go b/github/github-accessors.go index 62573892958..4791098b0b3 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4644,6 +4644,38 @@ func (l *ListCheckSuiteResults) GetTotal() int { return *l.Total } +// GetEffectiveDate returns the EffectiveDate field if it's non-nil, zero value otherwise. +func (m *MarketplacePendingChange) GetEffectiveDate() Timestamp { + if m == nil || m.EffectiveDate == nil { + return Timestamp{} + } + return *m.EffectiveDate +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (m *MarketplacePendingChange) GetID() int64 { + if m == nil || m.ID == nil { + return 0 + } + return *m.ID +} + +// GetPlan returns the Plan field. +func (m *MarketplacePendingChange) GetPlan() *MarketplacePlan { + if m == nil { + return nil + } + return m.Plan +} + +// GetUnitCount returns the UnitCount field if it's non-nil, zero value otherwise. +func (m *MarketplacePendingChange) GetUnitCount() int { + if m == nil || m.UnitCount == nil { + return 0 + } + return *m.UnitCount +} + // GetAccountsURL returns the AccountsURL field if it's non-nil, zero value otherwise. func (m *MarketplacePlan) GetAccountsURL() string { if m == nil || m.AccountsURL == nil { @@ -4668,6 +4700,14 @@ func (m *MarketplacePlan) GetDescription() string { return *m.Description } +// GetHasFreeTrial returns the HasFreeTrial field if it's non-nil, zero value otherwise. +func (m *MarketplacePlan) GetHasFreeTrial() bool { + if m == nil || m.HasFreeTrial == nil { + return false + } + return *m.HasFreeTrial +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (m *MarketplacePlan) GetID() int64 { if m == nil || m.ID == nil { @@ -4700,6 +4740,14 @@ func (m *MarketplacePlan) GetPriceModel() string { return *m.PriceModel } +// GetState returns the State field if it's non-nil, zero value otherwise. +func (m *MarketplacePlan) GetState() string { + if m == nil || m.State == nil { + return "" + } + return *m.State +} + // GetUnitName returns the UnitName field if it's non-nil, zero value otherwise. func (m *MarketplacePlan) GetUnitName() string { if m == nil || m.UnitName == nil { @@ -4748,6 +4796,14 @@ func (m *MarketplacePlanAccount) GetLogin() string { return *m.Login } +// GetMarketplacePendingChange returns the MarketplacePendingChange field. +func (m *MarketplacePlanAccount) GetMarketplacePendingChange() *MarketplacePendingChange { + if m == nil { + return nil + } + return m.MarketplacePendingChange +} + // GetMarketplacePurchase returns the MarketplacePurchase field. func (m *MarketplacePlanAccount) GetMarketplacePurchase() *MarketplacePurchase { if m == nil { @@ -4796,14 +4852,30 @@ func (m *MarketplacePurchase) GetBillingCycle() string { return *m.BillingCycle } +// GetFreeTrialEndsOn returns the FreeTrialEndsOn field if it's non-nil, zero value otherwise. +func (m *MarketplacePurchase) GetFreeTrialEndsOn() Timestamp { + if m == nil || m.FreeTrialEndsOn == nil { + return Timestamp{} + } + return *m.FreeTrialEndsOn +} + // GetNextBillingDate returns the NextBillingDate field if it's non-nil, zero value otherwise. -func (m *MarketplacePurchase) GetNextBillingDate() string { +func (m *MarketplacePurchase) GetNextBillingDate() Timestamp { if m == nil || m.NextBillingDate == nil { - return "" + return Timestamp{} } return *m.NextBillingDate } +// GetOnFreeTrial returns the OnFreeTrial field if it's non-nil, zero value otherwise. +func (m *MarketplacePurchase) GetOnFreeTrial() bool { + if m == nil || m.OnFreeTrial == nil { + return false + } + return *m.OnFreeTrial +} + // GetPlan returns the Plan field. func (m *MarketplacePurchase) GetPlan() *MarketplacePlan { if m == nil {