// GetBySlug fetches a repository based on the provided slug.
//
// Travis CI API docs: http://docs.travis-ci.com/api/#repositories
335349
func (rs *RepositoriesService) GetFromSlug(slug string) (*Repository, *http.Response, error) {
	u, err := urlWithOptions(fmt.Sprintf("/repos/%s", slug), nil)
	if err != nil {
		return nil, nil, err
	}

	req, err := rs.client.NewRequest("GET", u, nil, nil)
	if err != nil {
		return nil, nil, err
	}

	var repoResp getRepositoryResponse
	resp, err := rs.client.Do(req, &repoResp)
	if err != nil {
		return nil, resp, err
	}

	return &repoResp.Repository, resp, err
}
1263037
func (u *UserLDAPMapping) GetGistsURL() string {
	if u == nil || u.GistsURL == nil {
		return ""
	}
	return *u.GistsURL
}
981972
func (r *RepoKeyResource) Find(owner, slug string, id int) (*Key, error) {
	key := Key{}
	path := fmt.Sprintf("/repositories/%s/%s/deploy-keys/%v", owner, slug, id)
	if err := r.client.do("GET", path, nil, nil, &key); err != nil {
		return nil, err
	}

	return &key, nil
}
711354
func (r *RepositoryInvitation) GetURL() string {
	if r == nil || r.URL == nil {
		return ""
	}
	return *r.URL
}
1102055
func (r *Repository) GetSubscribersURL() string {
	if r == nil || r.SubscribersURL == nil {
		return ""
	}
	return *r.SubscribersURL
}
680401
func (r *RepositoryRelease) GetUploadURL() string {
	if r == nil || r.UploadURL == nil {
		return ""
	}
	return *r.UploadURL
}
414595
func (i *ImageService) GetRepository(ctx context.Context, ref reference.Named, authConfig *types.AuthConfig) (dist.Repository, bool, error) {
	// get repository info
	repoInfo, err := i.registryService.ResolveRepository(ref)
	if err != nil {
		return nil, false, errdefs.InvalidParameter(err)
	}
	// makes sure name is not empty or `scratch`
	if err := distribution.ValidateRepoName(repoInfo.Name); err != nil {
		return nil, false, errdefs.InvalidParameter(err)
	}

	// get endpoints
	endpoints, err := i.registryService.LookupPullEndpoints(reference.Domain(repoInfo.Name))
	if err != nil {
		return nil, false, err
	}

	// retrieve repository
	var (
		confirmedV2 bool
		repository  dist.Repository
		lastError   error
	)

	for _, endpoint := range endpoints {
		if endpoint.Version == registry.APIVersion1 {
			continue
		}

		repository, confirmedV2, lastError = distribution.NewV2Repository(ctx, repoInfo, endpoint, nil, authConfig, "pull")
		if lastError == nil && confirmedV2 {
			break
		}
	}
	return repository, confirmedV2, lastError
}
1262274
func (i *Import) GetRepositoryURL() string {
	if i == nil || i.RepositoryURL == nil {
		return ""
	}
	return *i.RepositoryURL
}
596419
func (r *Repository) GetURL() string {
	if r == nil || r.URL == nil {
		return ""
	}
	return *r.URL
}
501500
func (i *Installation) GetRepositoriesURL() string {
	if i == nil || i.RepositoriesURL == nil {
		return ""
	}
	return *i.RepositoriesURL
}
990366
func (b *Blob) GetURL() string {
	if b == nil || b.URL == nil {
		return ""
	}
	return *b.URL
}
313075
func GetURLBody(absoluteUrl string) ([]byte, error) {
	req, err := http.NewRequest("GET", absoluteUrl, nil)
	if err != nil {
		return []byte{}, err
	}
	cli := &http.Client{}
	res, err := cli.Do(req)
	if err != nil {
		return []byte{}, err
	}
	defer res.Body.Close()
	return ioutil.ReadAll(res.Body)
}
782526
func (d *Deployment) GetRepositoryURL() string {
	if d == nil || d.RepositoryURL == nil {
		return ""
	}
	return *d.RepositoryURL
}
237803
func (s *RepositoriesService) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*RepositoryRelease, *Response, error) {
	u := fmt.Sprintf("repos/%s/%s/releases/tags/%s", owner, repo, tag)
	return s.getSingleRelease(ctx, u)
}
621620
func (r *RepositoryLicense) GetURL() string {
	if r == nil || r.URL == nil {
		return ""
	}
	return *r.URL
}
1107173
func (r *BrokerResource) GetPatch(owner, slug string, id int) (string, error) {
	data := []byte{}
	// uri, err := url.Parse("https://api.bitbucket.org/1.0" + path)
	// https://bitbucket.org/!api/2.0/repositories/tdburke/test_mymysql/pullrequests/1/patch

	path := fmt.Sprintf("/repositories/tdburke/test_mymysql/pullrequests/1/patch")

	fmt.Println(path)

	if err := r.client.do("GET", path, nil, nil, &data); err != nil {
		fmt.Println("Get error:", err)
		return "", err
	}

	fmt.Println(data)

	if len(data) == 0 {
		return "", ErrNotFound
	}

	return "", nil
}
273330
func (c *Client) GetResultByURI(uri string) (*http.Response, error) {
	req, err := c.NewRequest("GET", uri, nil)
	if err != nil {
		return nil, err
	}
	res, err := c.HTTPClient.Do(req)

	if err != nil {
		return res, err
	}
	return res, err
}