Наследование: IDataResponse
        public IDataResponse FindDevices(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(GetDevicesUrl))
                {
                    string url = string.Format("{0}/{1}/", _baseUrl, _apiVersion);
                    RestClient client = new RestClient(url);
                    RestRequest request = new RestRequest(GetDevicesUrl, Method.POST);

                    //add headers, include user authentication we pass in with admin privileges
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    if (String.IsNullOrEmpty(data.Cursor))
                    {
                        //set up properties for JSON to the API
                        JObject jsonSearch = new JObject(
                            new JProperty("include_web_sessions", true),
                            new JProperty("include_desktop_clients", true),
                            new JProperty("include_mobile_clients", true)
                        );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }
                    if (!String.IsNullOrEmpty(data.Cursor))
                    {
                        //set up properties for JSON to the API with cursor for continuation
                        JObject jsonSearch = new JObject(
                            new JProperty("cursor", data.Cursor),
                            new JProperty("include_web_sessions", true),
                            new JProperty("include_desktop_clients", true),
                            new JProperty("include_mobile_clients", true)
                        );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IDataResponse DumpDevices(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(DumpDevicesUrl))
                {
                    string url = string.Format("{0}/{1}/", _baseUrl, _apiVersion);
                    RestClient client = new RestClient(url);
                    RestRequest request = new RestRequest(DumpDevicesUrl, Method.POST);

                    //add headers, include user authentication we pass in with admin privileges
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    string ClientType = data.ClientType;
                    string ClientTypeAPI = string.Empty;
                    if (ClientType == "Desktop")
                    {
                        ClientTypeAPI = "desktop_client";
                    }
                    if (ClientType == "Web")
                    {
                        ClientTypeAPI = "web_session";
                    }
                    if (ClientType == "Mobile")
                    {
                        ClientTypeAPI = "mobile_client";
                    }
                    //set up properties for JSON to the API
                    //if desktop client, do a delete_on_unlink set to true to delete all files of account
                    if (ClientTypeAPI == "desktop_client")
                    {
                        JObject jsonSearch = new JObject(
                            new JProperty(".tag", ClientTypeAPI),
                            new JProperty("session_id", data.SessionId),
                            new JProperty("team_member_id", data.MemberId),
                            new JProperty("delete_on_unlink", true)
                        );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }
                    if (ClientTypeAPI == "web_session" || ClientTypeAPI == "mobile_client")
                    {
                        JObject jsonSearch = new JObject(
                            new JProperty(".tag", ClientTypeAPI),
                            new JProperty("session_id", data.SessionId),
                            new JProperty("team_member_id", data.MemberId)
                        );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IDataResponse DumpFile(IMemberData data, string outputFolder, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(FileDumpUrl))
                {
                    //added this to be able to get files with ASCII characters in them.
                    Byte[] encodedBytes = System.Text.Encoding.ASCII.GetBytes(data.Path);
                    string newPath = System.Text.Encoding.ASCII.GetString(encodedBytes);

                    string pathString = string.Concat(@"{""path"":""", newPath, @"""}");
                    string url = string.Format("{0}/{1}/", _baseUrl, _apiVersion);
                    RestClient client = new RestClient(url);
                    RestRequest request = new RestRequest(FileDumpUrl, Method.GET);
                    client.UserAgent = UserAgentVersion;
                    //add headers, include user authentication we pass in with admin privileges
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Dropbox-API-Select-User", data.MemberId);
                    request.AddHeader("Dropbox-API-Arg", pathString);

                    //download file by using raw bytes returned
                    byte[] jsonResponseDump = client.DownloadData(request);

                    // strip out email prefix as folder name.
                    int index = data.Email.IndexOf("@");
                    string folderName = data.Email.Substring(0, index);

                    if (!data.ZipFiles)
                    {
                        //get the Dropbox folder structure so we can recreate correct folder structure locally under user folder below
                        String dbdirName = Path.GetDirectoryName(data.Path);
                        dbdirName = dbdirName.Remove(0, 1);

                        //combine Dropbox subdirectory to email username
                        if (!string.IsNullOrEmpty(dbdirName))
                        {
                            folderName = folderName + "\\" + dbdirName;
                        }
                        string fullOutputFolder = Path.Combine(outputFolder, folderName);

                        if (!Directory.Exists(fullOutputFolder))
                        {
                            Directory.CreateDirectory(fullOutputFolder);
                        }
                        string outputPath = Path.Combine(fullOutputFolder, data.FileName);
                        File.WriteAllBytes(outputPath, jsonResponseDump);
                    }
                         
                    //Added 5/5/16 - Zip file if needed. If first file create the zipfile, if not just add to existing zip file  
                    if (data.ZipFiles)
                    {
                        string fullOutputFolder = Path.Combine(outputFolder, folderName);
                        if (!Directory.Exists(fullOutputFolder))
                        {
                            Directory.CreateDirectory(fullOutputFolder);
                        }
                        string outputPath = Path.Combine(fullOutputFolder, data.FileName);
                        File.WriteAllBytes(outputPath, jsonResponseDump);

                        string dateString = DateTime.Now.ToString("-M.dd.yyyy");
                        string zipName = Path.Combine(fullOutputFolder, (folderName + dateString + ".zip"));
                        if (File.Exists(zipName))
                        {
                            using (ZipArchive modFile = ZipFile.Open(zipName, ZipArchiveMode.Update))
                            {
                                modFile.CreateEntryFromFile(outputPath, data.FileName, CompressionLevel.Fastest);
                            }
                        }
                        if (!File.Exists(zipName))
                        {
                            using (ZipArchive newFile = ZipFile.Open(zipName, ZipArchiveMode.Create))
                            {
                                newFile.CreateEntryFromFile(outputPath, data.FileName, CompressionLevel.Fastest);
                            }
                        }
                        File.Delete(outputPath);
                    }         
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IDataResponse ListTeamFolders(string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(ListTeamFolderUrl))
                {
                    RestClient client = new RestClient(
                        string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                    );
                    RestRequest request = new RestRequest(ListTeamFolderUrl, Method.POST);

                    //add headers
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    JObject json = new JObject(
                        new JProperty("limit", 1000)
                    );
                    request.AddParameter("application/json", json, ParameterType.RequestBody);
                    request.RequestFormat = DataFormat.Json;
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
                else
                {
                    throw new ArgumentNullException("Missing service url");
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
 public IDataResponse GetInfo(string authToken)
 {
     IDataResponse dataResponse = null;
     try
     {
         if (!string.IsNullOrEmpty(GetInfoUrl))
         {
             RestClient client = new RestClient(
                    string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                );
             RestRequest request = new RestRequest(GetInfoUrl, Method.POST);
             //add headers
             request.AddHeader("Authorization", "Bearer " + authToken);
             client.UserAgent = UserAgentVersion;
             IRestResponse response = client.Execute(request);
             dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
         }
         else
         {
             throw new ArgumentNullException("Missing service url");
         }
     }
     catch (Exception e)
     {
         dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
     }
     return dataResponse;
 }
        public IDataResponse SearchFiles(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(SearchFilesUrl))
                {
                    RestClient client = new RestClient(
                           string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                       );
                    RestRequest request = new RestRequest(SearchFilesUrl, Method.POST);
                    //add headers
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");
                    request.AddHeader("Dropbox-API-Select-User", data.MemberId);

                    //set up properties for JSON to the API
                    JObject jsonSearch = new JObject(
                        new JProperty("path", ""),
                        new JProperty("query", data.SearchText),
                        new JProperty("max_results", data.SearchLimit),
                        new JProperty("mode", data.SearchMode)
                    );
                    request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
                else
                {
                    throw new ArgumentNullException("Missing service url");
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IDataResponse GetGroups(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(GetGroupsUrl))
                {
                    RestClient client = new RestClient(
                           string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                       );
                    RestRequest request = new RestRequest(GetGroupsUrl, Method.POST);
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    if (String.IsNullOrEmpty(data.Cursor))
                    {
                        //set up properties for JSON to the API
                        JObject jsonSearch = new JObject(
                        new JProperty("limit", 1000)
                       );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }

                    if (!String.IsNullOrEmpty(data.Cursor))
                    {
                        //set up properties for JSON to the API
                        JObject jsonSearch = new JObject(
                        new JProperty("cursor", data.Cursor)
                       );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);

                    }
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }