@@ -118,6 +118,7 @@ type PayloadRepo struct {
118118var (
119119 _ Payloader = & CreatePayload {}
120120 _ Payloader = & PushPayload {}
121+ _ Payloader = & PullRequestPayload {}
121122)
122123
123124// _________ __
@@ -140,11 +141,7 @@ func (p *CreatePayload) SetSecret(secret string) {
140141}
141142
142143func (p * CreatePayload ) JSONPayload () ([]byte , error ) {
143- data , err := json .MarshalIndent (p , "" , " " )
144- if err != nil {
145- return []byte {}, err
146- }
147- return data , nil
144+ return json .MarshalIndent (p , "" , " " )
148145}
149146
150147// ParseCreateHook parses create event hook content.
@@ -192,11 +189,7 @@ func (p *PushPayload) SetSecret(secret string) {
192189}
193190
194191func (p * PushPayload ) JSONPayload () ([]byte , error ) {
195- data , err := json .MarshalIndent (p , "" , " " )
196- if err != nil {
197- return []byte {}, err
198- }
199- return data , nil
192+ return json .MarshalIndent (p , "" , " " )
200193}
201194
202195// ParsePushHook parses push event hook content.
@@ -219,3 +212,59 @@ func ParsePushHook(raw []byte) (*PushPayload, error) {
219212func (p * PushPayload ) Branch () string {
220213 return strings .Replace (p .Ref , "refs/heads/" , "" , - 1 )
221214}
215+
216+ // .___
217+ // | | ______ ________ __ ____
218+ // | |/ ___// ___/ | \_/ __ \
219+ // | |\___ \ \___ \| | /\ ___/
220+ // |___/____ >____ >____/ \___ >
221+ // \/ \/ \/
222+
223+ type HookIssueAction string
224+
225+ const (
226+ HOOK_ISSUE_OPENED HookIssueAction = "opened"
227+ HOOK_ISSUE_CLOSED HookIssueAction = "closed"
228+ HOOK_ISSUE_REOPENED HookIssueAction = "reopened"
229+ HOOK_ISSUE_EDITED HookIssueAction = "edited"
230+ HOOK_ISSUE_ASSIGNED HookIssueAction = "assigned"
231+ HOOK_ISSUE_UNASSIGNED HookIssueAction = "unassigned"
232+ HOOK_ISSUE_LABEL_UPDATED HookIssueAction = "label_updated"
233+ HOOK_ISSUE_LABEL_CLEARED HookIssueAction = "label_cleared"
234+ HOOK_ISSUE_SYNCHRONIZED HookIssueAction = "synchronized"
235+ )
236+
237+ type ChangesFromPayload struct {
238+ From string `json:"from"`
239+ }
240+
241+ type ChangesPayload struct {
242+ Title * ChangesFromPayload `json:"title,omitempty"`
243+ Body * ChangesFromPayload `json:"body,omitempty"`
244+ }
245+
246+ // __________ .__ .__ __________ __
247+ // \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_
248+ // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
249+ // | | | | / |_| |__ | | \ ___< <_| | | /\ ___/ \___ \ | |
250+ // |____| |____/|____/____/ |____|_ /\___ >__ |____/ \___ >____ > |__|
251+ // \/ \/ |__| \/ \/
252+
253+ // PullRequestPayload represents a payload information of pull request event.
254+ type PullRequestPayload struct {
255+ Secret string `json:"secret"`
256+ Action HookIssueAction `json:"action"`
257+ Index int64 `json:"number"`
258+ Changes * ChangesPayload `json:"changes,omitempty"`
259+ PullRequest * PullRequest `json:"pull_request"`
260+ Repository * Repository `json:"repository"`
261+ Sender * User `json:"sender"`
262+ }
263+
264+ func (p * PullRequestPayload ) SetSecret (secret string ) {
265+ p .Secret = secret
266+ }
267+
268+ func (p * PullRequestPayload ) JSONPayload () ([]byte , error ) {
269+ return json .MarshalIndent (p , "" , " " )
270+ }
0 commit comments