func()

in pkg/gitprovider/bitbucket.go [128:151]


func (b *BitbucketClient) GetWebHook(ctx context.Context, _, _, projectID, webHookRef string) (*WebHook, error) {
	owner, repo, err := parseProjectID(projectID)
	if err != nil {
		return nil, err
	}

	r, err := b.client.GetRepositoriesWorkspaceRepoSlugHooksUidWithResponse(ctx, owner, repo, webHookRef)
	if err != nil {
		return nil, fmt.Errorf("failed to get Bitbucket web hook: %w", err)
	}

	if r.StatusCode() != http.StatusOK {
		return nil, fmt.Errorf("failed to get Bitbucket web hook: %s %s", r.Status(), r.Body)
	}

	if r.JSON200 == nil || r.JSON200.Uuid == nil || r.JSON200.Url == nil {
		return nil, fmt.Errorf("failed to get Bitbucket web hook: invalid response %s", r.Body)
	}

	return &WebHook{
		ID:  *r.JSON200.Uuid,
		URL: *r.JSON200.Url,
	}, nil
}