// GetWebhooksByRepoID returns all webhooks of a repository.
438212
func GetWebhooksByRepoID(repoID int64) ([]*Webhook, error) {
	webhooks := make([]*Webhook, 0, 5)
	return webhooks, x.Find(&webhooks, &Webhook{RepoID: repoID})
}
698650
func (am *AutogitManager) GetBrowserForRepo(
	ctx context.Context, gitFS *libfs.FS, repoName string,
	branch plumbing.ReferenceName, subdir string) (*libfs.FS, *Browser, error) {
	am.browserLock.Lock()
	defer am.browserLock.Unlock()
	return am.getBrowserForRepoLocked(ctx, gitFS, repoName, branch, subdir)
}
1102870
func (s *Service) AddOnWebhookDeliveryInfo(ctx context.Context, addOnIdentity string, appWebhookDeliveryIdentity string) (*AddOnWebhookDeliveryInfoResult, error) {
	var addOnWebhookDelivery AddOnWebhookDeliveryInfoResult
	return &addOnWebhookDelivery, s.Get(ctx, &addOnWebhookDelivery, fmt.Sprintf("/addons/%v/webhook-deliveries/%v", addOnIdentity, appWebhookDeliveryIdentity), nil, nil)
}
6472
func GetWebhookOfRepoByID(repoID, id int64) (*Webhook, error) {
	return getWebhook(&Webhook{
		ID:     id,
		RepoID: repoID,
	})
}
570125
func (c *Client) GetGifsById(ids ...string) ([]*Gif, error) {

	// check that a query string was actually passed in
	if len(ids) > 100 {
		err := errors.New("Cannot fetch more than 100 GIFs at a time.")
		return nil, err
	}

	// build query string that will be appended to url
	qs := &url.Values{}
	qs.Set("ids", strings.Join(ids, ","))

	// construct and execute the HTTP request
	pr := &paginatedResults{}
	if err := c.makeRequest("gifs", qs, pr); err != nil {
		return nil, err
	}

	return pr.Data, nil
}
998687
func GetCommentsByRepoIDSince(repoID, since int64) ([]*Comment, error) {
	return getCommentsByRepoIDSince(x, repoID, since)
}
151650
func (mg *MailgunImpl) GetWebhook(ctx context.Context, t string) (string, error) {
	r := newHTTPRequest(generateDomainApiUrl(mg, webhooksEndpoint) + "/" + t)
	r.setClient(mg.Client())
	r.setBasicAuth(basicAuthUser, mg.APIKey())
	var envelope struct {
		Webhook struct {
			Url string `json:"url"`
		} `json:"webhook"`
	}
	err := getResponseFromJSON(ctx, r, &envelope)
	return envelope.Webhook.Url, err
}
1213307
func (s *Service) AddOnWebhookList(ctx context.Context, addOnIdentity string, lr *ListRange) (AddOnWebhookListResult, error) {
	var addOnWebhook AddOnWebhookListResult
	return addOnWebhook, s.Get(ctx, &addOnWebhook, fmt.Sprintf("/addons/%v/webhooks", addOnIdentity), nil, lr)
}
1113557
func GetHook(repoPath, name string) (*Hook, error) {
	if !IsValidHookName(name) {
		return nil, ErrNotValidHook
	}
	h := &Hook{
		name: name,
		path: path.Join(repoPath, HookDir, name),
	}
	if isFile(h.path) {
		data, err := ioutil.ReadFile(h.path)
		if err != nil {
			return nil, err
		}
		h.IsActive = true
		h.Content = string(data)
		return h, nil
	}

	// Check sample file
	samplePath := path.Join(repoPath, HookSampleDir, h.name) + ".sample"
	if isFile(samplePath) {
		data, err := ioutil.ReadFile(samplePath)
		if err != nil {
			return nil, err
		}
		h.Sample = string(data)
	}
	return h, nil
}
345975
func (s *Service) AppWebhookList(ctx context.Context, appIdentity string, lr *ListRange) (AppWebhookListResult, error) {
	var appWebhook AppWebhookListResult
	return appWebhook, s.Get(ctx, &appWebhook, fmt.Sprintf("/apps/%v/webhooks", appIdentity), nil, lr)
}
1078889
func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel {
	ch := make(chan Update, bot.Buffer)

	http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
		bytes, _ := ioutil.ReadAll(r.Body)
		r.Body.Close()

		var update Update
		json.Unmarshal(bytes, &update)

		ch <- update
	})

	return ch
}
46163
func (s *Service) AddOnWebhookCreate(ctx context.Context, addOnIdentity string, o AddOnWebhookCreateOpts) (*AddOnWebhookCreateResult, error) {
	var addOnWebhook AddOnWebhookCreateResult
	return &addOnWebhook, s.Post(ctx, &addOnWebhook, fmt.Sprintf("/addons/%v/webhooks", addOnIdentity), o)
}
135620
func NewWebHookREST(buildConfigClient buildclienttyped.BuildV1Interface, secretsClient kubetypedclient.SecretsGetter, groupVersion schema.GroupVersion, plugins map[string]webhook.Plugin) *WebHook {
	return newWebHookREST(buildConfigClient, secretsClient, client.BuildConfigInstantiatorClient{Client: buildConfigClient}, groupVersion, plugins)
}
566078
func (mg *MailgunImpl) VerifyWebhookRequest(req *http.Request) (verified bool, err error) {
	h := hmac.New(sha256.New, []byte(mg.APIKey()))
	io.WriteString(h, req.FormValue("timestamp"))
	io.WriteString(h, req.FormValue("token"))

	calculatedSignature := h.Sum(nil)
	signature, err := hex.DecodeString(req.FormValue("signature"))
	if err != nil {
		return false, err
	}
	if len(calculatedSignature) != len(signature) {
		return false, nil
	}

	return subtle.ConstantTimeCompare(signature, calculatedSignature) == 1, nil
}
916464
func (s *WebhooksService) GetWebhook(accountID string, webhookID int64) (*webhookResponse, error) {
	path := versioned(webhookPath(accountID, webhookID))
	webhookResponse := &webhookResponse{}

	resp, err := s.client.get(path, webhookResponse)
	if err != nil {
		return nil, err
	}

	webhookResponse.HttpResponse = resp
	return webhookResponse, nil
}
842181
func (c oauthClient) CreateWebhook(
	listID uint,
	url string,
	processorType string,
	configuration string,
) (wl.Webhook, error) {
	if listID == 0 {
		return wl.Webhook{}, errors.New("listID must be > 0")
	}

	body := []byte(fmt.Sprintf(`{
		"list_id":%d,
		"url":"%s",
		"processor_type":"%s",
		"configuration":"%s"
	}`,
		listID,
		url,
		processorType,
		configuration,
	))

	reqURL := fmt.Sprintf("%s/webhooks", c.apiURL)

	req, err := c.newPostRequest(reqURL, body)
	if err != nil {
		return wl.Webhook{}, err
	}

	resp, err := c.do(req)
	if err != nil {
		return wl.Webhook{}, err
	}

	if resp.StatusCode != http.StatusCreated {
		return wl.Webhook{}, fmt.Errorf("Unexpected response code %d - expected %d", resp.StatusCode, http.StatusCreated)
	}

	webhook := wl.Webhook{}
	err = json.NewDecoder(resp.Body).Decode(&webhook)
	if err != nil {
		return wl.Webhook{}, err
	}
	return webhook, nil
}
951640
func CreateWebhook(c *messagebird.Client, req *WebhookCreateRequest) (*Webhook, error) {
	webhook := &Webhook{}
	if err := request(c, webhook, http.MethodPost, webhooksPath, req); err != nil {
		return nil, err
	}

	return webhook, nil
}