123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- package github
- import (
- "context"
- "fmt"
- )
- func (s *OrganizationsService) ListHooks(ctx context.Context, org string, opt *ListOptions) ([]*Hook, *Response, error) {
- u := fmt.Sprintf("orgs/%v/hooks", org)
- u, err := addOptions(u, opt)
- if err != nil {
- return nil, nil, err
- }
- req, err := s.client.NewRequest("GET", u, nil)
- if err != nil {
- return nil, nil, err
- }
- var hooks []*Hook
- resp, err := s.client.Do(ctx, req, &hooks)
- if err != nil {
- return nil, resp, err
- }
- return hooks, resp, nil
- }
- func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int64) (*Hook, *Response, error) {
- u := fmt.Sprintf("orgs/%v/hooks/%d", org, id)
- req, err := s.client.NewRequest("GET", u, nil)
- if err != nil {
- return nil, nil, err
- }
- hook := new(Hook)
- resp, err := s.client.Do(ctx, req, hook)
- return hook, resp, err
- }
- func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook *Hook) (*Hook, *Response, error) {
- u := fmt.Sprintf("orgs/%v/hooks", org)
- req, err := s.client.NewRequest("POST", u, hook)
- if err != nil {
- return nil, nil, err
- }
- h := new(Hook)
- resp, err := s.client.Do(ctx, req, h)
- if err != nil {
- return nil, resp, err
- }
- return h, resp, nil
- }
- func (s *OrganizationsService) EditHook(ctx context.Context, org string, id int64, hook *Hook) (*Hook, *Response, error) {
- u := fmt.Sprintf("orgs/%v/hooks/%d", org, id)
- req, err := s.client.NewRequest("PATCH", u, hook)
- if err != nil {
- return nil, nil, err
- }
- h := new(Hook)
- resp, err := s.client.Do(ctx, req, h)
- return h, resp, err
- }
- func (s *OrganizationsService) PingHook(ctx context.Context, org string, id int64) (*Response, error) {
- u := fmt.Sprintf("orgs/%v/hooks/%d/pings", org, id)
- req, err := s.client.NewRequest("POST", u, nil)
- if err != nil {
- return nil, err
- }
- return s.client.Do(ctx, req, nil)
- }
- func (s *OrganizationsService) DeleteHook(ctx context.Context, org string, id int64) (*Response, error) {
- u := fmt.Sprintf("orgs/%v/hooks/%d", org, id)
- req, err := s.client.NewRequest("DELETE", u, nil)
- if err != nil {
- return nil, err
- }
- return s.client.Do(ctx, req, nil)
- }
|