// Path: src/main/java/org/springframework/social/bitbucket/api/BitBucket.java
// public interface BitBucket extends ApiBinding {
// 
//     /**
//      * Returns the portion of the BitBucket API that allow interaction with
//      * repositories.
//      */
//     RepoOperations repoOperations();
// 
//     /**
//      * Returns the portion of the BitBucket API that allow interaction with user
//      * accounts.
//      */
//     UserOperations userOperations();
// 
//     /**
//      * Returns the portion of the BitBucket API that allow messing with
//      * privileges.
//      */
//     PrivilegeOperations privelegesOperations();
// }
// 
// Path: src/main/java/org/springframework/social/bitbucket/api/PrivilegeOperations.java
// public interface PrivilegeOperations {
// 
//     /**
//      * Get the privileges on a given repository.
//      * 
//      * @param user
//      *            repository owner
//      * @param repoSlug
//      *            name of the repository
//      */
//     public List<RepoPrivilege> getRepoPrivileges(String user, String repoSlug);
// 
//     /**
//      * Set or change the privilege for the given recipient on some repository.
//      * 
//      * @param owner
//      *            the repository owner
//      * @param repoSlug
//      *            the repository name
//      * @param recipient
//      *            user for which to set the privilege
//      * @param privilege
//      *            new privilege value to set
//      */
//     public RepoPrivilege setPrivilege(String owner, String repoSlug,
//             String recipient, BitBucketPrivilege privilege);
// 
//     /**
//      * Removes the current privilege of the given recipient from some
//      * repository.
//      * 
//      * @param owner
//      *            the repository owner
//      * @param repoSlug
//      *            the repository name
//      * @param recipient
//      *            user for which to remove the privilege
//      */
//     public void removePrivilege(String owner, String repoSlug, String recipient);
// 
// }
// 
// Path: src/main/java/org/springframework/social/bitbucket/api/RepoOperations.java
// public interface RepoOperations {
// 
//     /**
//      * Returns the public repository that belongs to {@code user} and that has
//      * {@code repoSlug} as its technical name.
//      */
//     public BitBucketRepository getRepository(String user, String repoSlug);
// 
//     /**
//      * Returns the list of repositories for the current user.
//      */
//     public List<BitBucketRepository> getUserRepositories();
// 
//     /**
//      * Search for public repositories whose name contains the given String.
//      */
//     public List<BitBucketRepository> search(String string);
// 
//     /**
//      * Returns a mapping between tags (keys) and changesets (values) on the
//      * given repository.
//      */
//     public Map<String, BitBucketChangeset> getTags(String user, String repoSlug);
// 
//     /**
//      * Returns the list of users following the given repository.
//      */
//     public List<BitBucketUser> getFollowers(String user, String repoSlug);
// 
//     /**
//      * Returns the last changesets on a repository, as well as information about
//      * how many are available totally.
//      */
//     public BitBucketChangesets getChangesets(String user, String repoSlug);
// 
//     /**
//      * Returns some changesets on a repository, as well as information about how
//      * many are available totally.
//      */
//     public BitBucketChangesets getChangesets(String user, String repoSlug,
//             String start, int limit);
// 
//     /**
//      * Returns information about a known directory, including children
//      * directories and files.
//      */
//     public BitBucketDirectory getDirectory(String user, String repoSlug,
//             String revision, String path);
// 
//     /**
//      * Returns information and actual contents (as a String) about a known file
//      * path.
//      */
//     public BitBucketFile getFile(String string, String string2, String string3,
//             String string4);
// 
//     /**
//      * Creates a new repository under the account of the currently authenticated
//      * user. The account automatically becomes the owner.
//      */
//     public BitBucketRepository createRepository(RepoCreation options);
// }
// 
// Path: src/main/java/org/springframework/social/bitbucket/api/UserOperations.java
// public interface UserOperations {
// 
//     /**
//      * Returns information about the current user, as well as the list of
//      * repositories he/she owns.
//      */
//     UserWithRepositories getUserWithRepositories();
// 
//     /**
//      * Returns the list of users that follow the given {@code user}.
//      */
//     List<BitBucketUser> getFollowers(String user);
// 
// }


