Skip to content

Commit

Permalink
Add support for MarketplacePurchaseEvent. (google#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptonist authored and dmitshur committed Nov 22, 2017
1 parent 7c5e56e commit 3f4e092
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
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

0 comments on commit 3f4e092

Please sign in to comment.