// Path: src/main/java/com/wouterbreukink/onedrive/client/authoriser/AuthorisationProvider.java
// public interface AuthorisationProvider {
// 
//     String getAccessToken() throws IOException;
// 
//     void refresh() throws IOException;
// 
//     class FACTORY {
//         public static AuthorisationProvider create(Path keyFile) throws IOException {
//             return new OneDriveAuthorisationProvider(keyFile);
//         }
// 
//         public static void printAuthInstructions() {
//             OneDriveAuthorisationProvider.printAuthInstructions();
//         }
//     }
// }
// 
// Path: src/main/java/com/wouterbreukink/onedrive/client/downloader/ResumableDownloaderProgressListener.java
// public interface ResumableDownloaderProgressListener {
// 
//     /**
//      * Called to notify that progress has been changed.
//      * <p>
//      * <p>
//      * This method is called multiple times depending on how many chunks are downloaded. Once the
//      * download completes it is called one final time.
//      * </p>
//      *
//      * @param downloader Media HTTP downloader
//      */
//     void progressChanged(ResumableDownloader downloader) throws IOException;
// }
// 
// Path: src/main/java/com/wouterbreukink/onedrive/client/resources/Drive.java
// public class Drive {
// 
//     @Key
//     private String id;
// 
//     @Key
//     private String driveType;
// 
//     @Key
//     private IdentitySet owner;
// 
//     @Key
//     private QuotaFacet quota;
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getDriveType() {
//         return driveType;
//     }
// 
//     public IdentitySet getOwner() {
//         return owner;
//     }
// 
//     public QuotaFacet getQuota() {
//         return quota;
//     }
// }
// 
// Path: src/main/java/com/wouterbreukink/onedrive/client/resources/Item.java
// public class Item {
// 
//     @Key
//     private String id;
//     @Key
//     private String name;
//     @Key
//     private String eTag;
//     @Key
//     private String cTag;
//     @Key
//     private IdentitySet createdBy;
//     @Key
//     private IdentitySet lastModifiedBy;
//     @Key
//     private String createdDateTime;
//     @Key
//     private String lastModifiedDateTime;
//     @Key
//     private long size;
//     @Key
//     private ItemReference parentReference;
//     @Key
//     private Item[] children;
//     @Key
//     private String webUrl;
//     @Key
//     private FolderFacet folder;
//     @Key
//     private FileFacet file;
//     @Key
//     private FileSystemInfoFacet fileSystemInfo;
//     @Key
//     private DeletedFacet deleted;
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public String geteTag() {
//         return eTag;
//     }
// 
//     public String getcTag() {
//         return cTag;
//     }
// 
//     public IdentitySet getCreatedBy() {
//         return createdBy;
//     }
// 
//     public IdentitySet getLastModifiedBy() {
//         return lastModifiedBy;
//     }
// 
//     public String getCreatedDateTime() {
//         return createdDateTime;
//     }
// 
//     public String getLastModifiedDateTime() {
//         return lastModifiedDateTime;
//     }
// 
//     public long getSize() {
//         return size;
//     }
// 
//     public ItemReference getParentReference() {
//         return parentReference;
//     }
// 
//     public String getWebUrl() {
//         return webUrl;
//     }
// 
//     public FolderFacet getFolder() {
//         return folder;
//     }
// 
//     public FileFacet getFile() {
//         return file;
//     }
// 
//     public FileSystemInfoFacet getFileSystemInfo() {
//         return fileSystemInfo;
//     }
// 
//     public DeletedFacet getDeleted() {
//         return deleted;
//     }
// 
//     public Item[] getChildren() {
//         return children;
//     }
// }


import com.google.api.client.http.*;
import com.google.api.client.http.apache.ApacheHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonObjectParser;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.client.repackaged.com.google.common.base.Throwables;
import com.google.api.client.util.Lists;
import com.wouterbreukink.onedrive.client.authoriser.AuthorisationProvider;
import com.wouterbreukink.onedrive.client.downloader.ResumableDownloaderProgressListener;
import com.wouterbreukink.onedrive.client.resources.Drive;
import com.wouterbreukink.onedrive.client.resources.Item;
import com.wouterbreukink.onedrive.client.resources.ItemSet;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;
package com.wouterbreukink.onedrive.client;



class ROOneDriveProvider implements OneDriveProvider {

    static final HttpTransport HTTP_TRANSPORT = new ApacheHttpTransport();
    static final JsonFactory JSON_FACTORY = new GsonFactory();

    final HttpRequestFactory requestFactory;

    public ROOneDriveProvider(final AuthorisationProvider authoriser) {
        requestFactory =
                HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() {
                    @Override
                    public void initialize(HttpRequest request) {
                        request.setParser(new JsonObjectParser(JSON_FACTORY));
                        request.setReadTimeout(60000);
                        request.setConnectTimeout(60000);
                        try {
                            request.getHeaders().setAuthorization("bearer " + authoriser.getAccessToken());
                        } catch (IOException e) {
                            throw Throwables.propagate(e);
                        }

                        request.setUnsuccessfulResponseHandler(new OneDriveResponseHandler(authoriser));
                    }
                });
    }

    public Drive getDefaultDrive() throws IOException {
        HttpRequest request = requestFactory.buildGetRequest(OneDriveUrl.defaultDrive());
// Path: src/main/java/com/wouterbreukink/onedrive/client/authoriser/AuthorisationProvider.java
// public interface AuthorisationProvider {
// 
//     String getAccessToken() throws IOException;
// 
//     void refresh() throws IOException;
// 
//     class FACTORY {
//         public static AuthorisationProvider create(Path keyFile) throws IOException {
//             return new OneDriveAuthorisationProvider(keyFile);
//         }
// 
//         public static void printAuthInstructions() {
//             OneDriveAuthorisationProvider.printAuthInstructions();
//         }
//     }
// }
// 
// Path: src/main/java/com/wouterbreukink/onedrive/client/downloader/ResumableDownloaderProgressListener.java
// public interface ResumableDownloaderProgressListener {
// 
//     /**
//      * Called to notify that progress has been changed.
//      * <p>
//      * <p>
//      * This method is called multiple times depending on how many chunks are downloaded. Once the
//      * download completes it is called one final time.
//      * </p>
//      *
//      * @param downloader Media HTTP downloader
//      */
//     void progressChanged(ResumableDownloader downloader) throws IOException;
// }
// 
// Path: src/main/java/com/wouterbreukink/onedrive/client/resources/Drive.java
// public class Drive {
// 
//     @Key
//     private String id;
// 
//     @Key
//     private String driveType;
// 
//     @Key
//     private IdentitySet owner;
// 
//     @Key
//     private QuotaFacet quota;
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getDriveType() {
//         return driveType;
//     }
// 
//     public IdentitySet getOwner() {
//         return owner;
//     }
// 
//     public QuotaFacet getQuota() {
//         return quota;
//     }
// }
// 
// Path: src/main/java/com/wouterbreukink/onedrive/client/resources/Item.java
// public class Item {
// 
//     @Key
//     private String id;
//     @Key
//     private String name;
//     @Key
//     private String eTag;
//     @Key
//     private String cTag;
//     @Key
//     private IdentitySet createdBy;
//     @Key
//     private IdentitySet lastModifiedBy;
//     @Key
//     private String createdDateTime;
//     @Key
//     private String lastModifiedDateTime;
//     @Key
//     private long size;
//     @Key
//     private ItemReference parentReference;
//     @Key
//     private Item[] children;
//     @Key
//     private String webUrl;
//     @Key
//     private FolderFacet folder;
//     @Key
//     private FileFacet file;
//     @Key
//     private FileSystemInfoFacet fileSystemInfo;
//     @Key
//     private DeletedFacet deleted;
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public String geteTag() {
//         return eTag;
//     }
// 
//     public String getcTag() {
//         return cTag;
//     }
// 
//     public IdentitySet getCreatedBy() {
//         return createdBy;
//     }
// 
//     public IdentitySet getLastModifiedBy() {
//         return lastModifiedBy;
//     }
// 
//     public String getCreatedDateTime() {
//         return createdDateTime;
//     }
// 
//     public String getLastModifiedDateTime() {
//         return lastModifiedDateTime;
//     }
// 
//     public long getSize() {
//         return size;
//     }
// 
//     public ItemReference getParentReference() {
//         return parentReference;
//     }
// 
//     public String getWebUrl() {
//         return webUrl;
//     }
// 
//     public FolderFacet getFolder() {
//         return folder;
//     }
// 
//     public FileFacet getFile() {
//         return file;
//     }
// 
//     public FileSystemInfoFacet getFileSystemInfo() {
//         return fileSystemInfo;
//     }
// 
//     public DeletedFacet getDeleted() {
//         return deleted;
//     }
// 
//     public Item[] getChildren() {
//         return children;
//     }
// }


// Path: src/main/java/com/wouterbreukink/onedrive/client/ROOneDriveProvider.java
import com.google.api.client.http.*;
import com.google.api.client.http.apache.ApacheHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonObjectParser;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.client.repackaged.com.google.common.base.Throwables;
import com.google.api.client.util.Lists;
import com.wouterbreukink.onedrive.client.authoriser.AuthorisationProvider;
import com.wouterbreukink.onedrive.client.downloader.ResumableDownloaderProgressListener;
import com.wouterbreukink.onedrive.client.resources.Drive;
import com.wouterbreukink.onedrive.client.resources.Item;
import com.wouterbreukink.onedrive.client.resources.ItemSet;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;

package com.wouterbreukink.onedrive.client;



class ROOneDriveProvider implements OneDriveProvider {

    static final HttpTransport HTTP_TRANSPORT = new ApacheHttpTransport();
    static final JsonFactory JSON_FACTORY = new GsonFactory();

    final HttpRequestFactory requestFactory;

    public ROOneDriveProvider(final AuthorisationProvider authoriser) {
        requestFactory =
                HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() {
                    @Override
                    public void initialize(HttpRequest request) {
                        request.setParser(new JsonObjectParser(JSON_FACTORY));
                        request.setReadTimeout(60000);
                        request.setConnectTimeout(60000);
                        try {
                            request.getHeaders().setAuthorization("bearer " + authoriser.getAccessToken());
                        } catch (IOException e) {
                            throw Throwables.propagate(e);
                        }

                        request.setUnsuccessfulResponseHandler(new OneDriveResponseHandler(authoriser));
                    }
                });
    }

    public Drive getDefaultDrive() throws IOException {
        HttpRequest request = requestFactory.buildGetRequest(OneDriveUrl.defaultDrive());
        return request.execute().parseAs(Drive.class);