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

Support MarketeplacePurchaseEvent #789

Merged
merged 6 commits into from Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions github/activity_events.go
Expand Up @@ -56,6 +56,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) {
payload = &IssuesEvent{}
case "LabelEvent":
payload = &LabelEvent{}
case "MarketplacePurchaseEvent":
payload = &MarketplacePurchaseEvent{}
case "MemberEvent":
payload = &MemberEvent{}
case "MembershipEvent":
Expand Down
18 changes: 18 additions & 0 deletions github/event_types.go
Expand Up @@ -268,6 +268,24 @@ type LabelEvent struct {
Installation *Installation `json:"installation,omitempty"`
}

// MarketplacePurchaseEvent is triggered when a user purchases, cancels, or changes
// their GitHub Marketplace plan.
// Webhook event name "marketplace_purchase".
//
// 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".
Action *string `json:"action,omitempty"`

// The following fields are only populated by Webhook events.
EffectiveDate *Timestamp `json:"effective_date,omitempty"`
MarketplacePurchase *MarketplacePurchase `json:"marketplace_purchase,omitempty"`
PreviousMarketplacePurchase *MarketplacePurchase `json:"previous_marketplace_purchase,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
}

// MemberEvent is triggered when a user is added as a collaborator to a repository.
// The Webhook event name is "member".
//
Expand Down
48 changes: 48 additions & 0 deletions github/github-accessors.go

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

1 change: 1 addition & 0 deletions github/messages.go
Expand Up @@ -53,6 +53,7 @@ var (
"issue_comment": "IssueCommentEvent",
"issues": "IssuesEvent",
"label": "LabelEvent",
"marketplace_purchase": "MarketplacePurchaseEvent",
"member": "MemberEvent",
"membership": "MembershipEvent",
"milestone": "MilestoneEvent",
Expand Down
4 changes: 4 additions & 0 deletions github/messages_test.go
Expand Up @@ -210,6 +210,10 @@ func TestParseWebHook(t *testing.T) {
payload: &LabelEvent{},
messageType: "label",
},
{
payload: &MarketplacePurchaseEvent{},
messageType: "marketplace_purchase",
},
{
payload: &MemberEvent{},
messageType: "member",
Expand Down