import org.springframework.social.bitbucket.api.BitBucket;
import org.springframework.social.bitbucket.api.PrivilegeOperations;
import org.springframework.social.bitbucket.api.RepoOperations;
import org.springframework.social.bitbucket.api.UserOperations;
import org.springframework.social.oauth1.AbstractOAuth1ApiBinding;
/**
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.social.bitbucket.api.impl;


public class BitBucketTemplate extends AbstractOAuth1ApiBinding implements
        BitBucket {

    private UserOperations userOperations;

    private RepoOperations repoOperations;

    private PrivilegeOperations privilegeOperations;

    public BitBucketTemplate(String consumerKey, String consumerSecret,
            String accessToken, String accessTokenSecret) {
        super(consumerKey, consumerSecret, accessToken, accessTokenSecret);
        initSubApis();
    }

    public BitBucketTemplate() {
        super();
        initSubApis();
    }

    private void initSubApis() {
        userOperations = new UserTemplate(getRestTemplate(), isAuthorized());
        repoOperations = new RepoTemplate(getRestTemplate(), isAuthorized());
        privilegeOperations = new PrivilegeTemplate(getRestTemplate(),
                isAuthorized());
    }

    @Override
    public RepoOperations repoOperations() {
        return repoOperations;
    }

    @Override
    public UserOperations userOperations() {
        return userOperations;
    }

// Path: src/main/java/org/springframework/social/bitbucket/api/BitBucket.java
// public interface BitBucket extends ApiBinding {
// 
//     /**
//      * Returns the portion of the BitBucket API that allow interaction with
//      * repositories.
//      */
//     RepoOperations repoOperations();
// 
//     /**
//      * Returns the portion of the BitBucket API that allow interaction with user
//      * accounts.
//      */
//     UserOperations userOperations();
// 
//     /**
//      * Returns the portion of the BitBucket API that allow messing with
//      * privileges.
//      */
//     PrivilegeOperations privelegesOperations();
// }
// 
// Path: src/main/java/org/springframework/social/bitbucket/api/PrivilegeOperations.java
// public interface PrivilegeOperations {
// 
//     /**
//      * Get the privileges on a given repository.
//      * 
//      * @param user
//      *            repository owner
//      * @param repoSlug
//      *            name of the repository
//      */
//     public List<RepoPrivilege> getRepoPrivileges(String user, String repoSlug);
// 
//     /**
//      * Set or change the privilege for the given recipient on some repository.
//      * 
//      * @param owner
//      *            the repository owner
//      * @param repoSlug
//      *            the repository name
//      * @param recipient
//      *            user for which to set the privilege
//      * @param privilege
//      *            new privilege value to set
//      */
//     public RepoPrivilege setPrivilege(String owner, String repoSlug,
//             String recipient, BitBucketPrivilege privilege);
// 
//     /**
//      * Removes the current privilege of the given recipient from some
//      * repository.
//      * 
//      * @param owner
//      *            the repository owner
//      * @param repoSlug
//      *            the repository name
//      * @param recipient
//      *            user for which to remove the privilege
//      */
//     public void removePrivilege(String owner, String repoSlug, String recipient);
// 
// }
// 
// Path: src/main/java/org/springframework/social/bitbucket/api/RepoOperations.java
// public interface RepoOperations {
// 
//     /**
//      * Returns the public repository that belongs to {@code user} and that has
//      * {@code repoSlug} as its technical name.
//      */
//     public BitBucketRepository getRepository(String user, String repoSlug);
// 
//     /**
//      * Returns the list of repositories for the current user.
//      */
//     public List<BitBucketRepository> getUserRepositories();
// 
//     /**
//      * Search for public repositories whose name contains the given String.
//      */
//     public List<BitBucketRepository> search(String string);
// 
//     /**
//      * Returns a mapping between tags (keys) and changesets (values) on the
//      * given repository.
//      */
//     public Map<String, BitBucketChangeset> getTags(String user, String repoSlug);
// 
//     /**
//      * Returns the list of users following the given repository.
//      */
//     public List<BitBucketUser> getFollowers(String user, String repoSlug);
// 
//     /**
//      * Returns the last changesets on a repository, as well as information about
//      * how many are available totally.
//      */
//     public BitBucketChangesets getChangesets(String user, String repoSlug);
// 
//     /**
//      * Returns some changesets on a repository, as well as information about how
//      * many are available totally.
//      */
//     public BitBucketChangesets getChangesets(String user, String repoSlug,
//             String start, int limit);
// 
//     /**
//      * Returns information about a known directory, including children
//      * directories and files.
//      */
//     public BitBucketDirectory getDirectory(String user, String repoSlug,
//             String revision, String path);
// 
//     /**
//      * Returns information and actual contents (as a String) about a known file
//      * path.
//      */
//     public BitBucketFile getFile(String string, String string2, String string3,
//             String string4);
// 
//     /**
//      * Creates a new repository under the account of the currently authenticated
//      * user. The account automatically becomes the owner.
//      */
//     public BitBucketRepository createRepository(RepoCreation options);
// }
// 
// Path: src/main/java/org/springframework/social/bitbucket/api/UserOperations.java
// public interface UserOperations {
// 
//     /**
//      * Returns information about the current user, as well as the list of
//      * repositories he/she owns.
//      */
//     UserWithRepositories getUserWithRepositories();
// 
//     /**
//      * Returns the list of users that follow the given {@code user}.
//      */
//     List<BitBucketUser> getFollowers(String user);
// 
// }


// Path: src/main/java/org/springframework/social/bitbucket/api/impl/BitBucketTemplate.java
import org.springframework.social.bitbucket.api.BitBucket;
import org.springframework.social.bitbucket.api.PrivilegeOperations;
import org.springframework.social.bitbucket.api.RepoOperations;
import org.springframework.social.bitbucket.api.UserOperations;
import org.springframework.social.oauth1.AbstractOAuth1ApiBinding;

/**
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.social.bitbucket.api.impl;


public class BitBucketTemplate extends AbstractOAuth1ApiBinding implements
        BitBucket {

    private UserOperations userOperations;

    private RepoOperations repoOperations;

    private PrivilegeOperations privilegeOperations;

    public BitBucketTemplate(String consumerKey, String consumerSecret,
            String accessToken, String accessTokenSecret) {
        super(consumerKey, consumerSecret, accessToken, accessTokenSecret);
        initSubApis();
    }

    public BitBucketTemplate() {
        super();
        initSubApis();
    }

    private void initSubApis() {
        userOperations = new UserTemplate(getRestTemplate(), isAuthorized());
        repoOperations = new RepoTemplate(getRestTemplate(), isAuthorized());
        privilegeOperations = new PrivilegeTemplate(getRestTemplate(),
                isAuthorized());
    }

    @Override
    public RepoOperations repoOperations() {
        return repoOperations;
    }

    @Override
    public UserOperations userOperations() {
        return userOperations;
    }

    @Override