public void retrieveMetadataForFile()
        {
            Dictionary <String, Link> linksFromFirstFile = OAuthWorkFlow.linksFrom(files.page[3]);

            firstFileSelfUri = linksFromFirstFile["self"].uri;

            Hammock.Authentication.OAuth.OAuthCredentials credentials = OAuthWorkFlow.createOAuthCredentials(OAuthType.ProtectedResource, ApiCredentials.TOKEN.token,
                                                                                                             ApiCredentials.TOKEN.secret, null, null);


            Hammock.RestClient client = new Hammock.RestClient()
            {
                Authority   = "",
                Credentials = credentials
            };

            Hammock.RestRequest request = new Hammock.RestRequest()
            {
                Path = firstFileSelfUri
            };

            request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json");
            Hammock.RestResponse response = client.Request(request);

            SampleApp.Sources.generated.v3.File firstFileDetails = Deserialise <SampleApp.Sources.generated.v3.File>(response.ContentStream);

            filename = firstFileDetails.name;
        }
        public void uploadFile()
        {
            SampleApp.Sources.generated.v3.File apiFile = new SampleApp.Sources.generated.v3.File();
            apiFile.name = "greatFileFromBrian.zip";

            Hammock.RestClient client = getRestClient();

            Hammock.RestRequest request = new Hammock.RestRequest()
            {
                Path   = fileUploadLink.uri,
                Method = WebMethod.Put
            };

            request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json");
            request.AddHeader("Content-Type", "application/zip");
            MemoryStream ms = Serialize1 <SampleApp.Sources.generated.v3.File>(apiFile);

            request.AddPostContent(ms.ToArray());
            Hammock.RestResponse response = client.Request(request);


            /*final RestRequest fileUploadRequest = oauthRequestTo(newFileLocation)
             *      .method("PUT")
             *      .addHeader(new HttpHeader("Accept", "application/vnd.deere.axiom.v3+json"))
             *      .addHeader(new HttpHeader("Content-Type", "application/zip"))
             *      .body(Files.newInputStreamSupplier(findFile("wdtTestFile.zip")))
             *      .build();
             *
             * final RestResponse fileUploadResponse = fileUploadRequest.fetchResponse();
             * checkThat("PUT Response", fileUploadResponse.getResponseCode(), isEqualTo(NO_CONTENT));*/
        }
        private void UploadNewFileToOrganization(Organization organization)
        {
            var filesApiUrl = organization.links.SingleOrDefault(link => link.rel == LinkRel.files.ToString())?.uri;

            if (filesApiUrl == null)
            {
                return;
            }
            var file = new File {
                name = "GS3 - 2630 Setup Data.zip"
            };
            var fileUrl = _apiClient.PostNewObject(filesApiUrl, file);

            var executableDirectory = AppDomain.CurrentDomain.BaseDirectory;
            var fileName            = Path.Combine(executableDirectory, "Resources", "GS3 - 2630 Setup Data.zip");
            var fileContents        = System.IO.File.ReadAllBytes(fileName);

            _apiClient.PutBinaryPayload(fileUrl, fileContents);
        }
        public void deleteUploadedFile()
        {
            SampleApp.Sources.generated.v3.File apiFile = new SampleApp.Sources.generated.v3.File();
            Hammock.RestClient client = getRestClient();

            Hammock.RestRequest request = new Hammock.RestRequest()
            {
                Path   = newFileLocation,
                Method = WebMethod.Delete
            };

            request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json");
            Hammock.RestResponse response = client.Request(request);

            /*  final RestRequest deleteFileRequest = oauthRequestTo(newFileLocation)
             *        .method("DELETE")
             *        .addHeader(new HttpHeader("Accept", "application/vnd.deere.axiom.v3+json"))
             *        .build();
             *
             * final RestResponse deleteResponse = deleteFileRequest.fetchResponse();
             * checkThat("DELETE Response", deleteResponse.getResponseCode(), isEqualTo(NO_CONTENT));*/
        }
        public void addFile()
        {
            SampleApp.Sources.generated.v3.File apiFile = new SampleApp.Sources.generated.v3.File();
            apiFile.name = "greatFileFromBrian.zip";

            Hammock.RestClient client = getRestClient();

            Hammock.RestRequest request = new Hammock.RestRequest()
            {
                Path   = fileUploadLink.uri,
                Method = WebMethod.Post
            };

            request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json");
            request.AddHeader("Content-Type", "application/vnd.deere.axiom.v3+json");

            String s = JsonConvert.SerializeObject(apiFile);

            request.AddPostContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(apiFile)));
            Hammock.RestResponse response = client.Request(request);

            newFileLocation = response.Headers["Location"];
        }