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
Conversation
github/event_types.go
Outdated
// Github API docs: https://developer.github.com/v3/activity/events/types/#marketplacepurchaseevent | ||
type MarketplacePurchaseEvent struct { | ||
Action *string `json:"action"` | ||
EffectiveDate *time.Time `json:"effective_date"` |
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.
We don't use time.Time
directly in go-github, we have a custom Timestamp
type defined that handles some inconsistencies in time formatting on GitHub API side:
We should use it here, primarily for consistency. For example, see:
go-github/github/event_types.go
Lines 583 to 585 in 471e67c
CreatedAt *Timestamp `json:"created_at,omitempty"` | |
PushedAt *Timestamp `json:"pushed_at,omitempty"` | |
UpdatedAt *Timestamp `json:"updated_at,omitempty"` |
go-github/github/event_types.go
Lines 670 to 671 in 471e67c
CreatedAt *Timestamp `json:"created_at,omitempty"` | |
UpdatedAt *Timestamp `json:"updated_at,omitempty"` |
github/event_types.go
Outdated
MarketplacePurchase *MarketplacePurchase `json:"marketplace_purchase"` | ||
PreviousMarketplacePurchase *MarketplacePurchase `json:"previous_marketplace_purchase"` | ||
Sender *User `json:"sender,omitempty"` | ||
} |
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.
You'll need to break the fields into two sections. The event API payload fields (of which, there's only one, action
):
And Webhook payload fields, which are all the rest. You should put them under a // The following fields are only populated by Webhook events.
comment. Something like this:
type MarketplacePurchaseEvent struct {
// Action is the action that was performed. Possible values are:
// "purchased", "cancelled", or "changed".
Action *string `json:"action,omitempty"`
// The following fields are only populated by Webhook events.
...
}
See structs right above and below the one you added for reference.
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.
Additionally, you'll need to add an implicit Installation *Installation `json:"installation,omitempty"`
field. Its existence is documented at https://developer.github.com/webhooks/#payloads. Put it at the very bottom; see other events in this file as reference.
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.
Okay @shurcooL, will fix these. thanks 👍 .
Added *Installation
github/event_types.go
Outdated
// The following fields are only populated by Webhook events. | ||
EffectiveDate *Timestamp `json:"effective_date"` | ||
MarketplacePurchase *MarketplacePurchase `json:"marketplace_purchase"` | ||
PreviousMarketplacePurchase *MarketplacePurchase `json:"previous_marketplace_purchase"` |
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.
The 3 fields above are missing ,omitempty
suffix. The rest of the fields have it.
You should add them for consistency (unless there's a good reason not to include them; I don't know of any, let me know if you do).
08c4f3f
to
724b868
Compare
The CI is failing on the latest commit. It looks like you'll need to regenerate the package with |
@shurcooL It looks good right ? |
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.
LGTM. Thanks @scriptonist!
I can apply the minor comment myself and merge.
github/event_types.go
Outdated
// | ||
// Github API docs: https://developer.github.com/v3/activity/events/types/#marketplacepurchaseevent | ||
type MarketplacePurchaseEvent struct { | ||
Action *string `json:"action,omitempty"` |
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.
It'd be nice to add a comment here documenting possible action values, like in the events above and below.
// Action is the action that was performed. Possible values are:
// "purchased", "cancelled", "changed".
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
Fixes #785