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

Conversation

scriptonist
Copy link
Contributor

Fixes #785

@googlebot googlebot added the cla: yes Indication that the PR author has signed a Google Contributor License Agreement. label Nov 19, 2017
// 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"`
Copy link
Member

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:

CreatedAt *Timestamp `json:"created_at,omitempty"`
PushedAt *Timestamp `json:"pushed_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`

CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`

MarketplacePurchase *MarketplacePurchase `json:"marketplace_purchase"`
PreviousMarketplacePurchase *MarketplacePurchase `json:"previous_marketplace_purchase"`
Sender *User `json:"sender,omitempty"`
}
Copy link
Member

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

image

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.

Copy link
Member

@dmitshur dmitshur Nov 19, 2017

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.

Copy link
Contributor Author

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 👍 .

// 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"`
Copy link
Member

@dmitshur dmitshur Nov 21, 2017

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

@scriptonist scriptonist force-pushed the Issue704 branch 2 times, most recently from 08c4f3f to 724b868 Compare November 22, 2017 03:47
@dmitshur
Copy link
Member

The CI is failing on the latest commit. It looks like you'll need to regenerate the package with go generate again.

@scriptonist
Copy link
Contributor Author

@shurcooL It looks good right ?

Copy link
Member

@dmitshur dmitshur left a 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 API docs: https://developer.github.com/v3/activity/events/types/#marketplacepurchaseevent
type MarketplacePurchaseEvent struct {
Action *string `json:"action,omitempty"`
Copy link
Member

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".

@googlebot
Copy link

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 cla/google commit status will not change from this State. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@googlebot googlebot added cla: no and removed cla: yes Indication that the PR author has signed a Google Contributor License Agreement. labels Nov 22, 2017
@dmitshur dmitshur merged commit df47db1 into google:master Nov 22, 2017
@scriptonist scriptonist deleted the Issue704 branch November 23, 2017 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants